digitalhub-runtime-python 0.5.0b11__tar.gz → 0.6.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.
Files changed (31) hide show
  1. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/PKG-INFO +2 -2
  2. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/entities/functions/spec.py +5 -0
  3. digitalhub_runtime_python-0.6.0b0/digitalhub_runtime_python/entities/runs/spec.py +81 -0
  4. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/entities/tasks/spec.py +23 -12
  5. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/runtimes/runtime.py +24 -0
  6. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python.egg-info/PKG-INFO +2 -2
  7. digitalhub_runtime_python-0.6.0b0/digitalhub_runtime_python.egg-info/requires.txt +1 -0
  8. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/pyproject.toml +3 -3
  9. digitalhub_runtime_python-0.5.0b11/digitalhub_runtime_python/entities/runs/spec.py +0 -53
  10. digitalhub_runtime_python-0.5.0b11/digitalhub_runtime_python.egg-info/requires.txt +0 -1
  11. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/LICENSE.txt +0 -0
  12. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/README.md +0 -0
  13. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/__init__.py +0 -0
  14. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/entities/__init__.py +0 -0
  15. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/entities/functions/__init__.py +0 -0
  16. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/entities/functions/status.py +0 -0
  17. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/entities/runs/__init__.py +0 -0
  18. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/entities/runs/status.py +0 -0
  19. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/entities/tasks/__init__.py +0 -0
  20. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/entities/tasks/models.py +0 -0
  21. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/entities/tasks/status.py +0 -0
  22. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/runtimes/__init__.py +0 -0
  23. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/runtimes/kind_registry.py +0 -0
  24. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/utils/configuration.py +0 -0
  25. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/utils/inputs.py +0 -0
  26. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/utils/outputs.py +0 -0
  27. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python/utils/utils.py +0 -0
  28. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python.egg-info/SOURCES.txt +0 -0
  29. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python.egg-info/dependency_links.txt +0 -0
  30. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/digitalhub_runtime_python.egg-info/top_level.txt +0 -0
  31. {digitalhub_runtime_python-0.5.0b11 → digitalhub_runtime_python-0.6.0b0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: digitalhub-runtime-python
3
- Version: 0.5.0b11
3
+ Version: 0.6.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
@@ -228,6 +228,6 @@ Classifier: Programming Language :: Python :: 3.10
228
228
  Requires-Python: >=3.9
229
229
  Description-Content-Type: text/markdown
230
230
  License-File: LICENSE.txt
231
- Requires-Dist: digitalhub[ml]<0.6,~=0.5.0b
231
+ Requires-Dist: digitalhub[ml]<0.7,~=0.6.0b
232
232
 
233
233
  # SDK for DHCore
@@ -21,6 +21,7 @@ class FunctionSpecPython(FunctionSpec):
21
21
  source: dict,
22
22
  image: str | None = None,
23
23
  base_image: str | None = None,
24
+ python_version: str | None = None,
24
25
  requirements: list | None = None,
25
26
  ) -> None:
