Skip to content

Commit a6b3ae7

Browse files
added costs as a column to tracking databases
1 parent aa3e653 commit a6b3ae7

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
### Changed
1515

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

1820
### Fixed

openeo/extra/job_management.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ def start_job(
207207
"cpu": _ColumnProperties(dtype="str"),
208208
"memory": _ColumnProperties(dtype="str"),
209209
"duration": _ColumnProperties(dtype="str"),
210+
"costs": _ColumnProperties(dtype="str"),
210211
}
211212

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

748751
except OpenEoApiError as e:
749752
# TODO: inspect status code and e.g. differentiate between 4xx/5xx

tests/extra/test_job_management.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ def test_normalize_df(self):
283283
"memory",
284284
"duration",
285285
"backend_name",
286+
"costs",
286287
]
287288
)
288289

@@ -673,6 +674,7 @@ def test_initialize_from_df(self, tmp_path, db_class):
673674
"memory",
674675
"duration",
675676
"backend_name",
677+
"costs",
676678
}
677679

678680
actual_columns = set(db_class(path).read().columns)
@@ -852,6 +854,7 @@ def test_initialize_from_df(self, tmp_path):
852854
"memory",
853855
"duration",
854856
"backend_name",
857+
"costs",
855858
}
856859

857860
# Raw file content check
@@ -930,6 +933,7 @@ def test_initialize_from_df(self, tmp_path):
930933
"memory",
931934
"duration",
932935
"backend_name",
936+
"costs",
933937
}
934938

935939
df_from_disk = ParquetJobDatabase(path).read()

0 commit comments

Comments
 (0)