Skip to content

Commit

Permalink
GPU keys to list (#1694)
Browse files Browse the repository at this point in the history
  • Loading branch information
timmo001 authored May 19, 2022
1 parent aae2bf6 commit b82f950
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 6 deletions.
3 changes: 3 additions & 0 deletions backend/systembridgebackend/modules/gpu/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ async def update_temperature(

async def update_all_data(self) -> None:
"""Update data"""
gpu_list = []
for gpu_name in self._gpu.get_gpus(self._database):
gpu_key = make_key(gpu_name)
gpu_list.append(gpu_key)
await asyncio.gather(
*[
self.update_name(gpu_key, gpu_name),
Expand All @@ -134,3 +136,4 @@ async def update_all_data(self) -> None:
self.update_temperature(gpu_key),
]
)
self._database.write("gpu", "gpus", str(gpu_list))
2 changes: 1 addition & 1 deletion connector/systembridgeconnector/models/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ class Display(BaseModel):
class Config:
extra = Extra.allow

displays: list
displays: list[str]
last_updated: LastUpdated = Field(..., description="Last updated")
14 changes: 13 additions & 1 deletion connector/systembridgeconnector/models/gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
from pydantic import BaseModel, Extra, Field


class LastUpdated(BaseModel):
"""
Last updated
"""

class Config:
extra = Extra.allow

gpus: float


class Gpu(BaseModel):
"""
GPU
Expand All @@ -14,4 +25,5 @@ class Gpu(BaseModel):
class Config:
extra = Extra.allow

last_updated: dict[str, float] = Field(..., description="Last updated")
gpus: list[str]
last_updated: LastUpdated = Field(..., description="Last updated")
2 changes: 1 addition & 1 deletion schemas/data/display.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
}
},
"additionalProperties": {},
"required": ["last_updated"]
"required": ["displays", "last_updated"]
}
10 changes: 9 additions & 1 deletion schemas/data/gpu.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@
"type": "object",
"description": "GPU",
"properties": {
"gpus": {
"type": "array"
},
"last_updated": {
"type": "object",
"description": "Last updated",
"properties": {
"gpus": {
"type": "number"
}
},
"additionalProperties": {
"type": "number"
}
}
},
"additionalProperties": {},
"required": ["last_updated"]
"required": ["gpus", "last_updated"]
}
2 changes: 1 addition & 1 deletion shared/systembridgeshared/models/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ class Display(BaseModel):
class Config:
extra = Extra.allow

displays: list
displays: list[str]
last_updated: LastUpdated = Field(..., description="Last updated")
14 changes: 13 additions & 1 deletion shared/systembridgeshared/models/gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
from pydantic import BaseModel, Extra, Field


class LastUpdated(BaseModel):
"""
Last updated
"""

class Config:
extra = Extra.allow

gpus: float


class Gpu(BaseModel):
"""
GPU
Expand All @@ -14,4 +25,5 @@ class Gpu(BaseModel):
class Config:
extra = Extra.allow

last_updated: dict[str, float] = Field(..., description="Last updated")
gpus: list[str]
last_updated: LastUpdated = Field(..., description="Last updated")

0 comments on commit b82f950

Please sign in to comment.