Skip to content

Commit 71f1144

Browse files
committed
Merge remote-tracking branch 'origin/main' into autoscaling
2 parents 4da3546 + 92389ac commit 71f1144

14 files changed

Lines changed: 50 additions & 38 deletions

File tree

alchemiscale/compute/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def retrieve_task_transformation(
327327

328328
if protocoldagresultref_sk:
329329
protocoldagresultref = n4js.get_gufe(protocoldagresultref_sk)
330-
pdr_sk = ScopedKey(gufe_key=protocoldagresultref.obj_key, **sk.scope.dict())
330+
pdr_sk = ScopedKey(gufe_key=protocoldagresultref.obj_key, **sk.scope.to_dict())
331331

332332
# we keep this as a string to avoid useless deserialization/reserialization here
333333
try:

alchemiscale/compute/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def query_taskhubs(
7272
taskhubs = []
7373

7474
for scope in scopes:
75-
params = dict(return_gufe=return_gufe, **scope.dict())
75+
params = dict(return_gufe=return_gufe, **scope.to_dict())
7676
if return_gufe:
7777
taskhubs.update(self._query_resource("/taskhubs", params=params))
7878
else:
@@ -104,7 +104,7 @@ def claim_tasks(
104104
):
105105
"""Claim Tasks from TaskHubs within a list of Scopes."""
106106
data = dict(
107-
scopes=[scope.dict() for scope in scopes],
107+
scopes=[scope.to_dict() for scope in scopes],
108108
compute_service_id=str(compute_service_id),
109109
count=count,
110110
protocols=protocols,

alchemiscale/interface/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ def get_protocoldagresult(
11361136
detail=str(e),
11371137
)
11381138

1139-
pdr_sk = ScopedKey(gufe_key=protocoldagresultref.obj_key, **sk.scope.dict())
1139+
pdr_sk = ScopedKey(gufe_key=protocoldagresultref.obj_key, **sk.scope.to_dict())
11401140

11411141
# we leave each ProtocolDAGResult in string form to avoid
11421142
# deserializing/reserializing here; just passing through to client

alchemiscale/interface/client.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def get_scoped_key(self, obj: GufeTokenizable, scope: Scope) -> ScopedKey:
8484
)
8585

8686
if scope.specific():
87-
return ScopedKey(gufe_key=obj.key, **scope.dict())
87+
return ScopedKey(gufe_key=obj.key, **scope.to_dict())
8888
else:
8989
raise ValueError(
9090
"Scope for a ScopedKey must be specific; it cannot contain wildcards."
@@ -143,11 +143,11 @@ def create_network(
143143

144144
state = NetworkStateEnum(state)
145145

146-
sk = ScopedKey(gufe_key=network.key, **scope.dict())
146+
sk = ScopedKey(gufe_key=network.key, **scope.to_dict())
147147

148148
def post():
149149
keyed_chain = KeyedChain.gufe_to_keyed_chain_rep(network)
150-
data = dict(network=keyed_chain, scope=scope.dict(), state=state.value)
150+
data = dict(network=keyed_chain, scope=scope.to_dict(), state=state.value)
151151
return self._post_resource("/networks", data, compress=compress)
152152

153153
if visualize:
@@ -286,7 +286,7 @@ def query_networks(
286286
if isinstance(state, NetworkStateEnum):
287287
state = state.value
288288

289-
params = dict(name=name, **scope.dict(), state=state)
289+
params = dict(name=name, **scope.to_dict(), state=state)
290290

291291
return self._query_resource("/networks", params=params)
292292

@@ -304,7 +304,7 @@ def query_transformations(
304304
if scope is None:
305305
scope = Scope()
306306

307-
params = dict(name=name, **scope.dict())
307+
params = dict(name=name, **scope.to_dict())
308308

309309
return self._query_resource("/transformations", params=params)
310310

@@ -322,7 +322,7 @@ def query_chemicalsystems(
322322
if scope is None:
323323
scope = Scope()
324324

325-
params = dict(name=name, **scope.dict())
325+
params = dict(name=name, **scope.to_dict())
326326

327327
return self._query_resource("/chemicalsystems", params=params)
328328

@@ -723,7 +723,7 @@ def create_tasks(
723723
724724
"""
725725
if extends:
726-
extends = extends.dict()
726+
extends = extends.to_dict()
727727

728728
data = dict(extends=extends, count=count)
729729
task_sks = self._post_resource(f"/transformations/{transformation}/tasks", data)
@@ -801,7 +801,7 @@ def query_tasks(
801801
if scope is None:
802802
scope = Scope()
803803

804-
params = dict(status=status, **scope.dict())
804+
params = dict(status=status, **scope.to_dict())
805805

806806
return self._query_resource("/tasks", params=params)
807807

@@ -1139,7 +1139,7 @@ def action_tasks(
11391139
will be returned in its place.
11401140
11411141
"""
1142-
data = dict(tasks=[t.dict() for t in tasks], weight=weight)
1142+
data = dict(tasks=[t.to_dict() for t in tasks], weight=weight)
11431143
actioned_sks = self._post_resource(f"/networks/{network}/tasks/action", data)
11441144

11451145
return [ScopedKey.from_str(i) if i is not None else None for i in actioned_sks]
@@ -1169,7 +1169,7 @@ def cancel_tasks(
11691169
be returned in its place.
11701170
11711171
"""
1172-
data = dict(tasks=[t.dict() for t in tasks])
1172+
data = dict(tasks=[t.to_dict() for t in tasks])
11731173
canceled_sks = self._post_resource(f"/networks/{network}/tasks/cancel", data)
11741174

11751175
return [ScopedKey.from_str(i) if i is not None else None for i in canceled_sks]
@@ -1246,7 +1246,7 @@ async def _set_task_status(
12461246
self, tasks: list[ScopedKey], status: TaskStatusEnum
12471247
) -> list[ScopedKey | None]:
12481248
"""Set the statuses for many Tasks"""
1249-
data = dict(tasks=[t.dict() for t in tasks], status=status.value)
1249+
data = dict(tasks=[t.to_dict() for t in tasks], status=status.value)
12501250
tasks_updated = await self._post_resource_async(
12511251
"/bulk/tasks/status/set", data=data
12521252
)
@@ -1290,7 +1290,7 @@ def set_tasks_status(
12901290

12911291
async def _get_task_status(self, tasks: list[ScopedKey]) -> list[TaskStatusEnum]:
12921292
"""Get the statuses for many Tasks"""
1293-
data = dict(tasks=[t.dict() for t in tasks])
1293+
data = dict(tasks=[t.to_dict() for t in tasks])
12941294
statuses = await self._post_resource_async("/bulk/tasks/status/get", data=data)
12951295
return statuses
12961296

@@ -1319,7 +1319,7 @@ def get_tasks_status(
13191319
async def _set_task_priority(
13201320
self, tasks: list[ScopedKey], priority: int
13211321
) -> list[ScopedKey | None]:
1322-
data = dict(tasks=[t.dict() for t in tasks], priority=priority)
1322+
data = dict(tasks=[t.to_dict() for t in tasks], priority=priority)
13231323
tasks_updated = await self._post_resource_async(
13241324
"/bulk/tasks/priority/set", data=data
13251325
)
@@ -1360,7 +1360,7 @@ def set_tasks_priority(
13601360

13611361
async def _get_task_priority(self, tasks: list[ScopedKey]) -> list[int]:
13621362
"""Get the priority for many Tasks"""
1363-
data = dict(tasks=[t.dict() for t in tasks])
1363+
data = dict(tasks=[t.to_dict() for t in tasks])
13641364
priorities = await self._post_resource_async(
13651365
"/bulk/tasks/priority/get", data=data
13661366
)

alchemiscale/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ def specific(self) -> bool:
120120
"""Return `True` if this Scope has no unspecified elements."""
121121
return all(self.to_tuple())
122122

123+
def to_dict(self) -> dict:
124+
return self.model_dump()
125+
123126

124127
class InvalidGufeKeyError(ValueError): ...
125128

@@ -208,7 +211,7 @@ def qualname(self):
208211
return self.gufe_key.split("-")[0]
209212

210213
def to_dict(self):
211-
return self.dict()
214+
return self.model_dump()
212215

213216
@classmethod
214217
def from_dict(cls, d):

alchemiscale/security/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class CredentialedEntity(BaseModel):
2525
hashed_key: str
2626
expires: datetime.datetime | None = None
2727

28+
def to_dict(self):
29+
return self.model_dump()
30+
2831

2932
class ScopedIdentity(BaseModel):
3033
identifier: str

alchemiscale/storage/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def from_now(cls, identifier: ComputeServiceID):
4646
)
4747

4848
def to_dict(self):
49-
dct = self.dict()
49+
dct = self.model_dump()
5050
dct["identifier"] = str(self.identifier)
5151

5252
return dct

alchemiscale/storage/statestore.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ def process_keyed_dict(gufe_key, kd):
362362
node[key] = value
363363

364364
node["_gufe_key"] = str(gufe_key)
365-
node["_scoped_key"] = str(ScopedKey(gufe_key=str(gufe_key), **scope.dict()))
365+
node["_scoped_key"] = str(
366+
ScopedKey(gufe_key=str(gufe_key), **scope.to_dict())
367+
)
366368
node.update(
367369
{
368370
"_org": scope.org,
@@ -379,7 +381,7 @@ def process_keyed_dict(gufe_key, kd):
379381
add_previous_node(gufe_key, node)
380382

381383
subgraph = Subgraph(None, relationships)
382-
scoped_key = ScopedKey(gufe_key=node["_gufe_key"], **scope.dict())
384+
scoped_key = ScopedKey(gufe_key=node["_gufe_key"], **scope.to_dict())
383385
return subgraph, node, scoped_key
384386

385387
def _subgraph_to_gufe(
@@ -3848,7 +3850,7 @@ def create_credentialed_entity(self, entity: CredentialedEntity):
38483850
then this will overwrite its properties, including credential.
38493851
38503852
"""
3851-
node = Node("CredentialedEntity", entity.__class__.__name__, **entity.dict())
3853+
node = Node("CredentialedEntity", entity.__class__.__name__, **entity.to_dict())
38523854

38533855
with self.transaction() as tx:
38543856
merge_subgraph(

alchemiscale/tests/integration/compute/client/test_compute_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def test_get_task_transformation(
237237
# register compute service id
238238
compute_client.register(compute_service_id)
239239

240-
an_sk = ScopedKey(gufe_key=network_tyk2.key, **scope_test.dict())
240+
an_sk = ScopedKey(gufe_key=network_tyk2.key, **scope_test.to_dict())
241241

242242
taskhub_sk = n4js_preloaded.get_taskhub(an_sk)
243243

@@ -271,8 +271,8 @@ def test_set_task_result(
271271
# register compute service id
272272
compute_client.register(compute_service_id)
273273

274-
an_sk = ScopedKey(gufe_key=network_tyk2.key, **scope_test.dict())
275-
tf_sk = ScopedKey(gufe_key=transformation.key, **scope_test.dict())
274+
an_sk = ScopedKey(gufe_key=network_tyk2.key, **scope_test.to_dict())
275+
tf_sk = ScopedKey(gufe_key=transformation.key, **scope_test.to_dict())
276276
taskhub_sk = n4js_preloaded.get_taskhub(an_sk)
277277

278278
# claim our first task
@@ -322,8 +322,8 @@ def test_set_task_result_legacy(
322322
# register compute service id
323323
compute_client.register(compute_service_id)
324324

325-
an_sk = ScopedKey(gufe_key=network_tyk2.key, **scope_test.dict())
326-
tf_sk = ScopedKey(gufe_key=transformation.key, **scope_test.dict())
325+
an_sk = ScopedKey(gufe_key=network_tyk2.key, **scope_test.to_dict())
326+
tf_sk = ScopedKey(gufe_key=transformation.key, **scope_test.to_dict())
327327
taskhub_sk = n4js_preloaded.get_taskhub(an_sk)
328328

329329
# claim our first task
@@ -424,7 +424,7 @@ def test_set_task_result_failure(
424424
# register compute service id
425425
compute_client.register(compute_service_id)
426426

427-
tf_sk = ScopedKey(gufe_key=transformation_failure.key, **scope_test.dict())
427+
tf_sk = ScopedKey(gufe_key=transformation_failure.key, **scope_test.to_dict())
428428

429429
# add a network with a transformation that will always fail
430430
an_sk, taskhub_sk, _ = n4js_preloaded.assemble_network(

alchemiscale/tests/integration/interface/client/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def test_check_exists(
212212

213213
# check that an AlchemicalNetwork that doesn't exist shows as not existing
214214
an_sk_nonexistent = ScopedKey(
215-
gufe_key=GufeKey("AlchemicalNetwork-lol"), **scope_test.dict()
215+
gufe_key=GufeKey("AlchemicalNetwork-lol"), **scope_test.to_dict()
216216
)
217217
assert not user_client.check_exists(an_sk_nonexistent)
218218

0 commit comments

Comments
 (0)