digitalhub-runtime-python 0.5.0b7__tar.gz → 0.5.0b9__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.
Files changed (32) hide show
  1. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/PKG-INFO +1 -1
  2. digitalhub_runtime_python-0.5.0b9/digitalhub_runtime_python/entities/tasks/spec.py +76 -0
  3. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/runtimes/runtime.py +12 -1
  4. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/utils/configuration.py +0 -1
  5. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/utils/inputs.py +10 -14
  6. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python.egg-info/PKG-INFO +1 -1
  7. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python.egg-info/SOURCES.txt +0 -3
  8. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/pyproject.toml +2 -2
  9. digitalhub_runtime_python-0.5.0b7/digitalhub_runtime_python/entities/functions/metadata.py +0 -9
  10. digitalhub_runtime_python-0.5.0b7/digitalhub_runtime_python/entities/runs/metadata.py +0 -9
  11. digitalhub_runtime_python-0.5.0b7/digitalhub_runtime_python/entities/tasks/metadata.py +0 -15
  12. digitalhub_runtime_python-0.5.0b7/digitalhub_runtime_python/entities/tasks/spec.py +0 -103
  13. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/LICENSE.txt +0 -0
  14. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/README.md +0 -0
  15. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/__init__.py +0 -0
  16. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/__init__.py +0 -0
  17. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/functions/__init__.py +0 -0
  18. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/functions/spec.py +0 -0
  19. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/functions/status.py +0 -0
  20. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/runs/__init__.py +0 -0
  21. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/runs/spec.py +0 -0
  22. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/runs/status.py +0 -0
  23. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/tasks/__init__.py +0 -0
  24. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/tasks/models.py +0 -0
  25. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/tasks/status.py +0 -0
  26. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/runtimes/__init__.py +0 -0
  27. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/utils/outputs.py +0 -0
  28. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/utils/utils.py +0 -0
  29. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python.egg-info/dependency_links.txt +0 -0
  30. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python.egg-info/requires.txt +0 -0
  31. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python.egg-info/top_level.txt +0 -0
  32. {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: digitalhub-runtime-python
3
- Version: 0.5.0b7
3
+ Version: 0.5.0b9
4
4
  Summary: Python runtime for DHCore
5
5
  Author-email: Fondazione Bruno Kessler <dslab@fbk.eu>, Matteo Martini <mmartini@fbk.eu>
6
6
  License: Apache License
@@ -0,0 +1,76 @@
1
+ """
2
+ Task Python specification module.
3
+ """
4
+ from __future__ import annotations
5
+
6
+ from digitalhub_core.entities.tasks.spec import TaskParamsK8s, TaskSpecK8s
7
+ from digitalhub_runtime_python.entities.tasks.models import ContextRef, ContextSource
8
+
9
+
10
+ class TaskSpecJob(TaskSpecK8s):
11
+ """Task Job specification."""
12
+
13
+ def __init__(
14
+ self,
15
+ function: str,
16
+ **kwargs,
17
+ ) -> None:
18
+ """
19
+ Constructor.
20
+ """
21
+ super().__init__(function, **kwargs)
22
+
23
+ self.backoff_limit = kwargs.get("backoff_limit")
24
+ self.schedule = kwargs.get("schedule")
25
+
26
+
27
+ class TaskParamsJob(TaskParamsK8s):
28
+ """
29
+ TaskParamsJob model.
30
+ """
31
+
32
+
33
+ class TaskSpecBuild(TaskSpecK8s):
34
+ """Task Build specification."""
35
+
36
+ def __init__(
37
+ self,
38
+ function: str,
39
+ context_refs: list | None = None,
40
+ context_sources: list | None = None,
41
+ instructions: list | None = None,
42
+ **kwargs,
43
+ ) -> None:
44
+ """
45
+ Constructor.
46
+ """
47
+ super().__init__(function, **kwargs)
48
+
49
+ self.context_refs = context_refs
50
+ self.context_sources = context_sources
51
+ self.instructions = instructions
52
+
53
+
54
+ class TaskParamsBuild(TaskParamsK8s):
55
+ """
56
+ TaskParamsBuild model.
57
+ """
58
+
59
+ context_refs: list[ContextRef] = None
60
+ """Context references."""
61
+
62
+ context_sources: list[ContextSource] = None
63
+ """Context sources."""
64
+
65
+ instructions: list[str] = None
66
+ """Build instructions."""
67
+
68
+
69
+ class TaskSpecServe(TaskSpecK8s):
70
+ """Task Serve specification."""
71
+
72
+
73
+ class TaskParamsServe(TaskParamsK8s):
74
+ """
75
+ TaskParamsServe model.
76
+ """
@@ -7,18 +7,29 @@ from pathlib import Path
7
7
  from typing import Callable
8
8
 
9
9
  from digitalhub_core.runtimes.base import Runtime
10
+ from digitalhub_core.runtimes.registry import KindRegistry
10
11
  from digitalhub_core.utils.logger import LOGGER
11
12
  from digitalhub_runtime_python.utils.configuration import get_function_from_source
12
13
  from digitalhub_runtime_python.utils.inputs import get_inputs_parameters
13
14
  from digitalhub_runtime_python.utils.outputs import build_status, parse_outputs
14
15
 
16
+ data = {
17
+ "executable": {"kind": "python"},
18
+ "task": [
19
+ {"kind": "python+job", "action": "job"},
20
+ {"kind": "python+serve", "action": "serve"},
21
+ {"kind": "python+build", "action": "build"},
22
+ ],
23
+ "run": {"kind": "python+run"},
24
+ }
25
+
15
26
 
16
27
  class RuntimePython(Runtime):
17
28
  """
18
29
  Runtime Python class.
19
30
  """
20
31
 
21
- allowed_actions = ["job", "nuclio"]
32
+ kind_registry = KindRegistry(data)
22
33
 
23
34
  def __init__(self) -> None:
24
35
  """
@@ -92,7 +92,6 @@ def save_function_source(path: Path, source_spec: dict) -> Path:
92
92
 
93
93
  # Base64
94
94
  if base64 is not None:
95
-
96
95
  filename = "main.py"
97
96
  if scheme == "local":
98
97
  filename = Path(source).name
@@ -13,18 +13,17 @@ from digitalhub_ml.entities.models.crud import model_from_dict
13
13
  if typing.TYPE_CHECKING:
14
14
  from digitalhub_core.entities._base.entity import Entity
15
15
  from digitalhub_core.entities.artifacts.entity import Artifact
16
- from digitalhub_data.entities.dataitems.entity._base import Dataitem
16
+ from digitalhub_data.entities.dataitems.entity.table import DataitemTable
17
17
  from digitalhub_ml.entities.models.entity import Model
18
- from pandas import DataFrame
19
18
 
20
19
 
21
- def persist_dataitem(dataitem: Dataitem, tmp_dir: Path) -> str:
20
+ def persist_dataitem(dataitem: DataitemTable, tmp_dir: Path) -> str:
22
21
  """
23
22
  Persist dataitem locally.
24
23
 
25
24
  Parameters
26
25
  ----------
27
- dataitem : Dataitem
26
+ dataitem : DataitemTable
28
27
  The dataitem to persist.
29
28
  tmp_dir : Path
30
29
  Temporary download directory.
@@ -42,10 +41,9 @@ def persist_dataitem(dataitem: Dataitem, tmp_dir: Path) -> str:
42
41
  name = dataitem.name
43
42
  try:
44
43
  LOGGER.info(f"Persisting dataitem '{name}' locally.")
45
- tmp_path = tmp_dir / f"{name}.csv"
46
- dataframe: DataFrame = dataitem.as_df()
47
- dataframe.to_csv(tmp_path, sep=",", index=False)
48
- return str(tmp_path)
44
+ tmp_path = str(tmp_dir / f"{name}.csv")
45
+ dataitem.write_df(target_path=tmp_path, extension="csv", sep=",")
46
+ return tmp_path
49
47
  except Exception as e:
50
48
  msg = f"Error during dataitem '{name}' collection. Exception: {e.__class__}. Error: {e.args}"
51
49
  LOGGER.exception(msg)
@@ -77,9 +75,8 @@ def persist_artifact(artifact: Artifact, tmp_dir: Path) -> str:
77
75
  try:
78
76
  LOGGER.info(f"Persisting artifact '{name}' locally.")
79
77
  filename = Path(artifact.spec.path).name
80
- dst = tmp_dir / filename
81
- tmp_path = artifact.download(dst=dst)
82
- return str(tmp_path)
78
+ dst = str(tmp_dir / filename)
79
+ return artifact.download(dst=dst)
83
80
  except Exception as e:
84
81
  msg = f"Error during artifact '{name}' collection. Exception: {e.__class__}. Error: {e.args}"
85
82
  LOGGER.exception(msg)
@@ -111,9 +108,8 @@ def persist_model(model: Model, tmp_dir: Path) -> str:
111
108
  try:
112
109
  LOGGER.info(f"Persisting model '{name}' locally.")
113
110
  filename = Path(model.spec.path).name
114
- dst = tmp_dir / filename
115
- tmp_path = model.download(dst=dst)
116
- return str(tmp_path)
111
+ dst = str(tmp_dir / filename)
112
+ return model.download(dst=dst)
117
113
  except Exception as e:
118
114
  msg = f"Error during model '{name}' collection. Exception: {e.__class__}. Error: {e.args}"
119
115
  LOGGER.exception(msg)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: digitalhub-runtime-python
3
- Version: 0.5.0b7
3
+ Version: 0.5.0b9
4
4
  Summary: Python runtime for DHCore
5
5
  Author-email: Fondazione Bruno Kessler <dslab@fbk.eu>, Matteo Martini <mmartini@fbk.eu>
6
6
  License: Apache License
@@ -9,15 +9,12 @@ digitalhub_runtime_python.egg-info/requires.txt
9
9
  digitalhub_runtime_python.egg-info/top_level.txt
10
10
  digitalhub_runtime_python/entities/__init__.py
11
11
  digitalhub_runtime_python/entities/functions/__init__.py
12
- digitalhub_runtime_python/entities/functions/metadata.py
13
12
  digitalhub_runtime_python/entities/functions/spec.py
14
13
  digitalhub_runtime_python/entities/functions/status.py
15
14
  digitalhub_runtime_python/entities/runs/__init__.py
16
- digitalhub_runtime_python/entities/runs/metadata.py
17
15
  digitalhub_runtime_python/entities/runs/spec.py
18
16
  digitalhub_runtime_python/entities/runs/status.py
19
17
  digitalhub_runtime_python/entities/tasks/__init__.py
20
- digitalhub_runtime_python/entities/tasks/metadata.py
21
18
  digitalhub_runtime_python/entities/tasks/models.py
22
19
  digitalhub_runtime_python/entities/tasks/spec.py
23
20
  digitalhub_runtime_python/entities/tasks/status.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "digitalhub-runtime-python"
7
- version = "0.5.0b7"
7
+ version = "0.5.0b9"
8
8
  description = "Python runtime for DHCore"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -39,7 +39,7 @@ line-length = 120
39
39
  convention = "numpy"
40
40
 
41
41
  [tool.bumpver]
42
- current_version = "0.5.0b7"
42
+ current_version = "0.5.0b9"
43
43
  version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]"
