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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: madsci.node_module
3
- Version: 0.2.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
@@ -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
- # * Skip the return parameter
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.node_definition.capabilities, field) is None:
716
+ if getattr(self.node_info.capabilities, field) is None:
714
717
  setattr(
715
- self.node_definition.capabilities,
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.node_definition.capabilities.admin_commands = set.union(
722
- self.node_definition.capabilities.admin_commands,
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
  )
@@ -111,7 +111,7 @@ class RestNode(AbstractNode):
111
111
 
112
112
  response = super().run_action(
113
113
  ActionRequest(
114
- action_id=action_id if action_id else new_ulid_str(),
114
+ action_id=action_id or new_ulid_str(),
115
115
  action_name=action_name,
116
116
  args=args,
117
117
  files={
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "madsci.node_module"
3
- version = "0.2.0"
3
+ version = "0.3.0"
4
4
  description = "The Modular Autonomous Discovery for Science (MADSci) Node Module Helper Classes."
5
5
  authors = [
6
6
  { name = "Tobias Ginsburg", email = "tginsburg@anl.gov" },
@@ -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())