File tree Expand file tree Collapse file tree 6 files changed +17
-14
lines changed
Expand file tree Collapse file tree 6 files changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -489,7 +489,7 @@ def sync(ctx):
489489 current_bar .finish ()
490490
491491 # A new push job has started. Initialize a new progress bar.
492- click .echo (f"Starting upload" )
492+ click .echo (f"\n Starting upload" )
493493 current_job = job
494494
495495 # The length of the progress bar should be the total size of the job
Original file line number Diff line number Diff line change 1919from time import sleep
2020
2121from .common import (
22- PUSH_ATTEMPT_WAIT ,
23- PUSH_ATTEMPTS ,
22+ SYNC_ATTEMPT_WAIT ,
23+ SYNC_ATTEMPTS ,
2424 SYNC_CALLBACK_WAIT ,
2525 ClientError ,
2626 LoginError ,
@@ -1542,13 +1542,13 @@ def sync_project_generator(self, project_directory):
15421542 _ , has_changes = get_push_changes_batch (self , project_directory )
15431543 server_conflict_attempts = 0
15441544 except ClientError as e :
1545- if e .is_retryable_sync () and server_conflict_attempts < PUSH_ATTEMPTS - 1 :
1545+ if e .is_retryable_sync () and server_conflict_attempts < SYNC_ATTEMPTS - 1 :
15461546 # retry on conflict, e.g. when server has changes that we do not have yet
15471547 mp .log .info (
1548- f"Restarting sync process (conflict on server) - { server_conflict_attempts + 1 } /{ PUSH_ATTEMPTS } "
1548+ f"Restarting sync process (conflict on server) - { server_conflict_attempts + 1 } /{ SYNC_ATTEMPTS } "
15491549 )
15501550 server_conflict_attempts += 1
1551- sleep (PUSH_ATTEMPT_WAIT )
1551+ sleep (SYNC_ATTEMPT_WAIT )
15521552 continue
15531553 raise e
15541554
Original file line number Diff line number Diff line change 3636from .editor import filter_changes
3737from .utils import get_data_checksum
3838
39+ POST_JSON_HEADERS = {"Content-Type" : "application/json" }
40+
3941
4042class UploadChunksCache :
4143 """A cache for uploaded chunks to avoid re-uploading them, using checksum as key."""
@@ -248,13 +250,13 @@ def create_upload_job(
248250 mc .post (
249251 f"/v2/projects/{ project_id } /versions" ,
250252 {** data , "check_only" : True },
251- { "Content-Type" : "application/json" } ,
253+ POST_JSON_HEADERS ,
252254 )
253255 else :
254256 resp = mc .post (
255257 f"/v1/project/push/{ project_path } " ,
256258 data ,
257- { "Content-Type" : "application/json" } ,
259+ POST_JSON_HEADERS ,
258260 )
259261 push_start_resp = json .load (resp )
260262 except ClientError as err :
Original file line number Diff line number Diff line change 1515# size of the log file part to send (if file is larger only this size from end will be sent)
1616MAX_LOG_FILE_SIZE_TO_SEND = 5 * 1024 * 1024
1717
18- # number of attempts to push changes (in case of network issues etc)
19- PUSH_ATTEMPTS = 10
18+ # number of attempts of sync changes (in case of conflicted version etc. )
19+ SYNC_ATTEMPTS = 10
2020
21- # seconds to wait between attempts to push changes
22- PUSH_ATTEMPT_WAIT = 5
21+ # seconds to wait between attempts to sync changes (in case of conflicted version etc.)
22+ SYNC_ATTEMPT_WAIT = 5
2323
2424# seconds to wait between sync callback calls
2525SYNC_CALLBACK_WAIT = 0.01
Original file line number Diff line number Diff line change 55from .utils import is_versioned_file
66from .common import MAX_UPLOAD_MEDIA_SIZE , MAX_UPLOAD_VERSIONED_SIZE
77
8+ # Maximum changes uploading to server
89MAX_UPLOAD_CHANGES = 100
910
1011
Original file line number Diff line number Diff line change @@ -3198,7 +3198,7 @@ def test_client_project_sync_retry(mc):
31983198 mc .sync_project (project_dir )
31993199 assert mock_push_project_finalize .call_count == 1
32003200
3201- with patch ("mergin.client.push_project_async" ) as mock_push_project_async , patch ("mergin.client.PUSH_ATTEMPTS " , 2 ):
3201+ with patch ("mergin.client.push_project_async" ) as mock_push_project_async , patch ("mergin.client.SYNC_ATTEMPTS " , 2 ):
32023202 mock_push_project_async .side_effect = ClientError (
32033203 detail = "" ,
32043204 server_code = ErrorCode .AnotherUploadRunning .value ,
@@ -3208,7 +3208,7 @@ def test_client_project_sync_retry(mc):
32083208 assert mock_push_project_async .call_count == 2
32093209
32103210 # for v1 endpoints we are rising retry just from push start
3211- with patch ("mergin.client.push_project_async" ) as mock_push_project_async , patch ("mergin.client.PUSH_ATTEMPTS " , 2 ):
3211+ with patch ("mergin.client.push_project_async" ) as mock_push_project_async , patch ("mergin.client.SYNC_ATTEMPTS " , 2 ):
32123212 mock_push_project_async .side_effect = ClientError (
32133213 detail = "Another process is running. Please try later." ,
32143214 http_error = 400 ,
You can’t perform that action at this time.
0 commit comments