aiida-pythonjob 0.4.3__tar.gz → 0.4.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aiida_pythonjob-0.4.3/src/aiida_pythonjob.egg-info → aiida_pythonjob-0.4.4}/PKG-INFO +1 -1
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/pyproject.toml +0 -11
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/__init__.py +1 -1
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/calculations/pythonjob.py +0 -4
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/data/serializer.py +15 -8
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/utils.py +0 -47
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4/src/aiida_pythonjob.egg-info}/PKG-INFO +1 -1
- aiida_pythonjob-0.4.4/src/aiida_pythonjob.egg-info/entry_points.txt +11 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/tests/test_entry_points.py +3 -1
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/tests/test_pyfunction.py +10 -1
- aiida_pythonjob-0.4.3/src/aiida_pythonjob.egg-info/entry_points.txt +0 -22
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/LICENSE +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/README.md +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/setup.cfg +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/calculations/__init__.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/calculations/common.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/calculations/pyfunction.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/calculations/tasks.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/calculations/utils.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/config.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/data/__init__.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/data/atoms.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/data/common_data.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/data/deserializer.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/data/jsonable_data.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/data/pickled_data.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/data/utils.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/decorator.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/launch.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/parsers/__init__.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/parsers/pythonjob.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/parsers/utils.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob.egg-info/SOURCES.txt +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob.egg-info/dependency_links.txt +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob.egg-info/requires.txt +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob.egg-info/top_level.txt +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/tests/test_async.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/tests/test_create_env.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/tests/test_data.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/tests/test_jsonable_data.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/tests/test_monitor.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/tests/test_parser.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/tests/test_pickled_data.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/tests/test_pythonjob.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/tests/test_serializer.py +0 -0
- {aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/tests/test_utils.py +0 -0
|
@@ -55,17 +55,6 @@ Source = "https://github.com/aiidateam/aiida-pythonjob"
|
|
|
55
55
|
"pythonjob.ase.atoms.Atoms" = "aiida_pythonjob.data.atoms:AtomsData"
|
|
56
56
|
"pythonjob.builtins.NoneType" = "aiida_pythonjob.data.common_data:NoneData"
|
|
57
57
|
"pythonjob.datetime.datetime" = "aiida_pythonjob.data.common_data:DateTimeData"
|
|
58
|
-
"pythonjob.builtins.int" = "aiida.orm.nodes.data.int:Int"
|
|
59
|
-
"pythonjob.builtins.float" = "aiida.orm.nodes.data.float:Float"
|
|
60
|
-
"pythonjob.builtins.str" = "aiida.orm.nodes.data.str:Str"
|
|
61
|
-
"pythonjob.builtins.bool" = "aiida.orm.nodes.data.bool:Bool"
|
|
62
|
-
"pythonjob.builtins.list" = "aiida.orm.nodes.data.list:List"
|
|
63
|
-
"pythonjob.builtins.dict" = "aiida.orm.nodes.data.dict:Dict"
|
|
64
|
-
"pythonjob.numpy.float32" = "aiida.orm.nodes.data.float:Float"
|
|
65
|
-
"pythonjob.numpy.float64" = "aiida.orm.nodes.data.float:Float"
|
|
66
|
-
"pythonjob.numpy.int64" = "aiida.orm.nodes.data.int:Int"
|
|
67
|
-
"pythonjob.numpy.bool_" = "aiida.orm.nodes.data.bool:Bool"
|
|
68
|
-
"pythonjob.numpy.ndarray" = "aiida.orm.nodes.data.array.array.ArrayData"
|
|
69
58
|
|
|
70
59
|
[project.entry-points."aiida.calculations"]
|
|
71
60
|
"pythonjob.pythonjob" = "aiida_pythonjob.calculations.pythonjob:PythonJob"
|
{aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/calculations/pythonjob.py
RENAMED
|
@@ -157,10 +157,6 @@ class PythonJob(FunctionProcessMixin, CalcJob):
|
|
|
157
157
|
if "source_code" in self.inputs.function_data:
|
|
158
158
|
self.node.base.attributes.set(self._SOURCE_CODE_KEY, self.inputs.function_data.source_code)
|
|
159
159
|
|
|
160
|
-
def on_create(self) -> None:
|
|
161
|
-
super().on_create()
|
|
162
|
-
self.node.label = self._build_process_label()
|
|
163
|
-
|
|
164
160
|
def _gather_parent_transfers(self) -> tuple[list[tuple], list[tuple]]:
|
|
165
161
|
"""Build remote/local copy lists for the optional ``parent_folder``.
|
|
166
162
|
|
|
@@ -11,6 +11,20 @@ from aiida_pythonjob.data.jsonable_data import JsonableData
|
|
|
11
11
|
|
|
12
12
|
from .utils import import_from_path
|
|
13
13
|
|
|
14
|
+
builtin_serializers = {
|
|
15
|
+
"builtins.int": "aiida.orm.nodes.data.int.Int",
|
|
16
|
+
"builtins.float": "aiida.orm.nodes.data.float.Float",
|
|
17
|
+
"builtins.str": "aiida.orm.nodes.data.str.Str",
|
|
18
|
+
"builtins.bool": "aiida.orm.nodes.data.bool.Bool",
|
|
19
|
+
"builtins.list": "aiida.orm.nodes.data.list.List",
|
|
20
|
+
"builtins.dict": "aiida.orm.nodes.data.dict.Dict",
|
|
21
|
+
"numpy.float32": "aiida.orm.nodes.data.float.Float",
|
|
22
|
+
"numpy.float64": "aiida.orm.nodes.data.float.Float",
|
|
23
|
+
"numpy.int64": "aiida.orm.nodes.data.int.Int",
|
|
24
|
+
"numpy.bool_": "aiida.orm.nodes.data.bool.Bool",
|
|
25
|
+
"numpy.ndarray": "aiida.orm.nodes.data.array.array.ArrayData",
|
|
26
|
+
}
|
|
27
|
+
|
|
14
28
|
|
|
15
29
|
def atoms_to_structure_data(structure):
|
|
16
30
|
return orm.StructureData(ase=structure)
|
|
@@ -51,7 +65,7 @@ def get_serializers() -> dict:
|
|
|
51
65
|
# import time
|
|
52
66
|
|
|
53
67
|
# ts = time.time()
|
|
54
|
-
all_serializers =
|
|
68
|
+
all_serializers = builtin_serializers.copy()
|
|
55
69
|
custom_serializers = config.get("serializers", {})
|
|
56
70
|
eps = get_serializers_from_entry_points()
|
|
57
71
|
# check if there are duplicates
|
|
@@ -85,13 +99,6 @@ def serialize_to_aiida_nodes(inputs: dict, serializers: dict | None = None) -> d
|
|
|
85
99
|
return new_inputs
|
|
86
100
|
|
|
87
101
|
|
|
88
|
-
def clean_dict_key(data):
|
|
89
|
-
"""Replace "." with "__dot__" in the keys of a dictionary."""
|
|
90
|
-
if isinstance(data, dict):
|
|
91
|
-
return {k.replace(".", "__dot__"): clean_dict_key(v) for k, v in data.items()}
|
|
92
|
-
return data
|
|
93
|
-
|
|
94
|
-
|
|
95
102
|
def general_serializer(
|
|
96
103
|
data: Any,
|
|
97
104
|
serializers: dict | None = None,
|
|
@@ -18,7 +18,6 @@ from aiida.common.exceptions import NotExistent
|
|
|
18
18
|
from aiida.orm import Computer, InstalledCode, Str, User, load_code, load_computer
|
|
19
19
|
from node_graph.socket_spec import SocketSpec
|
|
20
20
|
|
|
21
|
-
from aiida_pythonjob.data.deserializer import deserialize_to_raw_python_data
|
|
22
21
|
from aiida_pythonjob.data.serializer import general_serializer
|
|
23
22
|
|
|
24
23
|
|
|
@@ -326,49 +325,3 @@ def serialize_ports(
|
|
|
326
325
|
|
|
327
326
|
# Leaf
|
|
328
327
|
return general_serializer(python_data, serializers=serializers, store=False)
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
def deserialize_ports(
|
|
332
|
-
serialized_data: Any,
|
|
333
|
-
port_schema: SocketSpec | Dict[str, Any],
|
|
334
|
-
deserializers: Optional[Dict[str, str]] = None,
|
|
335
|
-
) -> Any:
|
|
336
|
-
"""Deserialize AiiDA Data to raw Python following a SocketSpec schema.
|
|
337
|
-
|
|
338
|
-
Respects ``var_kwargs`` by accepting arbitrary keys and using ``item`` if set,
|
|
339
|
-
otherwise treating items as ANY.
|
|
340
|
-
"""
|
|
341
|
-
spec = _ensure_spec(port_schema)
|
|
342
|
-
|
|
343
|
-
# Namespace
|
|
344
|
-
if spec.is_namespace():
|
|
345
|
-
name = getattr(spec.meta, "help", None) or "<namespace>"
|
|
346
|
-
if not isinstance(serialized_data, dict):
|
|
347
|
-
raise ValueError(f"Expected dict for namespace '{name}', got {type(serialized_data)}")
|
|
348
|
-
|
|
349
|
-
out: Dict[str, Any] = {}
|
|
350
|
-
fields = spec.fields or {}
|
|
351
|
-
is_dyn = bool(spec.dynamic)
|
|
352
|
-
item_spec = spec.item if is_dyn else None
|
|
353
|
-
allow_extra = _has_var_kwargs(spec)
|
|
354
|
-
catch_schema = item_spec or SocketSpec(identifier="node_graph.any")
|
|
355
|
-
|
|
356
|
-
for key, value in serialized_data.items():
|
|
357
|
-
if key in fields:
|
|
358
|
-
child_spec = fields[key]
|
|
359
|
-
if child_spec.is_namespace():
|
|
360
|
-
out[key] = deserialize_ports(value, child_spec, deserializers=deserializers)
|
|
361
|
-
else:
|
|
362
|
-
out[key] = deserialize_to_raw_python_data(value, deserializers=deserializers)
|
|
363
|
-
elif (is_dyn and item_spec is not None) or allow_extra:
|
|
364
|
-
schema = item_spec if (is_dyn and item_spec is not None) else catch_schema
|
|
365
|
-
if schema.is_namespace():
|
|
366
|
-
out[key] = deserialize_ports(value, schema, deserializers=deserializers)
|
|
367
|
-
else:
|
|
368
|
-
out[key] = deserialize_to_raw_python_data(value, deserializers=deserializers)
|
|
369
|
-
else:
|
|
370
|
-
raise ValueError(f"Unexpected key '{key}' for namespace '{name}' (not dynamic).")
|
|
371
|
-
return out
|
|
372
|
-
|
|
373
|
-
# Leaf
|
|
374
|
-
return deserialize_to_raw_python_data(serialized_data, deserializers=deserializers)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[aiida.calculations]
|
|
2
|
+
pythonjob.pythonjob = aiida_pythonjob.calculations.pythonjob:PythonJob
|
|
3
|
+
|
|
4
|
+
[aiida.data]
|
|
5
|
+
pythonjob.ase.atoms.Atoms = aiida_pythonjob.data.atoms:AtomsData
|
|
6
|
+
pythonjob.builtins.NoneType = aiida_pythonjob.data.common_data:NoneData
|
|
7
|
+
pythonjob.datetime.datetime = aiida_pythonjob.data.common_data:DateTimeData
|
|
8
|
+
pythonjob.jsonable_data = aiida_pythonjob.data.jsonable_data:JsonableData
|
|
9
|
+
|
|
10
|
+
[aiida.parsers]
|
|
11
|
+
pythonjob.pythonjob = aiida_pythonjob.parsers.pythonjob:PythonJobParser
|
|
@@ -26,6 +26,7 @@ def create_mock_entry_points(entry_point_list):
|
|
|
26
26
|
def test_get_serializers(mock_entry_points):
|
|
27
27
|
# Mock the configuration
|
|
28
28
|
from aiida_pythonjob.config import config
|
|
29
|
+
from aiida_pythonjob.data.serializer import builtin_serializers
|
|
29
30
|
|
|
30
31
|
config["serializers"] = {}
|
|
31
32
|
# Mock entry points
|
|
@@ -47,6 +48,7 @@ def test_get_serializers(mock_entry_points):
|
|
|
47
48
|
}
|
|
48
49
|
result = get_serializers()
|
|
49
50
|
# Assert results
|
|
50
|
-
expected =
|
|
51
|
+
expected = builtin_serializers.copy()
|
|
52
|
+
expected.update({"abc.Abc": "xyz.abc.AbcData", "abc.Bcd": "xyz.abc.BcdData", "abc.Cde": "another_xyz.abc.CdeData"})
|
|
51
53
|
print("result", result)
|
|
52
54
|
assert result == expected
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
from aiida import orm
|
|
3
|
-
from aiida.engine import run_get_node
|
|
3
|
+
from aiida.engine import run_get_node, run_get_pk
|
|
4
4
|
from node_graph import socket_spec as spec
|
|
5
5
|
|
|
6
6
|
from aiida_pythonjob import PyFunction, prepare_pyfunction_inputs, pyfunction
|
|
@@ -20,6 +20,15 @@ def test_function_default_outputs(fixture_localhost):
|
|
|
20
20
|
assert node.process_label == "add"
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
def test_run_get_pk(fixture_localhost):
|
|
24
|
+
"""Test decorator."""
|
|
25
|
+
|
|
26
|
+
result, pk = run_get_pk(add, x=1, y=2)
|
|
27
|
+
|
|
28
|
+
assert result.value == 3
|
|
29
|
+
assert isinstance(pk, int)
|
|
30
|
+
|
|
31
|
+
|
|
23
32
|
def test_function_none_outputs(fixture_localhost):
|
|
24
33
|
@pyfunction()
|
|
25
34
|
def add(x, y):
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
[aiida.calculations]
|
|
2
|
-
pythonjob.pythonjob = aiida_pythonjob.calculations.pythonjob:PythonJob
|
|
3
|
-
|
|
4
|
-
[aiida.data]
|
|
5
|
-
pythonjob.ase.atoms.Atoms = aiida_pythonjob.data.atoms:AtomsData
|
|
6
|
-
pythonjob.builtins.NoneType = aiida_pythonjob.data.common_data:NoneData
|
|
7
|
-
pythonjob.builtins.bool = aiida.orm.nodes.data.bool:Bool
|
|
8
|
-
pythonjob.builtins.dict = aiida.orm.nodes.data.dict:Dict
|
|
9
|
-
pythonjob.builtins.float = aiida.orm.nodes.data.float:Float
|
|
10
|
-
pythonjob.builtins.int = aiida.orm.nodes.data.int:Int
|
|
11
|
-
pythonjob.builtins.list = aiida.orm.nodes.data.list:List
|
|
12
|
-
pythonjob.builtins.str = aiida.orm.nodes.data.str:Str
|
|
13
|
-
pythonjob.datetime.datetime = aiida_pythonjob.data.common_data:DateTimeData
|
|
14
|
-
pythonjob.jsonable_data = aiida_pythonjob.data.jsonable_data:JsonableData
|
|
15
|
-
pythonjob.numpy.bool_ = aiida.orm.nodes.data.bool:Bool
|
|
16
|
-
pythonjob.numpy.float32 = aiida.orm.nodes.data.float:Float
|
|
17
|
-
pythonjob.numpy.float64 = aiida.orm.nodes.data.float:Float
|
|
18
|
-
pythonjob.numpy.int64 = aiida.orm.nodes.data.int:Int
|
|
19
|
-
pythonjob.numpy.ndarray = aiida.orm.nodes.data.array.array.ArrayData
|
|
20
|
-
|
|
21
|
-
[aiida.parsers]
|
|
22
|
-
pythonjob.pythonjob = aiida_pythonjob.parsers.pythonjob:PythonJobParser
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/calculations/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob/calculations/pyfunction.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aiida_pythonjob-0.4.3 → aiida_pythonjob-0.4.4}/src/aiida_pythonjob.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|