Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Job Cost info to job data scheme #467

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading