Skip to content

Commit fbe13ff

Browse files
committed
Validate metadata types
1 parent e44caaa commit fbe13ff

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

alchemiscale/interface/client.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,21 +1801,42 @@ def get_network_archives(
18011801

18021802
return archives
18031803

1804-
def get_network_archive(self, network: ScopedKey) -> AlchemicalArchive | None:
1804+
def get_network_archive(self, network: ScopedKey, metadata: dict | None = None) -> AlchemicalArchive | None:
18051805
"""Get the archive for a given ``AlchemicalNetwork``.
18061806
18071807
Parameters
18081808
----------
18091809
network
18101810
The ``AlchemicalNetwork`` to archive.
1811+
metadata
1812+
Metadata to attach to the ``AlchemicalArchive``. This must
1813+
be a dictionary that is compatible with
1814+
``GufeTokenizable`` serialization.
18111815
18121816
Returns
18131817
-------
18141818
An ``AlchemicalArchive`` for the provided
18151819
``AlchemicalNetwork``. If the ntwork was not found, ``None``
18161820
is returned.
1821+
1822+
Raises
1823+
------
1824+
A ``ValueError`` is raised if the provided metadata is not
1825+
serializable.
18171826
"""
1818-
return self.get_network_archives([network])[0]
1827+
match metadata:
1828+
case dict():
1829+
print("found dict")
1830+
if metadata:
1831+
metadata = [metadata]
1832+
else:
1833+
metadata = None
1834+
case None:
1835+
pass
1836+
case _:
1837+
raise ValueError("metadata must be a dictionary or None")
1838+
1839+
return self.get_network_archives([network], metadata)[0]
18191840

18201841
def get_transformation_results(
18211842
self,

0 commit comments

Comments
 (0)