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.
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/PKG-INFO +1 -1
- digitalhub_runtime_python-0.5.0b9/digitalhub_runtime_python/entities/tasks/spec.py +76 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/runtimes/runtime.py +12 -1
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/utils/configuration.py +0 -1
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/utils/inputs.py +10 -14
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python.egg-info/PKG-INFO +1 -1
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python.egg-info/SOURCES.txt +0 -3
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/pyproject.toml +2 -2
- digitalhub_runtime_python-0.5.0b7/digitalhub_runtime_python/entities/functions/metadata.py +0 -9
- digitalhub_runtime_python-0.5.0b7/digitalhub_runtime_python/entities/runs/metadata.py +0 -9
- digitalhub_runtime_python-0.5.0b7/digitalhub_runtime_python/entities/tasks/metadata.py +0 -15
- digitalhub_runtime_python-0.5.0b7/digitalhub_runtime_python/entities/tasks/spec.py +0 -103
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/LICENSE.txt +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/README.md +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/__init__.py +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/__init__.py +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/functions/__init__.py +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/functions/spec.py +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/functions/status.py +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/runs/__init__.py +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/runs/spec.py +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/runs/status.py +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/tasks/__init__.py +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/tasks/models.py +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/entities/tasks/status.py +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/runtimes/__init__.py +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/utils/outputs.py +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python/utils/utils.py +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python.egg-info/dependency_links.txt +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python.egg-info/requires.txt +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/digitalhub_runtime_python.egg-info/top_level.txt +0 -0
- {digitalhub_runtime_python-0.5.0b7 → digitalhub_runtime_python-0.5.0b9}/setup.cfg +0 -0
|
@@ -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
|
-
|
|
32
|
+
kind_registry = KindRegistry(data)
|
|
22
33
|
|
|
23
34
|
def __init__(self) -> None:
|
|
24
35
|
"""
|
|
@@ -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.
|
|
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:
|
|
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 :
|
|
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
|
-
|
|
47
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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)
|
|
@@ -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.
|
|
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.
|
|
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,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."""
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|