Skip to content

Commit a5cb213

Browse files
committed
A couple of bug fixes including threading issues
1 parent 230e2f7 commit a5cb213

86 files changed

Lines changed: 2054 additions & 1410 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pyproject.toml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,15 @@ dev = [
8888
]
8989

9090
[tool.ruff]
91-
extend-exclude = ["tests", "examples", "notebooks"]
91+
extend-exclude = ["tests", "examples", "notebooks", "simvue/pynvml.py"]
92+
preview = true
9293

9394
[tool.ruff.lint]
95+
ignore = ["COM812", "PLR0904", "PLR6301", "D203", "D212"]
96+
dummy-variable-rgx = "^_+$"
9497
extend-select = [
95-
"C901",
96-
"T201",
98+
"C90",
99+
"D417",
97100
"E",
98101
"F",
99102
"W",
@@ -104,6 +107,33 @@ extend-select = [
104107
"ARG",
105108
"RUF",
106109
"RET",
110+
"S",
111+
"BLE",
112+
"FBT",
113+
"COM",
114+
"A",
115+
"C4",
116+
"DTZ",
117+
"ICN",
118+
"G",
119+
"PIE",
120+
"T20",
121+
"INP",
122+
"PYI",
123+
"PT",
124+
"Q",
125+
"RSE",
126+
"SLOT",
127+
"TID",
128+
"TC",
129+
"ARG",
130+
"I",
131+
"D417",
132+
"ERA",
133+
"PL",
134+
"UP",
135+
"FURB",
136+
"N",
107137
]
108138

109139
[tool.ruff.lint.mccabe]

simvue/api/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Simvue API
1+
"""Simvue API.
32
==========
43
54
Module contains methods for interacting with a Simvue server

simvue/api/objects/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Simvue API Objects
1+
"""Simvue API Objects.
32
==================
43
54
The following module defines objects which provide exact representations

simvue/api/objects/administrator/tenant.py

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
from typing import Self, override
1010
except ImportError:
1111
from typing_extensions import Self, override
12+
1213
import datetime
14+
import typing
1315
from collections.abc import Generator
1416

1517
import pydantic
@@ -34,7 +36,7 @@ def __init__(
3436
server_token: pydantic.SecretStr | None = None,
3537
**kwargs,
3638
) -> None:
37-
"""Initialise a Tenant
39+
"""Initialise a Tenant.
3840
3941
If an identifier is provided a connection will be made to the
4042
object matching the identifier on the target server.
@@ -52,9 +54,13 @@ def __init__(
5254
token for alternative server, default None
5355
**kwargs : dict
5456
any additional arguments to be passed to the object initialiser
57+
5558
"""
5659
super().__init__(
57-
identifier, server_url=server_url, server_token=server_token, **kwargs
60+
identifier,
61+
server_url=server_url,
62+
server_token=server_token,
63+
**kwargs,
5864
)
5965

6066
@override
@@ -124,7 +130,7 @@ def get(
124130
offset: pydantic.NonNegativeInt | None = None,
125131
server_url: str | None = None,
126132
server_token: pydantic.SecretStr | None = None,
127-
**kwargs,
133+
**kwargs: typing.Any,
128134
) -> Generator[tuple[str, Self | None]]:
129135
"""Retrieve tenants from the server.
130136
@@ -138,6 +144,8 @@ def get(
138144
alternative server URL, default None
139145
server_token : str | None, optional
140146
token for alternative server, default None
147+
**kwargs : Any
148+
additional arguments for retrieval
141149
142150
Yields
143151
------
@@ -147,86 +155,95 @@ def get(
147155
Returns
148156
-------
149157
Generator[tuple[str, Tenant | None]]
158+
150159
"""
151160
# Currently no tenant filters
152161
_ = kwargs.pop("filters", None)
153162
return super().get(
154-
count=count, offset=offset, server_url=server_url, server_token=server_token
163+
count=count,
164+
offset=offset,
165+
server_url=server_url,
166+
server_token=server_token,
155167
)
156168

157169
@property
158170
def name(self) -> str:
159-
"""Retrieve the name of the tenant"""
171+
"""Retrieve the name of the tenant."""
160172
return self._get_attribute("name")
161173

162174
@name.setter
163175
@write_only
164176
@pydantic.validate_call
165177
def name(self, name: str) -> None:
166-
"""Change name of tenant"""
178+
"""Change name of tenant."""
167179
self._staging["name"] = name
168180

169181
@property
170182
@staging_check
171183
def is_enabled(self) -> bool:
172-
"""Retrieve if tenant is enabled"""
184+
"""Retrieve if tenant is enabled."""
173185
return self._get_attribute("is_enabled")
174186

175187
@is_enabled.setter
176188
@write_only
177189
@pydantic.validate_call
178190
def is_enabled(self, is_enabled: bool) -> None:
179-
"""Enable/disable tenant"""
191+
"""Enable/disable tenant."""
180192
self._staging["is_enabled"] = is_enabled
181193

182194
@property
183195
@staging_check
184196
def max_request_rate(self) -> int:
185-
"""Retrieve the tenant's maximum request rate"""
197+
"""Retrieve the tenant's maximum request rate."""
186198
return self._get_attribute("max_request_rate")
187199

188200
@max_request_rate.setter
189201
@write_only
190202
@pydantic.validate_call
191203
def max_request_rate(self, max_request_rate: int) -> None:
192-
"""Update tenant's maximum request rate"""
204+
"""Update tenant's maximum request rate."""
193205
self._staging["max_request_rate"] = max_request_rate
194206

195207
@property
196208
@staging_check
197209
def max_runs(self) -> int:
198-
"""Retrieve the tenant's maximum runs"""
210+
"""Retrieve the tenant's maximum runs."""
199211
return self._get_attribute("max_runs")
200212

201213
@max_runs.setter
202214
@write_only
203215
@pydantic.validate_call
204216
def max_runs(self, max_runs: int) -> None:
205-
"""Update tenant's maximum runs"""
217+
"""Update tenant's maximum runs."""
206218
self._staging["max_runs"] = max_runs
207219

208220
@property
209221
@staging_check
210222
def max_data_volume(self) -> int:
211-
"""Retrieve the tenant's maximum data volume"""
223+
"""Retrieve the tenant's maximum data volume."""
212224
return self._get_attribute("max_data_volume")
213225

214226
@max_data_volume.setter
215227
@write_only
216228
@pydantic.validate_call
217229
def max_data_volume(self, max_data_volume: int) -> None:
218-
"""Update tenant's maximum data volume"""
230+
"""Update tenant's maximum data volume."""
219231
self._staging["max_data_volume"] = max_data_volume
220232

221233
@property
222234
def created(self) -> datetime.datetime | None:
223-
"""Set/retrieve created datetime for the run.
235+
"""Set/retrieve created datetime in UTC for the run.
224236
225237
Returns
226238
-------
227239
datetime.datetime
240+
228241
"""
229242
_created: str | None = self._get_attribute("created")
230243
return (
231-
datetime.datetime.strptime(_created, DATETIME_FORMAT) if _created else None
244+
datetime.datetime.strptime(_created, DATETIME_FORMAT).astimezone(
245+
datetime.UTC,
246+
)
247+
if _created
248+
else None
232249
)

0 commit comments

Comments
 (0)