26
27
  """
@@ -30,6 +31,7 @@ class FunctionSpecPython(FunctionSpec):
30
31
 
31
32
  self.image = image
32
33
  self.base_image = base_image
34
+ self.python_version = python_version
33
35
  self.requirements = requirements
34
36
 
35
37
  source = self._source_check(source)
@@ -135,5 +137,8 @@ class FunctionParamsPython(FunctionParams):
135
137
  base_image: str = None
136
138
  "Base image"
137
139
 
140
+ python_version: str = None
141
+ "Python version"
142
+
138
143
  requirements: list = None
139
144
  "Requirements list, as used by the runtime"
@@ -0,0 +1,81 @@
1
+ from __future__ import annotations
2
+
3
+ from digitalhub_ml.entities.runs.spec import RunParamsMl, RunSpecMl
4
+
5
+
6
+ class RunSpecPython(RunSpecMl):
7
+ """Run Python specification."""
8
+
9
+ def __init__(
10
+ self,
11
+ task: str,
12
+ local_execution: bool = False,
13
+ **kwargs,
14
+ ) -> None:
15
+ """
16
+ Constructor.
17
+ """
18
+ super().__init__(task, local_execution)
19
+
20
+ self.source = kwargs.get("source")
21
+ self.image = kwargs.get("image")
22
+ self.base_image = kwargs.get("base_image")
23
+ self.python_version = kwargs.get("python_version")
24
+ self.requirements = kwargs.get("requirements")
25
+
26
+ self.function = kwargs.get("function")
27
+ self.node_selector = kwargs.get("node_selector")
28
+ self.volumes = kwargs.get("volumes")
29
+ self.resources = kwargs.get("resources")
30
+ self.affinity = kwargs.get("affinity")
31
+ self.tolerations = kwargs.get("tolerations")
32
+ self.env = kwargs.get("env")
33
+ self.secrets = kwargs.get("secrets")
34
+ self.backoff_limit = kwargs.get("backoff_limit")
35
+ self.schedule = kwargs.get("schedule")
36
+ self.replicas = kwargs.get("replicas")
37
+
38
+ # Task job
39
+
40
+ # Task build
41
+ self.instructions = kwargs.get("instructions")
42
+
43
+ self.inputs = kwargs.get("inputs")
44
+ self.outputs = kwargs.get("outputs")
45
+ self.parameters = kwargs.get("parameters")
46
+
47
+
48
+ class RunParamsPython(RunParamsMl):
49
+ """Run Python parameters."""
50
+
51
+ # Function parameters
52
+ source: dict = None
53
+ image: str = None
54
+ base_image: str = None
55
+ python_version: str = None
56
+ requirements: list = None
57
+
58
+ # Task parameters
59
+ function: str = None
60
+ node_selector: list[dict] = None
61
+ volumes: list[dict] = None
62
+ resources: list[dict] = None
63
+ affinity: dict = None
64
+ tolerations: list[dict] = None
65
+ env: list[dict] = None
66
+ secrets: list[str] = None
67
+
68
+ # Task job
69
+ backoff_limit: int = None
70
+
71
+ # Task serve
72
+ service_type: str = None
73
+ replicas: int = None
74
+
75
+ # Task build
76
+ instructions: list[str] = None
77
+
78
+ # Run parameters
79
+ inputs: dict = None
80
+ outputs: dict = None
81
+ parameters: dict = None
@@ -3,8 +3,9 @@ Task Python specification module.
3
3
  """
4
4
  from __future__ import annotations
5
5
 
6
+ from typing import Literal
7
+
6
8
  from digitalhub_core.entities.tasks.spec import TaskParamsK8s, TaskSpecK8s
7
- from digitalhub_runtime_python.entities.tasks.models import ContextRef, ContextSource
8
9
 
9
10
 
10
11
  class TaskSpecJob(TaskSpecK8s):
@@ -21,7 +22,6 @@ class TaskSpecJob(TaskSpecK8s):
21
22
  super().__init__(function, **kwargs)
22
23
 
23
24
  self.backoff_limit = kwargs.get("backoff_limit")
24
- self.schedule = kwargs.get("schedule")
25
25
 
26
26
 
27
27
  class TaskParamsJob(TaskParamsK8s):
@@ -29,6 +29,9 @@ class TaskParamsJob(TaskParamsK8s):
29
29
  TaskParamsJob model.
30
30
  """
31
31
 
32
+ backoff_limit: int = None
33
+ """Backoff limit."""
34
+
32
35
 
33
36
  class TaskSpecBuild(TaskSpecK8s):
34
37
  """Task Build specification."""
@@ -36,8 +39,6 @@ class TaskSpecBuild(TaskSpecK8s):
36
39
  def __init__(
37
40
  self,
38
41
  function: str,
39
- context_refs: list | None = None,
40
- context_sources: list | None = None,
41
42
  instructions: list | None = None,
42
43
  **kwargs,
43
44
  ) -> None:
@@ -46,8 +47,6 @@ class TaskSpecBuild(TaskSpecK8s):
46
47
  """
47
48
  super().__init__(function, **kwargs)
48
49
 
49
- self.context_refs = context_refs
50
- self.context_sources = context_sources
51
50
  self.instructions = instructions
52
51
 
53
52
 
@@ -56,12 +55,6 @@ class TaskParamsBuild(TaskParamsK8s):
56
55
  TaskParamsBuild model.
57
56
  """
58
57
 
59
- context_refs: list[ContextRef] = None
60
- """Context references."""
61
-
62
- context_sources: list[ContextSource] = None
63
- """Context sources."""
64
-
65
58
  instructions: list[str] = None
66
59
  """Build instructions."""
67
60
 
@@ -69,8 +62,26 @@ class TaskParamsBuild(TaskParamsK8s):
69
62
  class TaskSpecServe(TaskSpecK8s):
70
63
  """Task Serve specification."""
71
64
 
65
+ def __init__(
66
+ self,
67
+ function: str,
68
+ replicas: int | None = None,
69
+ service_type: str | None = None,
70
+ **kwargs,
71
+ ) -> None:
72
+ """
73
+ Constructor.
74
+ """
75
+ super().__init__(function, **kwargs)
76
+
77
+ self.replicas = replicas
78
+ self.service_type = service_type
79
+
72
80
 
73
81
  class TaskParamsServe(TaskParamsK8s):
74
82
  """
