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

added costs as a column to tracking databases #664

Merged
merged 4 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- `MultiBackendJobManager`: costs has been added as a column in tracking databases ([[#588](https://github.com/Open-EO/openeo-python-client/issues/588)])

### Removed

### Fixed
Expand Down
3 changes: 3 additions & 0 deletions openeo/extra/job_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def start_job(
"cpu": _ColumnProperties(dtype="str"),
"memory": _ColumnProperties(dtype="str"),
"duration": _ColumnProperties(dtype="str"),
"costs": _ColumnProperties(dtype="str"),
VictorVerhaert marked this conversation as resolved.
Show resolved Hide resolved
}

def __init__(
Expand Down Expand Up @@ -744,6 +745,8 @@ def _track_statuses(self, job_db: JobDatabaseInterface, stats: Optional[dict] =
for key in job_metadata.get("usage", {}).keys():
if key in active.columns:
active.loc[i, key] = _format_usage_stat(job_metadata, key)
if "costs" in job_metadata.keys():
active.loc[i, "costs"] = job_metadata.get("costs")

except OpenEoApiError as e:
# TODO: inspect status code and e.g. differentiate between 4xx/5xx
Expand Down
4 changes: 4 additions & 0 deletions tests/extra/test_job_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def test_normalize_df(self):
"memory",
"duration",
"backend_name",
"costs",
]
)

Expand Down Expand Up @@ -673,6 +674,7 @@ def test_initialize_from_df(self, tmp_path, db_class):
"memory",
"duration",
"backend_name",
"costs",
}

actual_columns = set(db_class(path).read().columns)
Expand Down Expand Up @@ -852,6 +854,7 @@ def test_initialize_from_df(self, tmp_path):
"memory",
"duration",
"backend_name",
"costs",
}

# Raw file content check
Expand Down Expand Up @@ -930,6 +933,7 @@ def test_initialize_from_df(self, tmp_path):
"memory",
"duration",
"backend_name",
"costs",
}

df_from_disk = ParquetJobDatabase(path).read()
Expand Down