digitalhub-runtime-python 0.16.0b4__py3-none-any.whl → 0.16.0b6__py3-none-any.whl

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.
@@ -193,7 +193,7 @@ def _check_config_params(
193
193
  if path is not None:
194
194
  config["path"] = path
195
195
 
196
- if config_src is None and config_content is None and config_base64 is None:
196
+ if config_src is None and config_content is None and config_base64 is None and path is None:
197
197
  raise EntityError("Config must be provided.")
198
198
 
199
199
  if config_src is not None:
@@ -19,6 +19,8 @@ from digitalhub_runtime_python.utils.configuration import (
19
19
  has_git_scheme,
20
20
  has_remote_scheme,
21
21
  has_s3_scheme,
22
+ import_function_from_source,
23
+ save_function_source,
22
24
  )
23
25
  from digitalhub_runtime_python.utils.outputs import build_new_status, collect_outputs
24
26
 
@@ -70,6 +72,9 @@ class RuntimeHydraJob(RuntimePythonJob):
70
72
  def _configure_execution(self, spec: dict, run: dict) -> tuple[Callable, bool]:
71
73
  args = ["main", "-m"]
72
74
 
75
+ # prepare source code
76
+ source_path = save_function_source(self.runtime_dir, spec.get("source", {}))
77
+
73
78
  # write runtime config for dh launcher
74
79
  dh_launcher_config = {
75
80
  "defaults": ["dh"],
@@ -111,6 +116,8 @@ class RuntimeHydraJob(RuntimePythonJob):
111
116
  # Unsupported scheme
112
117
  else:
113
118
  raise RuntimeError(f"Unable to collect source from: {source}")
119
+ if "path" in config:
120
+ path = path / config["path"]
114
121
  sys.argv = args + [f"--config-path={path.absolute()}"]
115
122
  elif "path" in config:
116
123
  path = self.runtime_dir / config["path"]
@@ -122,7 +129,16 @@ class RuntimeHydraJob(RuntimePythonJob):
122
129
  f"hydra.launcher.job_ref={run['id']}",
123
130
  ]
124
131
 
125
- fnc, _ = super()._configure_execution(spec)
132
+ if "parameters" in spec:
133
+ sys.argv += [f"{key}={value}" for key, value in spec["parameters"].items()]
134
+
135
+
136
+ # import from source
137
+ fnc = import_function_from_source(
138
+ source_path,
139
+ spec.get("source", {}),
140
+ skip_save=True,
141
+ )
126
142
  # treat as not wrapped, as the wrapping is done by hydra.main and we do not need to pass the extra attributes
127
143
  return fnc, {"cfg_passthrough": None}
128
144
 
@@ -133,6 +149,9 @@ class RuntimeHydraSubtask(RuntimePythonJob):
133
149
  """
134
150
 
135
151
  def _configure_execution(self, spec: dict) -> tuple[Callable, bool]:
152
+ from hydra.core.utils import setup_globals
153
+ setup_globals()
154
+
136
155
  source_spec = spec.get("source", {})
137
156
  path = self.runtime_dir
138
157
 
@@ -210,7 +210,7 @@ def _import_function_from_path(function_path: Path, function_name: str) -> Calla
210
210
  return import_function(function_path, function_name)
211
211
 
212
212
 
213
- def import_function_from_source(path: Path, source_spec: dict) -> Callable:
213
+ def import_function_from_source(path: Path, source_spec: dict, skip_save: bool = False) -> Callable:
214
214
  """
215
215
  Get function from source.
216
216
 
@@ -227,7 +227,7 @@ def import_function_from_source(path: Path, source_spec: dict) -> Callable:
227
227
  Function.
228
228
  """
229
229
  try:
230
- source_path = save_function_source(path, source_spec)
230
+ source_path = save_function_source(path, source_spec) if not skip_save else path
231
231
  function_path, function_name = _get_function_path(source_path, source_spec["handler"])
232
232
  return _import_function_from_path(function_path, function_name)
233
233
  except Exception as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: digitalhub-runtime-python
3
- Version: 0.16.0b4
3
+ Version: 0.16.0b6
4
4
  Summary: Python runtime for DHCore
5
5
  Project-URL: Homepage, https://github.com/scc-digitalhub/digitalhub-sdk-runtime-python
6
6
  Author-email: Fondazione Bruno Kessler <digitalhub@fbk.eu>, Matteo Martini <mmartini@fbk.eu>
@@ -31,7 +31,7 @@ digitalhub_runtime_python/entities/function/hydra/entity.py,sha256=U1h2H8UVDPskp
31
31
  digitalhub_runtime_python/entities/function/hydra/models.py,sha256=DXQa9DTnHw_YAos2lfcNPFL2LpeWy0VAqa5s7joWflI,1155
32
32
  digitalhub_runtime_python/entities/function/hydra/spec.py,sha256=n0meR5mUz6dIzpoa76Zfm6ezKxUHeOKezOXjpd0qlLU,1630
33
33
  digitalhub_runtime_python/entities/function/hydra/status.py,sha256=O26R7uqJLRZ_UHrnTgiS7hsmdfHOho1szNrK9lITSEI,306
34
- digitalhub_runtime_python/entities/function/hydra/utils.py,sha256=wd8Hx_rQzoYjMXuSyJKbX3D5JqXci1OUcTafu030g7I,5570
34
+ digitalhub_runtime_python/entities/function/hydra/utils.py,sha256=-cLXGoqJ2G4T1awSLjBpZ-k21dto8spFOZdWJhNZ2WA,5587
35
35
  digitalhub_runtime_python/entities/function/openinference/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
36
36
  digitalhub_runtime_python/entities/function/openinference/builder.py,sha256=jYGi-Qol5Vreyubd_MGB3hG83Hfv75sVJt2evHTtKeo,1177
37
37
  digitalhub_runtime_python/entities/function/openinference/entity.py,sha256=43KLWGd-x9Vq7oTeiqXISmelWcBXoLGA_a8TYgwUu7Q,778
@@ -153,14 +153,14 @@ digitalhub_runtime_python/entities/task/python_serve/spec.py,sha256=VDkEvgoxYv5O
153
153
  digitalhub_runtime_python/entities/task/python_serve/status.py,sha256=OqKVBAhiQDXJb_qogxV8qqh6eyPjudT4puXx8bg_6XU,298
154
154
  digitalhub_runtime_python/runtimes/__init__.py,sha256=IRY2i9U97wptE3OcC_NO-EBmcAH6-Q36gMCspKetQ0k,107
155
155
  digitalhub_runtime_python/runtimes/builder.py,sha256=vfSyxh5iEkSmTngTWM2BMpcnyvtAagBJpbN0M7ICjKw,1370
156
- digitalhub_runtime_python/runtimes/hydra_runtime.py,sha256=9qnXdmUzX_uP-_qfZzZJilYChPlUivzO6LLQoGVR65c,5831
156
+ digitalhub_runtime_python/runtimes/hydra_runtime.py,sha256=kU55HLaktyb2XnoltIKY2A6BooCTRJHvhKFs2TYuB8k,6411
157
157
  digitalhub_runtime_python/runtimes/runtime.py,sha256=kJgDfXk_UbXXryRw7LNAIETJJH5nB7IwjnJgYVBrBRI,3965
158
- digitalhub_runtime_python/utils/configuration.py,sha256=BhrHFsvlCcAHA1hfmx7b5lURKeMV9TuC1dtMKXpcHOM,9125
158
+ digitalhub_runtime_python/utils/configuration.py,sha256=1GyCOtl-mQ4lgv6UplpaB-wj1E-VoWChAC_G6HbYXzE,9177
159
159
  digitalhub_runtime_python/utils/inputs.py,sha256=c-dU61jHXrTd-5XJt4LacjfDzi_vWZFKwuJCbqAGdJQ,5806
160
160
  digitalhub_runtime_python/utils/outputs.py,sha256=irGUqy43F26NC1_ruH831NDyDTIVQHwIf15oXpR-q2M,9571
161
161
  digitalhub_runtime_python/utils/utils.py,sha256=qO-wh-9qJFvoJnWIWNeajtFQuBSYw3xhCI3JqV9gVHE,1936
162
- digitalhub_runtime_python-0.16.0b4.dist-info/METADATA,sha256=s85f6B7jhPyIX6-3XzNAtO18CWnWIoWjvoAVAhbj2qs,17080
163
- digitalhub_runtime_python-0.16.0b4.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
164
- digitalhub_runtime_python-0.16.0b4.dist-info/licenses/AUTHORS,sha256=iDleK_2EAMmh0o8Te_E9mdXQCP4rBfFr9dW9d0-pCno,301
165
- digitalhub_runtime_python-0.16.0b4.dist-info/licenses/LICENSE,sha256=z3xQCHfGmTnigfoUe3uidW_GUSVeFBdos30w9VNTRec,11361
166
- digitalhub_runtime_python-0.16.0b4.dist-info/RECORD,,
162
+ digitalhub_runtime_python-0.16.0b6.dist-info/METADATA,sha256=-OVuO1MBrEUSCRR_dBCNc_an_VsUjJ8DCLUySqvX5q8,17080
163
+ digitalhub_runtime_python-0.16.0b6.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
164
+ digitalhub_runtime_python-0.16.0b6.dist-info/licenses/AUTHORS,sha256=iDleK_2EAMmh0o8Te_E9mdXQCP4rBfFr9dW9d0-pCno,301
165
+ digitalhub_runtime_python-0.16.0b6.dist-info/licenses/LICENSE,sha256=z3xQCHfGmTnigfoUe3uidW_GUSVeFBdos30w9VNTRec,11361
166
+ digitalhub_runtime_python-0.16.0b6.dist-info/RECORD,,