Skip to content

Commit

Permalink
Replace ClusterUtilization.id with ClusterUtilization.cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
epwalsh committed May 5, 2022
1 parent 7533fa8 commit 25676aa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Changed

- Replaced `id: str` field of `ClusterUtilization` with `cluster: Cluster`. `id` is still available
as a property for backwards compatibility.

## [v0.14.0](https://github.com/allenai/beaker-py/releases/tag/v0.14.0) - 2022-05-04

### Added
Expand Down
6 changes: 5 additions & 1 deletion beaker/data_model/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ def is_active(self) -> bool:


class ClusterUtilization(BaseModel):
id: str
cluster: Cluster
running_jobs: int
queued_jobs: int
nodes: Tuple[NodeUtilization, ...]

@property
def id(self) -> str:
return self.cluster.id


class ClusterSpec(BaseModel):
name: str
Expand Down
2 changes: 1 addition & 1 deletion beaker/services/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def utilization(self, cluster: Union[str, Cluster]) -> ClusterUtilization:
node_util["cpus_used"] += job.requests.cpu_count

return ClusterUtilization(
id=cluster.id,
cluster=cluster,
running_jobs=running_jobs,
queued_jobs=queued_jobs,
nodes=[
Expand Down
4 changes: 4 additions & 0 deletions tests/cluster_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def test_cluster_get_on_prem(client: Beaker, beaker_on_prem_cluster_name: str):
assert cluster.node_shape is None


def test_cluster_utilization(client: Beaker, beaker_on_prem_cluster_name: str):
client.cluster.utilization(beaker_on_prem_cluster_name)


def test_cluster_list(client: Beaker, beaker_org: Organization):
client.cluster.list(beaker_org)

Expand Down

0 comments on commit 25676aa

Please sign in to comment.