Skip to content

Commit

Permalink
Add Job Cost info to job data scheme (#467)
Browse files Browse the repository at this point in the history
* add job cost info to job data scheme

Signed-off-by: Igor Davidyuk <igor.davidyuk@intel.com>

* Update geti_sdk/rest_clients/project_client/project_client.py

Co-authored-by: Ludo Cornelissen <ludo.cornelissen@intel.com>

---------

Signed-off-by: Igor Davidyuk <igor.davidyuk@intel.com>
Co-authored-by: Ludo Cornelissen <ludo.cornelissen@intel.com>
  • Loading branch information
igor-davidyuk and ljcornel authored Jul 18, 2024
1 parent 68fd223 commit 9556cf4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
11 changes: 11 additions & 0 deletions geti_sdk/data_models/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,16 @@ class JobCancellationInfo:
cancel_time: Optional[str] = attr.field(converter=str_to_datetime, default=None)


@attr.define
class JobCost:
"""
Information relating to the cost of a Job in Intel Geti
"""

requests: List
consumed: List


@attr.define(slots=False)
class Job:
"""
Expand Down Expand Up @@ -248,6 +258,7 @@ class Job:
converter=str_to_optional_enum_converter(JobState), default=None
) # Added in Geti v1.7
steps: Optional[List[dict]] = None # Added in Geti v1.7
cost: Optional[JobCost] = None # Added in Geti v2.2

def __attrs_post_init__(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions geti_sdk/data_models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ def summary(self) -> str:
@property
def training_dataset(self) -> Dataset:
"""
Return the training dataset for the project.
Return a training dataset for the project.
:return: Training dataset for the project
"""
return [dataset for dataset in self.datasets if dataset.use_for_training][0]
return next(dataset for dataset in self.datasets if dataset.use_for_training)
12 changes: 7 additions & 5 deletions geti_sdk/rest_clients/project_client/project_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ def get_project_by_name(
f"the project ID's `{[p.id for p in matches]}` matches the "
f"requested id `{project_id}`."
)
return matched_project
return None
else:
return self._get_project_detail(matched_project)
else:
return None

Expand Down Expand Up @@ -524,10 +526,10 @@ def delete_project(
f"{dataset.id}/statistics",
method="GET",
)
if dataset_statistics is dict:
dataset_statistics["overview"].get("image_count", 0)
image_count += dataset_statistics.get("images", 0)
video_count += dataset_statistics.get("videos", 0)
if isinstance(dataset_statistics, dict):
dataset_overview = dataset_statistics["overview"]
image_count += dataset_overview.get("images", 0)
video_count += dataset_overview.get("videos", 0)
else:
logging.warning(
f"Unable to retrieve statistics for dataset {dataset.name}."
Expand Down

0 comments on commit 9556cf4

Please sign in to comment.