madsci.node_module 0.2.0__tar.gz → 0.3.0__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.
- {madsci_node_module-0.2.0 → madsci_node_module-0.3.0}/PKG-INFO +1 -1
- {madsci_node_module-0.2.0 → madsci_node_module-0.3.0}/madsci/node_module/abstract_node_module.py +11 -8
- {madsci_node_module-0.2.0 → madsci_node_module-0.3.0}/madsci/node_module/helpers.py +3 -2
- {madsci_node_module-0.2.0 → madsci_node_module-0.3.0}/madsci/node_module/rest_node_module.py +1 -1
- {madsci_node_module-0.2.0 → madsci_node_module-0.3.0}/pyproject.toml +1 -1
- {madsci_node_module-0.2.0 → madsci_node_module-0.3.0}/tests/test_rest_node_module.py +1 -0
- {madsci_node_module-0.2.0 → madsci_node_module-0.3.0}/README.md +0 -0
- {madsci_node_module-0.2.0 → madsci_node_module-0.3.0}/madsci/node_module/__init__.py +0 -0
- {madsci_node_module-0.2.0 → madsci_node_module-0.3.0}/tests/test_node.py +0 -0
- {madsci_node_module-0.2.0 → madsci_node_module-0.3.0}/tests/test_rest_node_client.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: madsci.node_module
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: The Modular Autonomous Discovery for Science (MADSci) Node Module Helper Classes.
|
|
5
5
|
Author-Email: Tobias Ginsburg <tginsburg@anl.gov>, "Ryan D. Lewis" <ryan.lewis@anl.gov>, Casey Stone <cstone@anl.gov>, Doga Ozgulbas <dozgulbas@anl.gov>
|
|
6
6
|
License: MIT
|
{madsci_node_module-0.2.0 → madsci_node_module-0.3.0}/madsci/node_module/abstract_node_module.py
RENAMED
|
@@ -42,6 +42,7 @@ from madsci.common.types.location_types import (
|
|
|
42
42
|
)
|
|
43
43
|
from madsci.common.types.node_types import (
|
|
44
44
|
AdminCommands,
|
|
45
|
+
NodeCapabilities,
|
|
45
46
|
NodeClientCapabilities,
|
|
46
47
|
NodeConfig,
|
|
47
48
|
NodeDefinition,
|
|
@@ -128,14 +129,14 @@ class AbstractNode:
|
|
|
128
129
|
"The module version in the Node Module's source code does not match the version specified in your Node Definition. Your module may have been updated. We recommend checking to ensure compatibility, and then updating the version in your node definition to match."
|
|
129
130
|
)
|
|
130
131
|
|
|
131
|
-
# * Combine the node definition and classes's capabilities
|
|
132
|
-
self._populate_capabilities()
|
|
133
|
-
|
|
134
132
|
# * Synthesize the node info
|
|
135
133
|
self.node_info = NodeInfo.from_node_def_and_config(
|
|
136
134
|
self.node_definition, self.config
|
|
137
135
|
)
|
|
138
136
|
|
|
137
|
+
# * Combine the node definition and classes's capabilities
|
|
138
|
+
self._populate_capabilities()
|
|
139
|
+
|
|
139
140
|
# * Add the action decorators to the node (and node info)
|
|
140
141
|
for action_callable in self.__class__.__dict__.values():
|
|
141
142
|
if hasattr(action_callable, "__is_madsci_action__"):
|
|
@@ -462,7 +463,7 @@ class AbstractNode:
|
|
|
462
463
|
f"Adding parameter {parameter_name} of type {parameter_type} to action {action_name}",
|
|
463
464
|
)
|
|
464
465
|
if parameter_name == "return":
|
|
465
|
-
#
|
|
466
|
+
# TODO: Extract the return type and add it to the action definition
|
|
466
467
|
continue
|
|
467
468
|
if (
|
|
468
469
|
parameter_name not in action_def.args
|
|
@@ -709,17 +710,19 @@ class AbstractNode:
|
|
|
709
710
|
|
|
710
711
|
def _populate_capabilities(self) -> None:
|
|
711
712
|
"""Populate the node capabilities based on the node definition and the supported capabilities of the class."""
|
|
713
|
+
if self.node_info.capabilities is None:
|
|
714
|
+
self.node_info.capabilities = NodeCapabilities()
|
|
712
715
|
for field in self.supported_capabilities.__pydantic_fields__:
|
|
713
|
-
if getattr(self.
|
|
716
|
+
if getattr(self.node_info.capabilities, field) is None:
|
|
714
717
|
setattr(
|
|
715
|
-
self.
|
|
718
|
+
self.node_info.capabilities,
|
|
716
719
|
field,
|
|
717
720
|
getattr(self.supported_capabilities, field),
|
|
718
721
|
)
|
|
719
722
|
|
|
720
723
|
# * Add the admin commands to the node info
|
|
721
|
-
self.
|
|
722
|
-
self.
|
|
724
|
+
self.node_info.capabilities.admin_commands = set.union(
|
|
725
|
+
self.node_info.capabilities.admin_commands,
|
|
723
726
|
{
|
|
724
727
|
admin_command.value
|
|
725
728
|
for admin_command in AdminCommands
|
|
@@ -65,6 +65,7 @@ def action_response_to_headers(action_response: ActionResult) -> dict[str, str]:
|
|
|
65
65
|
"x-madsci-datapoints": json.dumps(action_response.datapoints),
|
|
66
66
|
"x-madsci-errors": json.dumps(action_response.errors),
|
|
67
67
|
"x-madsci-files": json.dumps(action_response.files),
|
|
68
|
+
"x-madsci-data": json.dumps(action_response.data),
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
|
|
@@ -84,7 +85,7 @@ class ActionResultWithFiles(FileResponse):
|
|
|
84
85
|
suffix=".zip",
|
|
85
86
|
delete=False,
|
|
86
87
|
) as temp_zipfile_path:
|
|
87
|
-
temp_zip = ZipFile(temp_zipfile_path, "w")
|
|
88
|
+
temp_zip = ZipFile(temp_zipfile_path.name, "w")
|
|
88
89
|
for file in action_response.files:
|
|
89
90
|
temp_zip.write(
|
|
90
91
|
action_response.files[file],
|
|
@@ -95,6 +96,6 @@ class ActionResultWithFiles(FileResponse):
|
|
|
95
96
|
)
|
|
96
97
|
|
|
97
98
|
return ActionResultWithFiles(
|
|
98
|
-
path=temp_zipfile_path,
|
|
99
|
+
path=temp_zipfile_path.name,
|
|
99
100
|
headers=action_response_to_headers(action_response),
|
|
100
101
|
)
|
|
@@ -332,6 +332,7 @@ def test_get_action_result(test_client: TestClient) -> None:
|
|
|
332
332
|
result = ActionResult.model_validate(response.json())
|
|
333
333
|
assert result.status in [ActionStatus.RUNNING, ActionStatus.SUCCEEDED]
|
|
334
334
|
|
|
335
|
+
time.sleep(0.1)
|
|
335
336
|
response = client.get(f"/action/{result.action_id}")
|
|
336
337
|
assert response.status_code == 200
|
|
337
338
|
fetched_result = ActionResult.model_validate(response.json())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|