75
83
  TaskParamsServe model.
76
84
  """
85
+
86
+ replicas: int = None
87
+ service_type: Literal["ClusterIP", "NodePort", "LoadBalancer"] = "NodePort"
@@ -70,6 +70,9 @@ class RuntimePython(Runtime):
70
70
  LOGGER.info("Validating task.")
71
71
  self._validate_task(run)
72
72
 
73
+ LOGGER.info("Validating run.")
74
+ self._validate_run(run)
75
+
73
76
  LOGGER.info("Starting task.")
74
77
  spec = run.get("spec")
75
78
  project = run.get("project")
@@ -111,6 +114,27 @@ class RuntimePython(Runtime):
111
114
  """
112
115
  raise NotImplementedError
113
116
 
117
+ @staticmethod
118
+ def _validate_run(run: dict) -> None:
119
+ """
120
+ Check if run is locally allowed.
121
+
122
+ Parameters
123
+ ----------
124
+ run : dict
125
+ Run object dictionary.
126
+
127
+ Returns
128
+ -------
129
+ None
130
+ """
131
+ task_kind = run["spec"]["task"].split(":")[0]
132
+ local_execution = run["spec"]["local_execution"]
133
+ if task_kind != "python+job" and local_execution:
134
+ msg = f"Local execution not allowed for task kind {task_kind}."
135
+ LOGGER.exception(msg)
136
+ raise RuntimeError(msg)
137
+
114
138
  ####################
115
139
  # Configuration
116
140
  ####################
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: digitalhub-runtime-python
3
- Version: 0.5.0b11
3
+ Version: 0.6.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
@@ -228,6 +228,6 @@ Classifier: Programming Language :: Python :: 3.10
228
228
  Requires-Python: >=3.9
229
229
  Description-Content-Type: text/markdown
230
230
  License-File: LICENSE.txt
231
- Requires-Dist: digitalhub[ml]<0.6,~=0.5.0b
231
+ Requires-Dist: digitalhub[ml]<0.7,~=0.6.0b
232
232
 
233
233
  # SDK for DHCore
@@ -0,0 +1 @@
1
+ digitalhub[ml]<0.7,~=0.6.0b
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "digitalhub-runtime-python"
7
- version = "0.5.0b11"
7
+ version = "0.6.0b0"
8
8
  description = "Python runtime for DHCore"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -20,7 +20,7 @@ classifiers = [
20
20
  keywords = ["data", "dataops", "kubernetes"]
21
21
  requires-python = ">=3.9"
22
22
  dependencies = [
23
- "digitalhub[ml]~=0.5.0b, <0.6",
23
+ "digitalhub[ml]~=0.6.0b, <0.7",
24
24
  ]
25
25
 
26
26
  [project.urls]
@@ -39,7 +39,7 @@ line-length = 120
39
39
  convention = "numpy"
40
40
 
41
41
  [tool.bumpver]
42
- current_version = "0.5.0b11"
42
+ current_version = "0.6.0b0"
43
43
  version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]"
44
44
  commit_message = "Bump version {old_version} -> {new_version}"
45
45
  commit = false
@@ -1,53 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from digitalhub_ml.entities.runs.spec import RunParamsMl, RunSpecMl
4
-
5
-
6
- class RunSpecPython(RunSpecMl):
7
- """Run Python specification."""
8
-
9
- def __init__(
10
- self,
11
- task: str,
12
- inputs: dict | None = None,
13
- outputs: dict | None = None,
14
- parameters: dict | None = None,
15
- values: list | None = None,
16
- local_execution: bool = False,
17
- **kwargs,
18
- ) -> None:
19
- """
20
- Constructor.
21
- """
22
- super().__init__(task, inputs, outputs, parameters, values, local_execution)
23
-
24
- # Set function and task parameters
25
- self._any_setter(**kwargs)
26
-
27
-
28
- class RunParamsPython(RunParamsMl):
29
- """Run Python parameters."""
30
-
31
- # Function parameters
32
- source: dict = None
33
- image: str = None
34
- base_image: str = None
35
- requirements: list = None
36
-
37
- # Task parameters
38
- function: str = None
39
- node_selector: list[dict] = None
40
- volumes: list[dict] = None
41
- resources: list[dict] = None
42
- affinity: dict = None
43
- tolerations: list[dict] = None
44
- env: list[dict] = None
45
- secrets: list[str] = None
46
- backoff_limit: int = None
47
- schedule: str = None
48
- replicas: int = None
49
-
50
- # Task build
51
- context_refs: list[dict] = None
52
- context_sources: list[dict] = None
53
- instructions: list[str] = None
@@ -1 +0,0 @@
1
- digitalhub[ml]<0.6,~=0.5.0b