44
44
  commit_message = "Bump version {old_version} -> {new_version}"
45
45
  commit = false
@@ -1,9 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from digitalhub_core.entities.functions.metadata import FunctionMetadata
4
-
5
-
6
- class FunctionMetadataPython(FunctionMetadata):
7
- """
8
- Function Python metadata.
9
- """
@@ -1,9 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from digitalhub_core.entities.runs.metadata import RunMetadata
4
-
5
-
6
- class RunMetadataPython(RunMetadata):
7
- """
8
- Run Python metadata.
9
- """
@@ -1,15 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from digitalhub_core.entities.tasks.metadata import TaskMetadata
4
-
5
-
6
- class TaskMetadataJob(TaskMetadata):
7
- """
8
- Task Job metadata.
9
- """
10
-
11
-
12
- class TaskMetadataBuild(TaskMetadata):
13
- """
14
- Task Build metadata.
15
- """
@@ -1,103 +0,0 @@
1
- """
2
- Task Python specification module.
3
- """
4
- from __future__ import annotations
5
-
6
- from digitalhub_core.entities.tasks.models import K8s
7
- from digitalhub_core.entities.tasks.spec import TaskParams, TaskSpec
8
- from digitalhub_runtime_python.entities.tasks.models import ContextRef, ContextSource
9
-
10
-
11
- class TaskSpecPythonBase(TaskSpec):
12
- """Task Python specification for Kubernetes."""
13
-
14
- def __init__(
15
- self,
16
- function: str,
17
- k8s: dict | None = None,
18
- ) -> None:
19
- """
20
- Constructor.
21
- """
22
- super().__init__(function)
23
- if k8s is None:
24
- k8s = {}
25
- k8s = K8s(**k8s).dict(by_alias=True)
26
- self.node_selector = k8s.get("node_selector")
27
- self.volumes = k8s.get("volumes")
28
- self.resources = k8s.get("resources")
29
- self.affinity = k8s.get("affinity")
30
- self.tolerations = k8s.get("tolerations")
31
- self.envs = k8s.get("envs")
32
- self.secrets = k8s.get("secrets")
33
- self.backoff_limit = k8s.get("backoff_limit")
34
- self.schedule = k8s.get("schedule")
35
- self.replicas = k8s.get("replicas")
36
-
37
-
38
- class TaskSpecJob(TaskSpecPythonBase):
39
- """Task Job specification."""
40
-
41
- def __init__(
42
- self,
43
- function: str,
44
- k8s: dict | None = None,
45
- ) -> None:
46
- """
47
- Constructor.
48
- """
49
- super().__init__(function, k8s)
50
-
51
- k8s = k8s if k8s is not None else {}
52
-
53
- self.backoff_limit = k8s.get("backoff_limit")
54
- self.schedule = k8s.get("schedule")
55
-
56
-
57
- class TaskParamsJob(TaskParams):
58
- """
59
- TaskParamsJob model.
60
- """
61
-
62
- k8s: K8s = None
63
- """Kubernetes resources."""
64
-
65
-
66
- class TaskSpecBuild(TaskSpecPythonBase):
67
- """Task Build specification."""
68
-
69
- def __init__(
70
- self,
71
- function: str,
72
- k8s: dict | None = None,
73
- context_refs: list | None = None,
74
- context_sources: list | None = None,
75
- instructions: list | None = None,
76
- ) -> None:
77
- """
78
- Constructor.
79
- """
80
- super().__init__(function, k8s)
81
-
82
- k8s = k8s if k8s is not None else {}
83
- self.context_refs = context_refs
84
- self.context_sources = context_sources
85
- self.instructions = instructions
86
-
87
-
88
- class TaskParamsBuild(TaskParams):
89
- """
90
- TaskParamsBuild model.
91
- """
92
-
93
- k8s: K8s = None
94
- """Kubernetes resources."""
95
-
96
- context_refs: list[ContextRef] = None
97
- """Context references."""
98
-
99
- context_sources: list[ContextSource] = None
100
- """Context sources."""
101
-
102
- instructions: list[str] = None
103
- """Build instructions."""