@@ -46,17 +46,17 @@ def __init__(self,
4646 self ._organization_manager = organization_manager
4747 self ._cloud_projects = []
4848
49- def push_project (self , project : Path , encryption_action : Optional [ActionType ]= None , encryption_key : Optional [Path ]= None ) -> None :
49+ def push_project (self , project : Path , encryption_action : Optional [ActionType ]= None , encryption_key : Optional [Path ]= None , force : Optional [ bool ] = False ) -> None :
5050 """Pushes the given project from the local drive to the cloud.
5151
5252 It will also push every library referenced by the project and add or remove references.
5353
5454 :param project: path to the directory containing the local project that needs to be pushed
5555 """
5656 libraries = self ._project_manager .get_project_libraries (project )
57- self .push_projects ([project ], libraries , encryption_action , encryption_key )
57+ self .push_projects ([project ], libraries , encryption_action , encryption_key , force )
5858
59- def push_projects (self , projects_to_push : List [Path ], associated_libraries_to_push : Optional [List [Path ]]= [], encryption_action : Optional [ActionType ]= None , encryption_key : Optional [Path ]= None ) -> None :
59+ def push_projects (self , projects_to_push : List [Path ], associated_libraries_to_push : Optional [List [Path ]]= [], encryption_action : Optional [ActionType ]= None , encryption_key : Optional [Path ]= None , force : Optional [ bool ] = False ) -> None :
6060 """Pushes the given projects from the local drive to the cloud.
6161
6262 It will also push every library referenced by each project and add or remove references.
@@ -78,7 +78,7 @@ def push_projects(self, projects_to_push: List[Path], associated_libraries_to_pu
7878 relative_path = path .relative_to (Path .cwd ())
7979 try :
8080 self ._logger .info (f"[{ index } /{ len (all_projects_to_push )} ] Pushing '{ relative_path } '" )
81- self ._push_project (path , organization_id , encryption_action_value , encryption_key_value )
81+ self ._push_project (path , organization_id , encryption_action_value , encryption_key_value , force = force )
8282 except Exception as ex :
8383 from traceback import format_exc
8484 self ._logger .debug (format_exc ().strip ())
@@ -95,7 +95,7 @@ def _get_local_libraries_cloud_ids(self, project_dir: Path) -> List[int]:
9595
9696 return local_libraries_cloud_ids
9797
98- def _push_project (self , project_path : Path , organization_id : str , encryption_action : Optional [ActionType ], encryption_key : Optional [Path ], suggested_rename_path : Path = None ) -> None :
98+ def _push_project (self , project_path : Path , organization_id : str , encryption_action : Optional [ActionType ], encryption_key : Optional [Path ], force : Optional [ bool ], suggested_rename_path : Path = None ) -> None :
9999 """Pushes a single local project to the cloud.
100100
101101 Raises an error with a descriptive message if the project cannot be pushed.
@@ -111,7 +111,6 @@ def _push_project(self, project_path: Path, organization_id: str, encryption_act
111111 if suggested_rename_path and suggested_rename_path != project_path :
112112 potential_new_name = suggested_rename_path .relative_to (Path .cwd ()).as_posix ()
113113
114-
115114 project_config = self ._project_config_manager .get_project_config (project_path )
116115 cloud_id = project_config .get ("cloud-id" )
117116 local_encryption_state = project_config .get ("encrypted" , False )
@@ -163,7 +162,7 @@ def _push_project(self, project_path: Path, organization_id: str, encryption_act
163162 encryption_key = local_encryption_key
164163 encryption_action = ActionType .ENCRYPT if local_encryption_state else ActionType .DECRYPT
165164 # Finalize pushing by updating locally modified metadata, files and libraries
166- self ._push_metadata (project_path , cloud_project , encryption_action , encryption_key )
165+ self ._push_metadata (project_path , cloud_project , encryption_action , encryption_key , force )
167166
168167 def _get_files (self , project : Path , encryption_action : Optional [ActionType ], encryption_key : Optional [Path ]) -> List [Dict [str , str ]]:
169168 """Pushes the files of a local project to the cloud.
@@ -193,7 +192,7 @@ def _get_files(self, project: Path, encryption_action: Optional[ActionType], enc
193192
194193 return files
195194
196- def _push_metadata (self , project : Path , cloud_project : QCProject , encryption_action : Optional [ActionType ], encryption_key : Optional [Path ]) -> None :
195+ def _push_metadata (self , project : Path , cloud_project : QCProject , encryption_action : Optional [ActionType ], encryption_key : Optional [Path ], force : Optional [ bool ] ) -> None :
197196 """Pushes local project description and parameters to the cloud.
198197
199198 Does nothing if the cloud is already up-to-date.
@@ -260,13 +259,16 @@ def _push_metadata(self, project: Path, cloud_project: QCProject, encryption_act
260259
261260 if "encryption_key" in update_args :
262261 del update_args ["encryption_key" ]
262+ if not force :
263+ update_args ["code_source_id" ] = "cli"
263264 updated_keys = list (update_args )
264265 if len (updated_keys ) == 1 :
265266 updated_keys_str = updated_keys [0 ]
266267 elif len (updated_keys ) == 2 :
267268 updated_keys_str = " and " .join (updated_keys )
268269 else :
269270 updated_keys_str = ", " .join (updated_keys [:- 1 ]) + f", and { updated_keys [- 1 ]} "
271+
270272 self ._logger .info (f"Successfully updated { updated_keys_str } for '{ cloud_project .name } '" )
271273
272274 def _get_cloud_project (self , project_id : int , organization_id : str ) -> QCProject :
0 commit comments