digitalhub-runtime-python 0.8.0__tar.gz → 0.8.0b0__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.8.0 → digitalhub_runtime_python-0.8.0b0}/PKG-INFO +2 -2
- digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python/__init__.py +44 -0
- {digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/function/python → digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python/entities/function}/models.py +6 -6
- {digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/function/python → digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python/entities/function}/spec.py +5 -6
- digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python/entities/function/status.py +9 -0
- {digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/run/python_run → digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python/entities/run}/spec.py +5 -14
- digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python/entities/run/status.py +39 -0
- digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python/entities/task/spec.py +138 -0
- digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python/entities/task/status.py +21 -0
- digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python/runtimes/kind_registry.py +15 -0
- {digitalhub_runtime_python-0.8.0 → digitalhub_runtime_python-0.8.0b0}/digitalhub_runtime_python/runtimes/runtime.py +8 -5
- {digitalhub_runtime_python-0.8.0 → digitalhub_runtime_python-0.8.0b0}/digitalhub_runtime_python/utils/configuration.py +10 -5
- {digitalhub_runtime_python-0.8.0 → digitalhub_runtime_python-0.8.0b0}/digitalhub_runtime_python/utils/inputs.py +18 -8
- {digitalhub_runtime_python-0.8.0 → digitalhub_runtime_python-0.8.0b0}/digitalhub_runtime_python/utils/nuclio_configuration.py +1 -2
- {digitalhub_runtime_python-0.8.0 → digitalhub_runtime_python-0.8.0b0}/digitalhub_runtime_python/utils/outputs.py +9 -17
- {digitalhub_runtime_python-0.8.0 → digitalhub_runtime_python-0.8.0b0}/digitalhub_runtime_python.egg-info/PKG-INFO +2 -2
- digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python.egg-info/SOURCES.txt +30 -0
- digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python.egg-info/requires.txt +1 -0
- {digitalhub_runtime_python-0.8.0 → digitalhub_runtime_python-0.8.0b0}/pyproject.toml +3 -3
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/__init__.py +0 -23
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/_base/runtime_entity/builder.py +0 -22
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/function/python/builder.py +0 -20
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/function/python/entity.py +0 -33
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/function/python/status.py +0 -9
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/run/__init__.py +0 -0
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/run/python_run/__init__.py +0 -0
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/run/python_run/builder.py +0 -20
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/run/python_run/entity.py +0 -251
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/run/python_run/status.py +0 -25
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/run/python_run/utils.py +0 -34
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/__init__.py +0 -0
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_build/__init__.py +0 -0
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_build/builder.py +0 -20
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_build/entity.py +0 -32
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_build/spec.py +0 -44
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_build/status.py +0 -9
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_job/__init__.py +0 -0
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_job/builder.py +0 -20
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_job/entity.py +0 -32
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_job/spec.py +0 -49
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_job/status.py +0 -9
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_serve/__init__.py +0 -0
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_serve/builder.py +0 -20
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_serve/entity.py +0 -32
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_serve/spec.py +0 -48
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_serve/status.py +0 -9
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/runtimes/__init__.py +0 -0
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/runtimes/builder.py +0 -11
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python.egg-info/SOURCES.txt +0 -53
- digitalhub_runtime_python-0.8.0/digitalhub_runtime_python.egg-info/requires.txt +0 -1
- {digitalhub_runtime_python-0.8.0 → digitalhub_runtime_python-0.8.0b0}/LICENSE.txt +0 -0
- {digitalhub_runtime_python-0.8.0 → digitalhub_runtime_python-0.8.0b0}/README.md +0 -0
- {digitalhub_runtime_python-0.8.0 → digitalhub_runtime_python-0.8.0b0}/digitalhub_runtime_python/entities/__init__.py +0 -0
- {digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/_base → digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python/entities/function}/__init__.py +0 -0
- {digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/_base/runtime_entity → digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python/entities/run}/__init__.py +0 -0
- {digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/function → digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python/entities/task}/__init__.py +0 -0
- {digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/task/python_job → digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python/entities/task}/models.py +0 -0
- {digitalhub_runtime_python-0.8.0/digitalhub_runtime_python/entities/function/python → digitalhub_runtime_python-0.8.0b0/digitalhub_runtime_python/runtimes}/__init__.py +0 -0
- {digitalhub_runtime_python-0.8.0 → digitalhub_runtime_python-0.8.0b0}/digitalhub_runtime_python/utils/env.py +0 -0
- {digitalhub_runtime_python-0.8.0 → digitalhub_runtime_python-0.8.0b0}/digitalhub_runtime_python/utils/utils.py +0 -0
- {digitalhub_runtime_python-0.8.0 → digitalhub_runtime_python-0.8.0b0}/digitalhub_runtime_python.egg-info/dependency_links.txt +0 -0
- {digitalhub_runtime_python-0.8.0 → digitalhub_runtime_python-0.8.0b0}/digitalhub_runtime_python.egg-info/top_level.txt +0 -0
- {digitalhub_runtime_python-0.8.0 → digitalhub_runtime_python-0.8.0b0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: digitalhub-runtime-python
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.0b0
|
|
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
|
|
@@ -229,6 +229,6 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
229
229
|
Requires-Python: >=3.9
|
|
230
230
|
Description-Content-Type: text/markdown
|
|
231
231
|
License-File: LICENSE.txt
|
|
232
|
-
Requires-Dist: digitalhub[
|
|
232
|
+
Requires-Dist: digitalhub[ml]<0.9,>=0.8.0b
|
|
233
233
|
|
|
234
234
|
# SDK for DHCore
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from digitalhub_core.entities.entity_types import EntityTypes
|
|
4
|
+
from digitalhub_core.registry.registry import registry
|
|
5
|
+
from digitalhub_core.registry.utils import create_info
|
|
6
|
+
from digitalhub_runtime_python.utils.utils import handler
|
|
7
|
+
|
|
8
|
+
root = "digitalhub_runtime_python"
|
|
9
|
+
runtime_info = {
|
|
10
|
+
"module": f"{root}.runtimes.runtime",
|
|
11
|
+
"class_name": "RuntimePython",
|
|
12
|
+
"kind_registry_module": f"{root}.runtimes.kind_registry",
|
|
13
|
+
"kind_registry_class_name": "kind_registry",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
root_ent = f"{root}.entities"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# Function
|
|
20
|
+
entity_type = EntityTypes.FUNCTION.value
|
|
21
|
+
func_kind = "python"
|
|
22
|
+
prefix = entity_type.capitalize()
|
|
23
|
+
suffix = func_kind.capitalize()
|
|
24
|
+
func_info = create_info(root_ent, entity_type, prefix, suffix, runtime_info)
|
|
25
|
+
registry.register(func_kind, func_info)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Tasks
|
|
29
|
+
entity_type = EntityTypes.TASK.value
|
|
30
|
+
for i in ["job", "build", "serve"]:
|
|
31
|
+
task_kind = f"{func_kind}+{i}"
|
|
32
|
+
prefix = entity_type.capitalize()
|
|
33
|
+
suffix = i.capitalize()
|
|
34
|
+
task_info = create_info(root_ent, entity_type, prefix, suffix, runtime_info)
|
|
35
|
+
registry.register(task_kind, task_info)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# Runs
|
|
39
|
+
entity_type = EntityTypes.RUN.value
|
|
40
|
+
run_kind = f"{func_kind}+run"
|
|
41
|
+
prefix = entity_type.capitalize()
|
|
42
|
+
suffix = func_kind.capitalize()
|
|
43
|
+
run_info = create_info(root_ent, entity_type, prefix, suffix, runtime_info)
|
|
44
|
+
registry.register(run_kind, run_info)
|
|
@@ -2,10 +2,10 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from
|
|
8
|
-
from
|
|
5
|
+
from digitalhub_core.entities.function.models import SourceCodeParams, SourceCodeStruct
|
|
6
|
+
from digitalhub_core.utils.exceptions import EntityError
|
|
7
|
+
from digitalhub_core.utils.generic_utils import encode_source, encode_string
|
|
8
|
+
from digitalhub_core.utils.uri_utils import map_uri_scheme
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class SourceCodeStructPython(SourceCodeStruct):
|
|
@@ -92,9 +92,9 @@ class SourceCodeStructPython(SourceCodeStruct):
|
|
|
92
92
|
return dict_
|
|
93
93
|
|
|
94
94
|
|
|
95
|
-
class
|
|
95
|
+
class SourceCodeParamsPython(SourceCodeParams):
|
|
96
96
|
"""
|
|
97
|
-
|
|
97
|
+
Source code params for python.
|
|
98
98
|
"""
|
|
99
99
|
|
|
100
100
|
init_function: str = None
|
|
@@ -2,14 +2,13 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import Literal
|
|
4
4
|
|
|
5
|
-
from
|
|
6
|
-
|
|
7
|
-
from digitalhub.entities.function._base.spec import FunctionSpec, FunctionValidator
|
|
5
|
+
from digitalhub_core.entities.function.spec import FunctionParams, FunctionSpec
|
|
6
|
+
from digitalhub_runtime_python.entities.function.models import SourceCodeParamsPython, SourceCodeStructPython
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
class FunctionSpecPython(FunctionSpec):
|
|
11
10
|
"""
|
|
12
|
-
|
|
11
|
+
Specification for a Function job.
|
|
13
12
|
"""
|
|
14
13
|
|
|
15
14
|
def __init__(
|
|
@@ -91,9 +90,9 @@ class FunctionSpecPython(FunctionSpec):
|
|
|
91
90
|
return dict_
|
|
92
91
|
|
|
93
92
|
|
|
94
|
-
class
|
|
93
|
+
class FunctionParamsPython(FunctionParams, SourceCodeParamsPython):
|
|
95
94
|
"""
|
|
96
|
-
|
|
95
|
+
Function python parameters model.
|
|
97
96
|
"""
|
|
98
97
|
|
|
99
98
|
python_version: Literal["PYTHON3_9", "PYTHON3_10", "PYTHON3_11"]
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from digitalhub_ml.entities.run.spec import RunParamsMl, RunSpecMl
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
class
|
|
7
|
-
"""
|
|
6
|
+
class RunSpecPython(RunSpecMl):
|
|
7
|
+
"""Run Python specification."""
|
|
8
8
|
|
|
9
9
|
def __init__(
|
|
10
10
|
self,
|
|
@@ -24,10 +24,6 @@ class RunSpecPythonRun(RunSpec):
|
|
|
24
24
|
base_image: str | None = None,
|
|
25
25
|
python_version: str | None = None,
|
|
26
26
|
requirements: list | None = None,
|
|
27
|
-
backoff_limit: int | None = None,
|
|
28
|
-
schedule: str | None = None,
|
|
29
|
-
service_type: str | None = None,
|
|
30
|
-
replicas: int | None = None,
|
|
31
27
|
instructions: dict | None = None,
|
|
32
28
|
inputs: dict | None = None,
|
|
33
29
|
outputs: dict | None = None,
|
|
@@ -53,18 +49,14 @@ class RunSpecPythonRun(RunSpec):
|
|
|
53
49
|
self.base_image = base_image
|
|
54
50
|
self.python_version = python_version
|
|
55
51
|
self.requirements = requirements
|
|
56
|
-
self.backoff_limit = backoff_limit
|
|
57
|
-
self.schedule = schedule
|
|
58
|
-
self.service_type = service_type
|
|
59
|
-
self.replicas = replicas
|
|
60
52
|
self.instructions = instructions
|
|
61
53
|
self.inputs = inputs
|
|
62
54
|
self.outputs = outputs
|
|
63
55
|
self.parameters = parameters
|
|
64
56
|
|
|
65
57
|
|
|
66
|
-
class
|
|
67
|
-
"""
|
|
58
|
+
class RunParamsPython(RunParamsMl):
|
|
59
|
+
"""Run Python parameters."""
|
|
68
60
|
|
|
69
61
|
# Function parameters
|
|
70
62
|
source: dict = None
|
|
@@ -75,7 +67,6 @@ class RunValidatorPythonRun(RunValidator):
|
|
|
75
67
|
|
|
76
68
|
# Task job
|
|
77
69
|
backoff_limit: int = None
|
|
78
|
-
schedule: str = None
|
|
79
70
|
|
|
80
71
|
# Task serve
|
|
81
72
|
service_type: str = None
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import requests
|
|
4
|
+
from digitalhub_core.utils.exceptions import EntityError
|
|
5
|
+
from digitalhub_ml.entities.run.status import RunStatusMl
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class RunStatusPython(RunStatusMl):
|
|
9
|
+
"""
|
|
10
|
+
Run Python status.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def invoke(self, local: bool, **kwargs) -> requests.Response:
|
|
14
|
+
"""
|
|
15
|
+
Invoke running process.
|
|
16
|
+
|
|
17
|
+
Parameters
|
|
18
|
+
----------
|
|
19
|
+
kwargs
|
|
20
|
+
Keyword arguments to pass to the request.
|
|
21
|
+
|
|
22
|
+
Returns
|
|
23
|
+
-------
|
|
24
|
+
requests.Response
|
|
25
|
+
Response from service.
|
|
26
|
+
"""
|
|
27
|
+
try:
|
|
28
|
+
if local:
|
|
29
|
+
raise EntityError("Invoke not supported locally.")
|
|
30
|
+
|
|
31
|
+
method = kwargs.pop("method", "POST")
|
|
32
|
+
url = kwargs.get("url", "http://" + self.service.get("url"))
|
|
33
|
+
|
|
34
|
+
response = requests.request(method=method, url=url, **kwargs)
|
|
35
|
+
response.raise_for_status()
|
|
36
|
+
return response
|
|
37
|
+
except Exception as e:
|
|
38
|
+
msg = f"Something got wrong during model serving. Exception: {e.__class__}. Error: {e.args}"
|
|
39
|
+
raise EntityError(msg)
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from digitalhub_core.entities.task.spec import TaskParamsK8s, TaskSpecK8s
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TaskSpecJob(TaskSpecK8s):
|
|
9
|
+
"""Task Job specification."""
|
|
10
|
+
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
function: str,
|
|
14
|
+
node_selector: dict | None = None,
|
|
15
|
+
volumes: list | None = None,
|
|
16
|
+
resources: dict | None = None,
|
|
17
|
+
affinity: dict | None = None,
|
|
18
|
+
tolerations: list | None = None,
|
|
19
|
+
envs: list | None = None,
|
|
20
|
+
secrets: list | None = None,
|
|
21
|
+
profile: str | None = None,
|
|
22
|
+
backoff_limit: int | None = None,
|
|
23
|
+
schedule: str | None = None,
|
|
24
|
+
**kwargs,
|
|
25
|
+
) -> None:
|
|
26
|
+
super().__init__(
|
|
27
|
+
function,
|
|
28
|
+
node_selector,
|
|
29
|
+
volumes,
|
|
30
|
+
resources,
|
|
31
|
+
affinity,
|
|
32
|
+
tolerations,
|
|
33
|
+
envs,
|
|
34
|
+
secrets,
|
|
35
|
+
profile,
|
|
36
|
+
**kwargs,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
self.backoff_limit = backoff_limit
|
|
40
|
+
self.schedule = schedule
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class TaskParamsJob(TaskParamsK8s):
|
|
44
|
+
"""
|
|
45
|
+
TaskParamsJob model.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
backoff_limit: int = None
|
|
49
|
+
"""Backoff limit."""
|
|
50
|
+
|
|
51
|
+
schedule: str = None
|
|
52
|
+
"""Schedule."""
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class TaskSpecBuild(TaskSpecK8s):
|
|
56
|
+
"""Task Build specification."""
|
|
57
|
+
|
|
58
|
+
def __init__(
|
|
59
|
+
self,
|
|
60
|
+
function: str,
|
|
61
|
+
node_selector: dict | None = None,
|
|
62
|
+
volumes: list | None = None,
|
|
63
|
+
resources: dict | None = None,
|
|
64
|
+
affinity: dict | None = None,
|
|
65
|
+
tolerations: list | None = None,
|
|
66
|
+
envs: list | None = None,
|
|
67
|
+
secrets: list | None = None,
|
|
68
|
+
profile: str | None = None,
|
|
69
|
+
instructions: list | None = None,
|
|
70
|
+
**kwargs,
|
|
71
|
+
) -> None:
|
|
72
|
+
super().__init__(
|
|
73
|
+
function,
|
|
74
|
+
node_selector,
|
|
75
|
+
volumes,
|
|
76
|
+
resources,
|
|
77
|
+
affinity,
|
|
78
|
+
tolerations,
|
|
79
|
+
envs,
|
|
80
|
+
secrets,
|
|
81
|
+
profile,
|
|
82
|
+
**kwargs,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
self.instructions = instructions
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class TaskParamsBuild(TaskParamsK8s):
|
|
89
|
+
"""
|
|
90
|
+
TaskParamsBuild model.
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
instructions: list[str] = None
|
|
94
|
+
"""Build instructions."""
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class TaskSpecServe(TaskSpecK8s):
|
|
98
|
+
"""Task Serve specification."""
|
|
99
|
+
|
|
100
|
+
def __init__(
|
|
101
|
+
self,
|
|
102
|
+
function: str,
|
|
103
|
+
node_selector: dict | None = None,
|
|
104
|
+
volumes: list | None = None,
|
|
105
|
+
resources: dict | None = None,
|
|
106
|
+
affinity: dict | None = None,
|
|
107
|
+
tolerations: list | None = None,
|
|
108
|
+
envs: list | None = None,
|
|
109
|
+
secrets: list | None = None,
|
|
110
|
+
profile: str | None = None,
|
|
111
|
+
replicas: int | None = None,
|
|
112
|
+
service_type: str | None = None,
|
|
113
|
+
**kwargs,
|
|
114
|
+
) -> None:
|
|
115
|
+
super().__init__(
|
|
116
|
+
function,
|
|
117
|
+
node_selector,
|
|
118
|
+
volumes,
|
|
119
|
+
resources,
|
|
120
|
+
affinity,
|
|
121
|
+
tolerations,
|
|
122
|
+
envs,
|
|
123
|
+
secrets,
|
|
124
|
+
profile,
|
|
125
|
+
**kwargs,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
self.replicas = replicas
|
|
129
|
+
self.service_type = service_type
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class TaskParamsServe(TaskParamsK8s):
|
|
133
|
+
"""
|
|
134
|
+
TaskParamsServe model.
|
|
135
|
+
"""
|
|
136
|
+
|
|
137
|
+
replicas: int = None
|
|
138
|
+
service_type: Literal["ClusterIP", "NodePort", "LoadBalancer"] = "NodePort"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from digitalhub_core.entities.task.status import TaskStatus
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TaskStatusJob(TaskStatus):
|
|
7
|
+
"""
|
|
8
|
+
Task Job status.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TaskStatusBuild(TaskStatus):
|
|
13
|
+
"""
|
|
14
|
+
Task Build status.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class TaskStatusServe(TaskStatus):
|
|
19
|
+
"""
|
|
20
|
+
Task Serve status.
|
|
21
|
+
"""
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from digitalhub_core.runtimes.kind_registry import KindRegistry
|
|
4
|
+
|
|
5
|
+
kind_registry = KindRegistry(
|
|
6
|
+
{
|
|
7
|
+
"executable": {"kind": "python"},
|
|
8
|
+
"task": [
|
|
9
|
+
{"kind": "python+job", "action": "job"},
|
|
10
|
+
{"kind": "python+serve", "action": "serve"},
|
|
11
|
+
{"kind": "python+build", "action": "build"},
|
|
12
|
+
],
|
|
13
|
+
"run": {"kind": "python+run"},
|
|
14
|
+
}
|
|
15
|
+
)
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import typing
|
|
3
4
|
from typing import Callable
|
|
4
5
|
|
|
6
|
+
from digitalhub_core.context.builder import get_context
|
|
7
|
+
from digitalhub_core.runtimes.base import Runtime
|
|
8
|
+
from digitalhub_core.utils.logger import LOGGER
|
|
5
9
|
from digitalhub_runtime_python.utils.configuration import get_function_from_source
|
|
6
10
|
from digitalhub_runtime_python.utils.inputs import compose_inputs
|
|
7
11
|
from digitalhub_runtime_python.utils.outputs import build_status, parse_outputs
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
from
|
|
11
|
-
from digitalhub.utils.logger import LOGGER
|
|
13
|
+
if typing.TYPE_CHECKING:
|
|
14
|
+
from digitalhub_core.runtimes.kind_registry import KindRegistry
|
|
12
15
|
|
|
13
16
|
|
|
14
17
|
class RuntimePython(Runtime):
|
|
@@ -16,8 +19,8 @@ class RuntimePython(Runtime):
|
|
|
16
19
|
Runtime Python class.
|
|
17
20
|
"""
|
|
18
21
|
|
|
19
|
-
def __init__(self, project: str) -> None:
|
|
20
|
-
super().__init__(project)
|
|
22
|
+
def __init__(self, kind_registry: KindRegistry, project: str) -> None:
|
|
23
|
+
super().__init__(kind_registry, project)
|
|
21
24
|
ctx = get_context(self.project)
|
|
22
25
|
self.runtime_dir = ctx.root / "runtime_python"
|
|
23
26
|
self.runtime_dir.mkdir(parents=True, exist_ok=True)
|
|
@@ -4,11 +4,16 @@ import importlib.util as imputil
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from typing import Callable
|
|
6
6
|
|
|
7
|
-
from
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
from digitalhub_core.utils.generic_utils import (
|
|
8
|
+
decode_string,
|
|
9
|
+
extract_archive,
|
|
10
|
+
get_bucket_and_key,
|
|
11
|
+
get_s3_source,
|
|
12
|
+
requests_chunk_download,
|
|
13
|
+
)
|
|
14
|
+
from digitalhub_core.utils.git_utils import clone_repository
|
|
15
|
+
from digitalhub_core.utils.logger import LOGGER
|
|
16
|
+
from digitalhub_core.utils.uri_utils import map_uri_scheme
|
|
12
17
|
|
|
13
18
|
|
|
14
19
|
def get_function_from_source(path: Path, source_spec: dict) -> Callable:
|
|
@@ -4,14 +4,18 @@ import inspect
|
|
|
4
4
|
import typing
|
|
5
5
|
from typing import Any, Callable
|
|
6
6
|
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
from
|
|
10
|
-
from
|
|
7
|
+
from digitalhub_core.context.builder import get_context
|
|
8
|
+
from digitalhub_core.entities.artifact.crud import artifact_from_dict
|
|
9
|
+
from digitalhub_core.entities.utils import parse_entity_key
|
|
10
|
+
from digitalhub_core.utils.logger import LOGGER
|
|
11
|
+
from digitalhub_data.entities.dataitem.crud import dataitem_from_dict
|
|
12
|
+
from digitalhub_ml.entities.entity_types import EntityTypes
|
|
13
|
+
from digitalhub_ml.entities.model.crud import model_from_dict
|
|
14
|
+
from digitalhub_ml.entities.project.crud import get_project
|
|
11
15
|
|
|
12
16
|
if typing.TYPE_CHECKING:
|
|
13
|
-
from
|
|
14
|
-
from
|
|
17
|
+
from digitalhub_core.entities._base.entity.base import Entity
|
|
18
|
+
from digitalhub_core.entities.project.entity._base import Project
|
|
15
19
|
|
|
16
20
|
|
|
17
21
|
def get_project_(project_name: str) -> Project:
|
|
@@ -53,12 +57,18 @@ def get_entity_inputs(inputs: dict) -> dict[str, Entity]:
|
|
|
53
57
|
Returns
|
|
54
58
|
-------
|
|
55
59
|
dict
|
|
56
|
-
|
|
60
|
+
Mlrun inputs.
|
|
57
61
|
"""
|
|
58
62
|
try:
|
|
59
63
|
inputs_objects = {}
|
|
60
64
|
for k, v in inputs.items():
|
|
61
|
-
|
|
65
|
+
_, entity_type, _, _, _ = parse_entity_key(v.get("key"))
|
|
66
|
+
if entity_type == EntityTypes.DATAITEM.value:
|
|
67
|
+
inputs_objects[k] = dataitem_from_dict(v)
|
|
68
|
+
elif entity_type == EntityTypes.ARTIFACT.value:
|
|
69
|
+
inputs_objects[k] = artifact_from_dict(v)
|
|
70
|
+
elif entity_type == EntityTypes.MODEL.value:
|
|
71
|
+
inputs_objects[k] = model_from_dict(v)
|
|
62
72
|
return inputs_objects
|
|
63
73
|
except Exception as e:
|
|
64
74
|
msg = f"Error during inputs collection. Exception: {e.__class__}. Error: {e.args}"
|
|
@@ -3,10 +3,9 @@ from __future__ import annotations
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from typing import Callable, Union
|
|
5
5
|
|
|
6
|
+
from digitalhub_core.utils.uri_utils import map_uri_scheme
|
|
6
7
|
from digitalhub_runtime_python.utils.configuration import import_function
|
|
7
8
|
|
|
8
|
-
from digitalhub.utils.uri_utils import map_uri_scheme
|
|
9
|
-
|
|
10
9
|
|
|
11
10
|
def parse_handler(handler: str) -> tuple[Path, str]:
|
|
12
11
|
"""
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import pickle
|
|
4
|
-
import typing
|
|
5
4
|
from typing import Any
|
|
6
5
|
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from
|
|
12
|
-
from
|
|
13
|
-
from
|
|
14
|
-
from digitalhub.utils.logger import LOGGER
|
|
15
|
-
|
|
16
|
-
if typing.TYPE_CHECKING:
|
|
17
|
-
from digitalhub.entities.dataitem.table.entity import DataitemTable
|
|
6
|
+
from digitalhub_core.entities._base.state import State
|
|
7
|
+
from digitalhub_core.entities.artifact.crud import log_artifact
|
|
8
|
+
from digitalhub_core.entities.artifact.entity._base import Artifact
|
|
9
|
+
from digitalhub_core.utils.logger import LOGGER
|
|
10
|
+
from digitalhub_data.entities.dataitem.crud import log_dataitem
|
|
11
|
+
from digitalhub_data.entities.dataitem.entity.table import DataitemTable
|
|
12
|
+
from digitalhub_data.readers.registry import DATAFRAME_TYPES
|
|
18
13
|
|
|
19
14
|
|
|
20
15
|
def collect_outputs(results: Any, outputs: list[str], project_name: str) -> dict:
|
|
@@ -45,12 +40,9 @@ def collect_outputs(results: Any, outputs: list[str], project_name: str) -> dict
|
|
|
45
40
|
if isinstance(item, (str, int, float, bool, bytes)):
|
|
46
41
|
objects[name] = item
|
|
47
42
|
|
|
48
|
-
elif f"{item.__class__.__module__}.{item.__class__.__name__}" in
|
|
43
|
+
elif f"{item.__class__.__module__}.{item.__class__.__name__}" in DATAFRAME_TYPES:
|
|
49
44
|
objects[name] = _log_dataitem(name, project_name, item)
|
|
50
45
|
|
|
51
|
-
elif isinstance(item, (Dataitem, Artifact, Model)):
|
|
52
|
-
objects[name] = item
|
|
53
|
-
|
|
54
46
|
else:
|
|
55
47
|
objects[name] = _log_artifact(name, project_name, item)
|
|
56
48
|
|
|
@@ -199,7 +191,7 @@ def build_status(
|
|
|
199
191
|
|
|
200
192
|
try:
|
|
201
193
|
for key, value in parsed_execution.items():
|
|
202
|
-
if isinstance(value, (
|
|
194
|
+
if isinstance(value, (DataitemTable, Artifact)):
|
|
203
195
|
outputs[key] = value.key
|
|
204
196
|
else:
|
|
205
197
|
results[key] = value
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: digitalhub-runtime-python
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.0b0
|
|
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
|
|
@@ -229,6 +229,6 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
229
229
|
Requires-Python: >=3.9
|
|
230
230
|
Description-Content-Type: text/markdown
|
|
231
231
|
License-File: LICENSE.txt
|
|
232
|
-
Requires-Dist: digitalhub[
|
|
232
|
+
Requires-Dist: digitalhub[ml]<0.9,>=0.8.0b
|
|
233
233
|
|
|
234
234
|
# SDK for DHCore
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
LICENSE.txt
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
digitalhub_runtime_python/__init__.py
|
|
5
|
+
digitalhub_runtime_python.egg-info/PKG-INFO
|
|
6
|
+
digitalhub_runtime_python.egg-info/SOURCES.txt
|
|
7
|
+
digitalhub_runtime_python.egg-info/dependency_links.txt
|
|
8
|
+
digitalhub_runtime_python.egg-info/requires.txt
|
|
9
|
+
digitalhub_runtime_python.egg-info/top_level.txt
|
|
10
|
+
digitalhub_runtime_python/entities/__init__.py
|
|
11
|
+
digitalhub_runtime_python/entities/function/__init__.py
|
|
12
|
+
digitalhub_runtime_python/entities/function/models.py
|
|
13
|
+
digitalhub_runtime_python/entities/function/spec.py
|
|
14
|
+
digitalhub_runtime_python/entities/function/status.py
|
|
15
|
+
digitalhub_runtime_python/entities/run/__init__.py
|
|
16
|
+
digitalhub_runtime_python/entities/run/spec.py
|
|
17
|
+
digitalhub_runtime_python/entities/run/status.py
|
|
18
|
+
digitalhub_runtime_python/entities/task/__init__.py
|
|
19
|
+
digitalhub_runtime_python/entities/task/models.py
|
|
20
|
+
digitalhub_runtime_python/entities/task/spec.py
|
|
21
|
+
digitalhub_runtime_python/entities/task/status.py
|
|
22
|
+
digitalhub_runtime_python/runtimes/__init__.py
|
|
23
|
+
digitalhub_runtime_python/runtimes/kind_registry.py
|
|
24
|
+
digitalhub_runtime_python/runtimes/runtime.py
|
|
25
|
+
digitalhub_runtime_python/utils/configuration.py
|
|
26
|
+
digitalhub_runtime_python/utils/env.py
|
|
27
|
+
digitalhub_runtime_python/utils/inputs.py
|
|
28
|
+
digitalhub_runtime_python/utils/nuclio_configuration.py
|
|
29
|
+
digitalhub_runtime_python/utils/outputs.py
|
|
30
|
+
digitalhub_runtime_python/utils/utils.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
digitalhub[ml]<0.9,>=0.8.0b
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "digitalhub-runtime-python"
|
|
7
|
-
version = "0.8.
|
|
7
|
+
version = "0.8.0b0"
|
|
8
8
|
description = "Python runtime for DHCore"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
@@ -21,7 +21,7 @@ classifiers = [
|
|
|
21
21
|
keywords = ["data", "dataops", "kubernetes"]
|
|
22
22
|
requires-python = ">=3.9"
|
|
23
23
|
dependencies = [
|
|
24
|
-
"digitalhub[
|
|
24
|
+
"digitalhub[ml]>=0.8.0b, <0.9",
|
|
25
25
|
]
|
|
26
26
|
|
|
27
27
|
[project.urls]
|
|
@@ -40,7 +40,7 @@ line-length = 120
|
|
|
40
40
|
convention = "numpy"
|
|
41
41
|
|
|
42
42
|
[tool.bumpver]
|
|
43
|
-
current_version = "0.8.
|
|
43
|
+
current_version = "0.8.0b0"
|
|
44
44
|
version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]"
|
|
45
45
|
commit_message = "Bump version {old_version} -> {new_version}"
|
|
46
46
|
commit = false
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from digitalhub_runtime_python.entities.function.python.builder import FunctionPythonBuilder
|
|
4
|
-
from digitalhub_runtime_python.entities.run.python_run.builder import RunPythonRunBuilder
|
|
5
|
-
from digitalhub_runtime_python.entities.task.python_build.builder import TaskPythonBuildBuilder
|
|
6
|
-
from digitalhub_runtime_python.entities.task.python_job.builder import TaskPythonJobBuilder
|
|
7
|
-
from digitalhub_runtime_python.entities.task.python_serve.builder import TaskPythonServeBuilder
|
|
8
|
-
from digitalhub_runtime_python.utils.utils import handler
|
|
9
|
-
|
|
10
|
-
entity_builders = (
|
|
11
|
-
(FunctionPythonBuilder.ENTITY_KIND, FunctionPythonBuilder),
|
|
12
|
-
(TaskPythonBuildBuilder.ENTITY_KIND, TaskPythonBuildBuilder),
|
|
13
|
-
(TaskPythonJobBuilder.ENTITY_KIND, TaskPythonJobBuilder),
|
|
14
|
-
(TaskPythonServeBuilder.ENTITY_KIND, TaskPythonServeBuilder),
|
|
15
|
-
(RunPythonRunBuilder.ENTITY_KIND, RunPythonRunBuilder),
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
try:
|
|
19
|
-
from digitalhub_runtime_python.runtimes.builder import RuntimePythonBuilder
|
|
20
|
-
|
|
21
|
-
runtime_builders = ((kind, RuntimePythonBuilder) for kind in FunctionPythonBuilder().get_all_kinds())
|
|
22
|
-
except ImportError:
|
|
23
|
-
runtime_builders = tuple()
|