Skip to content

Commit

Permalink
Merge pull request #511 from openvinotoolkit/keep-label-ids-upon-proj…
Browse files Browse the repository at this point in the history
…ect-deployment

Keep label ID's intact on saving project deployment
  • Loading branch information
ljcornel authored Oct 29, 2024
2 parents d6e19d2 + 02e5437 commit ca42ad1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion geti_sdk/deployment/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def save(self, path_to_folder: Union[str, os.PathLike]) -> bool:
:param path_to_folder: Folder to save the deployment to
:return: True if the deployment was saved successfully, False otherwise
"""
project_dict = ProjectRESTConverter.to_dict(self.project)
project_dict = ProjectRESTConverter.to_dict(self.project, deidentify=False)
deployment_folder = os.path.join(path_to_folder, "deployment")

os.makedirs(deployment_folder, exist_ok=True, mode=0o770)
Expand Down
8 changes: 6 additions & 2 deletions geti_sdk/rest_converters/project_rest_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,21 @@ def from_dict(cls, project_input: Dict[str, Any]) -> Project:
return deserialize_dictionary(prepared_project, output_type=Project)

@classmethod
def to_dict(cls, project: Project) -> Dict[str, Any]:
def to_dict(cls, project: Project, deidentify: bool = True) -> Dict[str, Any]:
"""
Convert the `project` to its dictionary representation.
This functions removes database UID's and optional fields that are `None`
from the output dictionary, to make the output more compact and improve
readability.
:param project: Project to convert to dictionary
:param deidentify: True to remove all unique database ID's from the project
and it's child entities, False to keep the ID's intact. Defaults to True,
which is useful for project import/export
:return:
"""
project.deidentify()
if deidentify:
project.deidentify()
project_data = project.to_dict()
remove_null_fields(project_data)
return project_data

0 comments on commit ca42ad1

Please sign in to comment.