digitalhub 0.8.0b3__py3-none-any.whl → 0.8.0b4__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.

Potentially problematic release.


This version of digitalhub might be problematic. Click here for more details.

Files changed (80) hide show
  1. digitalhub/__init__.py +3 -2
  2. digitalhub/client/dhcore/client.py +6 -1
  3. digitalhub/context/builder.py +1 -1
  4. digitalhub/context/context.py +1 -1
  5. digitalhub/entities/_base/entity/entity.py +2 -28
  6. digitalhub/entities/_base/unversioned/builder.py +66 -0
  7. digitalhub/entities/_base/unversioned/entity.py +0 -38
  8. digitalhub/entities/_base/versioned/builder.py +68 -0
  9. digitalhub/entities/_base/versioned/entity.py +0 -41
  10. digitalhub/entities/_builders/entity.py +37 -32
  11. digitalhub/entities/_builders/metadata.py +3 -10
  12. digitalhub/entities/_builders/spec.py +11 -21
  13. digitalhub/entities/_builders/status.py +8 -18
  14. digitalhub/entities/_builders/uuid.py +4 -11
  15. digitalhub/entities/artifact/_base/builder.py +86 -0
  16. digitalhub/entities/artifact/artifact/builder.py +18 -0
  17. digitalhub/entities/artifact/builder.py +15 -97
  18. digitalhub/entities/artifact/crud.py +1 -1
  19. digitalhub/entities/builders.py +63 -0
  20. digitalhub/entities/dataitem/_base/builder.py +86 -0
  21. digitalhub/entities/dataitem/builder.py +15 -108
  22. digitalhub/entities/dataitem/crud.py +3 -3
  23. digitalhub/entities/dataitem/dataitem/builder.py +18 -0
  24. digitalhub/entities/dataitem/iceberg/builder.py +18 -0
  25. digitalhub/entities/dataitem/table/builder.py +18 -0
  26. digitalhub/entities/function/_base/builder.py +78 -0
  27. digitalhub/entities/function/_base/entity.py +2 -2
  28. digitalhub/entities/function/builder.py +22 -57
  29. digitalhub/entities/function/crud.py +1 -1
  30. digitalhub/entities/model/_base/builder.py +86 -0
  31. digitalhub/entities/model/builder.py +15 -116
  32. digitalhub/entities/model/crud.py +1 -1
  33. digitalhub/entities/model/huggingface/builder.py +18 -0
  34. digitalhub/entities/model/mlflow/builder.py +18 -0
  35. digitalhub/entities/model/model/builder.py +18 -0
  36. digitalhub/entities/model/sklearn/builder.py +18 -0
  37. digitalhub/entities/project/_base/builder.py +128 -0
  38. digitalhub/entities/project/{project → _base}/entity.py +9 -51
  39. digitalhub/entities/project/builder.py +20 -51
  40. digitalhub/entities/project/crud.py +1 -1
  41. digitalhub/entities/run/_base/builder.py +73 -0
  42. digitalhub/entities/run/_base/entity.py +6 -149
  43. digitalhub/entities/run/builder.py +21 -47
  44. digitalhub/entities/run/crud.py +1 -1
  45. digitalhub/entities/secret/_base/builder.py +81 -0
  46. digitalhub/entities/secret/{secret → _base}/entity.py +2 -2
  47. digitalhub/entities/secret/builder.py +20 -62
  48. digitalhub/entities/secret/crud.py +2 -2
  49. digitalhub/entities/task/_base/builder.py +76 -0
  50. digitalhub/entities/task/builder.py +21 -44
  51. digitalhub/entities/task/crud.py +1 -1
  52. digitalhub/entities/workflow/_base/builder.py +78 -0
  53. digitalhub/entities/workflow/_base/entity.py +2 -2
  54. digitalhub/entities/workflow/builder.py +20 -60
  55. digitalhub/entities/workflow/crud.py +1 -1
  56. digitalhub/factory/factory.py +204 -0
  57. digitalhub/factory/utils.py +90 -0
  58. digitalhub/runtimes/builder.py +24 -41
  59. digitalhub/runtimes/kind_registry.py +14 -0
  60. digitalhub/runtimes/utils.py +28 -0
  61. digitalhub/utils/exceptions.py +6 -0
  62. digitalhub/utils/generic_utils.py +1 -1
  63. {digitalhub-0.8.0b3.dist-info → digitalhub-0.8.0b4.dist-info}/METADATA +1 -1
  64. {digitalhub-0.8.0b3.dist-info → digitalhub-0.8.0b4.dist-info}/RECORD +75 -57
  65. digitalhub/entities/_builders/factory.py +0 -44
  66. digitalhub/entities/registries.py +0 -48
  67. digitalhub/registry/models.py +0 -87
  68. digitalhub/registry/registry.py +0 -74
  69. digitalhub/registry/utils.py +0 -151
  70. /digitalhub/entities/project/{project → _base}/__init__.py +0 -0
  71. /digitalhub/entities/project/{project → _base}/spec.py +0 -0
  72. /digitalhub/entities/project/{project → _base}/status.py +0 -0
  73. /digitalhub/entities/secret/{secret → _base}/__init__.py +0 -0
  74. /digitalhub/entities/secret/{secret → _base}/spec.py +0 -0
  75. /digitalhub/entities/secret/{secret → _base}/status.py +0 -0
  76. /digitalhub/{registry → factory}/__init__.py +0 -0
  77. /digitalhub/runtimes/{base.py → _base.py} +0 -0
  78. {digitalhub-0.8.0b3.dist-info → digitalhub-0.8.0b4.dist-info}/LICENSE.txt +0 -0
  79. {digitalhub-0.8.0b3.dist-info → digitalhub-0.8.0b4.dist-info}/WHEEL +0 -0
  80. {digitalhub-0.8.0b3.dist-info → digitalhub-0.8.0b4.dist-info}/top_level.txt +0 -0
@@ -8,8 +8,8 @@ from digitalhub.entities.utils.entity_types import EntityTypes
8
8
 
9
9
  if typing.TYPE_CHECKING:
10
10
  from digitalhub.entities._base.entity.metadata import Metadata
11
- from digitalhub.entities.secret.secret.spec import SecretSpec
12
- from digitalhub.entities.secret.secret.status import SecretStatus
11
+ from digitalhub.entities.secret._base.spec import SecretSpec
12
+ from digitalhub.entities.secret._base.status import SecretStatus
13
13
 
14
14
 
15
15
  class Secret(VersionedEntity):
@@ -1,79 +1,33 @@
1
1
  from __future__ import annotations
2
2
 
3
- from digitalhub.entities._builders.metadata import build_metadata
4
- from digitalhub.entities._builders.name import build_name
5
- from digitalhub.entities._builders.spec import build_spec
6
- from digitalhub.entities._builders.status import build_status
7
- from digitalhub.entities._builders.uuid import build_uuid
8
- from digitalhub.entities.secret.secret.entity import Secret
3
+ import typing
9
4
 
5
+ from digitalhub.factory.factory import factory
6
+ from digitalhub.utils.exceptions import BuilderError
10
7
 
11
- def secret_from_parameters(
12
- project: str,
13
- name: str,
14
- kind: str,
15
- uuid: str | None = None,
16
- description: str | None = None,
17
- labels: list[str] | None = None,
18
- embedded: bool = True,
19
- **kwargs,
20
- ) -> Secret:
8
+ if typing.TYPE_CHECKING:
9
+ from digitalhub.entities.secret._base.entity import Secret
10
+
11
+
12
+ def secret_from_parameters(**kwargs) -> Secret:
21
13
  """
22
14
  Create a new object.
23
15
 
24
16
  Parameters
25
17
  ----------
26
- project : str
27
- Project name.
28
- name : str
29
- Object name.
30
- kind : str
31
- Kind the object.
32
- uuid : str
33
- ID of the object (UUID4, e.g. 40f25c4b-d26b-4221-b048-9527aff291e2).
34
- labels : list[str]
35
- List of labels.
36
- description : str
37
- Description of the object (human readable).
38
- embedded : bool
39
- Flag to determine if object spec must be embedded in project spec.
40
- **kwargs : dict
41
- Spec keyword arguments.
18
+ **kwargs
19
+ Keyword arguments.
42
20
 
43
21
  Returns
44
22
  -------
45
23
  Secret
46
24
  Object instance.
47
25
  """
48
- name = build_name(name)
49
- uuid = build_uuid(uuid)
50
- metadata = build_metadata(
51
- kind,
52
- project=project,
53
- name=name,
54
- version=uuid,
55
- description=description,
56
- labels=labels,
57
- embedded=embedded,
58
- )
59
- path = f"kubernetes://dhcore-proj-secrets-{project}/{name}"
60
- provider = "kubernetes"
61
- spec = build_spec(
62
- kind,
63
- path=path,
64
- provider=provider,
65
- **kwargs,
66
- )
67
- status = build_status(kind)
68
- return Secret(
69
- project=project,
70
- name=name,
71
- uuid=uuid,
72
- kind=kind,
73
- metadata=metadata,
74
- spec=spec,
75
- status=status,
76
- )
26
+ try:
27
+ kind = kwargs["kind"]
28
+ except KeyError:
29
+ raise BuilderError("Missing 'kind' parameter.")
30
+ return factory.build_entity_from_params(kind, **kwargs)
77
31
 
78
32
 
79
33
  def secret_from_dict(obj: dict) -> Secret:
@@ -90,4 +44,8 @@ def secret_from_dict(obj: dict) -> Secret:
90
44
  Secret
91
45
  Object instance.
92
46
  """
93
- return Secret.from_dict(obj)
47
+ try:
48
+ kind = obj["kind"]
49
+ except KeyError:
50
+ raise BuilderError("Missing 'kind' parameter.")
51
+ return factory.build_entity_from_dict(kind, obj)
@@ -15,7 +15,7 @@ from digitalhub.utils.exceptions import EntityAlreadyExistsError, EntityNotExist
15
15
  from digitalhub.utils.io_utils import read_yaml
16
16
 
17
17
  if typing.TYPE_CHECKING:
18
- from digitalhub.entities.secret.secret.entity import Secret
18
+ from digitalhub.entities.secret._base.entity import Secret
19
19
 
20
20
 
21
21
  ENTITY_TYPE = EntityTypes.SECRET.value
@@ -41,7 +41,7 @@ def new_secret(
41
41
  name : str
42
42
  Object name.
43
43
  uuid : str
44
- ID of the object (UUID4, e.g. 40f25c4b-d26b-4221-b048-9527aff291e2).
44
+ ID of the object.
45
45
  description : str
46
46
  Description of the object (human readable).
47
47
  labels : list[str]
@@ -0,0 +1,76 @@
1
+ from __future__ import annotations
2
+
3
+ import typing
4
+
5
+ from digitalhub.entities._base.unversioned.builder import UnversionedBuilder
6
+ from digitalhub.entities.utils.entity_types import EntityTypes
7
+ from digitalhub.utils.exceptions import BuilderError
8
+
9
+ if typing.TYPE_CHECKING:
10
+ from digitalhub.entities.task._base.entity import Task
11
+
12
+
13
+ class TaskBuilder(UnversionedBuilder):
14
+ """
15
+ Task builder.
16
+ """
17
+
18
+ ACTION: str = None
19
+ ENTITY_TYPE = EntityTypes.TASK.value
20
+
21
+ def __init__(self) -> None:
22
+ super().__init__()
23
+ if self.ACTION is None:
24
+ raise BuilderError("ACTION must be set")
25
+
26
+ def build(
27
+ self,
28
+ project: str,
29
+ kind: str,
30
+ uuid: str | None = None,
31
+ labels: list[str] | None = None,
32
+ function: str | None = None,
33
+ **kwargs,
34
+ ) -> Task:
35
+ """
36
+ Create a new object.
37
+
38
+ Parameters
39
+ ----------
40
+ project : str
41
+ Project name.
42
+ kind : str
43
+ Kind the object.
44
+ uuid : str
45
+ ID of the object.
46
+ labels : list[str]
47
+ List of labels.
48
+ function : str
49
+ Name of the executable associated with the task.
50
+ **kwargs : dict
51
+ Spec keyword arguments.
52
+
53
+ Returns
54
+ -------
55
+ Task
56
+ Object instance.
57
+ """
58
+ uuid = self.build_uuid(uuid)
59
+ metadata = self.build_metadata(
60
+ project=project,
61
+ name=uuid,
62
+ labels=labels,
63
+ )
64
+ spec = self.build_spec(
65
+ function=function,
66
+ **kwargs,
67
+ )
68
+ status = self.build_status()
69
+ return self.build_entity(
70
+ project=project,
71
+ uuid=uuid,
72
+ kind=kind,
73
+ metadata=metadata,
74
+ spec=spec,
75
+ status=status,
76
+ )
@@ -1,60 +1,33 @@
1
1
  from __future__ import annotations
2
2
 
3
- from digitalhub.entities._builders.metadata import build_metadata
4
- from digitalhub.entities._builders.spec import build_spec
5
- from digitalhub.entities._builders.status import build_status
6
- from digitalhub.entities._builders.uuid import build_uuid
7
- from digitalhub.entities.task._base.entity import Task
3
+ import typing
8
4
 
5
+ from digitalhub.factory.factory import factory
6
+ from digitalhub.utils.exceptions import BuilderError
9
7
 
10
- def task_from_parameters(
11
- project: str,
12
- kind: str,
13
- uuid: str | None = None,
14
- labels: list[str] | None = None,
15
- function: str | None = None,
16
- **kwargs,
17
- ) -> Task:
8
+ if typing.TYPE_CHECKING:
9
+ from digitalhub.entities.task._base.entity import Task
10
+
11
+
12
+ def task_from_parameters(**kwargs) -> Task:
18
13
  """
19
14
  Create a new object.
20
15
 
21
16
  Parameters
22
17
  ----------
23
- project : str
24
- Project name.
25
- kind : str
26
- Kind the object.
27
- uuid : str
28
- ID of the object (UUID4, e.g. 40f25c4b-d26b-4221-b048-9527aff291e2).
29
- labels : list[str]
30
- List of labels.
31
- function : str
32
- Name of the executable associated with the task.
33
- **kwargs : dict
34
- Spec keyword arguments.
18
+ **kwargs
19
+ Keyword arguments.
35
20
 
36
21
  Returns
37
22
  -------
38
23
  Task
39
24
  Object instance.
40
25
  """
41
- uuid = build_uuid(uuid)
42
- metadata = build_metadata(
43
- kind=kind,
44
- project=project,
45
- name=uuid,
46
- labels=labels,
47
- )
48
- spec = build_spec(kind, function=function, **kwargs)
49
- status = build_status(kind)
50
- return Task(
51
- project=project,
52
- uuid=uuid,
53
- kind=kind,
54
- metadata=metadata,
55
- spec=spec,
56
- status=status,
57
- )
26
+ try:
27
+ kind = kwargs["kind"]
28
+ except KeyError:
29
+ raise BuilderError("Missing 'kind' parameter.")
30
+ return factory.build_entity_from_params(kind, **kwargs)
58
31
 
59
32
 
60
33
  def task_from_dict(obj: dict) -> Task:
@@ -64,11 +37,15 @@ def task_from_dict(obj: dict) -> Task:
64
37
  Parameters
65
38
  ----------
66
39
  obj : dict
67
- Dictionary representation of Task.
40
+ Dictionary to create object from.
68
41
 
69
42
  Returns
70
43
  -------
71
44
  Task
72
45
  Object instance.
73
46
  """
74
- return Task.from_dict(obj)
47
+ try:
48
+ kind = obj["kind"]
49
+ except KeyError:
50
+ raise BuilderError("Missing 'kind' parameter.")
51
+ return factory.build_entity_from_dict(kind, obj)
@@ -34,7 +34,7 @@ def new_task(
34
34
  kind : str
35
35
  Kind the object.
36
36
  uuid : str
37
- ID of the object (UUID4, e.g. 40f25c4b-d26b-4221-b048-9527aff291e2).
37
+ ID of the object.
38
38
  labels : list[str]
39
39
  List of labels.
40
40
  function : str
@@ -0,0 +1,78 @@
1
+ from __future__ import annotations
2
+
3
+ import typing
4
+
5
+ from digitalhub.entities._base.versioned.builder import VersionedBuilder
6
+ from digitalhub.entities.utils.entity_types import EntityTypes
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from digitalhub.entities.workflow._base.entity import Workflow
10
+
11
+
12
+ class WorkflowBuilder(VersionedBuilder):
13
+ """
14
+ Workflow builder.
15
+ """
16
+
17
+ ENTITY_TYPE = EntityTypes.WORKFLOW.value
18
+
19
+ def build(
20
+ self,
21
+ kind: str,
22
+ project: str,
23
+ name: str,
24
+ uuid: str | None = None,
25
+ description: str | None = None,
26
+ labels: list[str] | None = None,
27
+ embedded: bool = True,
28
+ **kwargs,
29
+ ) -> Workflow:
30
+ """
31
+ Create a new object.
32
+
33
+ Parameters
34
+ ----------
35
+ project : str
36
+ Project name.
37
+ name : str
38
+ Object name.
39
+ kind : str
40
+ Kind the object.
41
+ uuid : str
42
+ ID of the object.
43
+ description : str
44
+ Description of the object (human readable).
45
+ labels : list[str]
46
+ List of labels.
47
+ embedded : bool
48
+ Flag to determine if object spec must be embedded in project spec.
49
+ **kwargs : dict
50
+ Spec keyword arguments.
51
+
52
+ Returns
53
+ -------
54
+ Workflow
55
+ Object instance.
56
+ """
57
+ name = self.build_name(name)
58
+ uuid = self.build_uuid(uuid)
59
+ metadata = self.build_metadata(
60
+ project=project,
61
+ name=name,
62
+ description=description,
63
+ labels=labels,
64
+ embedded=embedded,
65
+ )
66
+ spec = self.build_spec(
67
+ **kwargs,
68
+ )
69
+ status = self.build_status()
70
+ return self.build_entity(
71
+ project=project,
72
+ name=name,
73
+ uuid=uuid,
74
+ kind=kind,
75
+ metadata=metadata,
76
+ spec=spec,
77
+ status=status,
78
+ )
@@ -4,7 +4,7 @@ import typing
4
4
 
5
5
  from digitalhub.entities._base.executable.entity import ExecutableEntity
6
6
  from digitalhub.entities.utils.entity_types import EntityTypes
7
- from digitalhub.runtimes.builder import get_kind_registry
7
+ from digitalhub.runtimes.utils import get_kind_registry
8
8
  from digitalhub.utils.exceptions import BackendError
9
9
 
10
10
  if typing.TYPE_CHECKING:
@@ -61,7 +61,7 @@ class Workflow(ExecutableEntity):
61
61
  action = "pipeline"
62
62
 
63
63
  # Get kind registry
64
- kind_reg = get_kind_registry(self.kind)
64
+ kind_reg = get_kind_registry(self.kind, self.project)
65
65
 
66
66
  # Get task and run kind
67
67
  task_kind = kind_reg.get_task_kind_from_action(action=action)
@@ -1,77 +1,33 @@
1
1
  from __future__ import annotations
2
2
 
3
- from digitalhub.entities._builders.metadata import build_metadata
4
- from digitalhub.entities._builders.name import build_name
5
- from digitalhub.entities._builders.spec import build_spec
6
- from digitalhub.entities._builders.status import build_status
7
- from digitalhub.entities._builders.uuid import build_uuid
8
- from digitalhub.entities.workflow._base.entity import Workflow
3
+ import typing
9
4
 
5
+ from digitalhub.factory.factory import factory
6
+ from digitalhub.utils.exceptions import BuilderError
10
7
 
11
- def workflow_from_parameters(
12
- project: str,
13
- name: str,
14
- kind: str,
15
- uuid: str | None = None,
16
- description: str | None = None,
17
- labels: list[str] | None = None,
18
- embedded: bool = True,
19
- **kwargs,
20
- ) -> Workflow:
8
+ if typing.TYPE_CHECKING:
9
+ from digitalhub.entities.workflow._base.entity import Workflow
10
+
11
+
12
+ def workflow_from_parameters(**kwargs) -> Workflow:
21
13
  """
22
14
  Create a new object.
23
15
 
24
16
  Parameters
25
17
  ----------
26
- project : str
27
- Project name.
28
- name : str
29
- Object name.
30
- kind : str
31
- Kind the object.
32
- uuid : str
33
- ID of the object (UUID4, e.g. 40f25c4b-d26b-4221-b048-9527aff291e2).
34
- labels : list[str]
35
- List of labels.
36
- description : str
37
- Description of the object (human readable).
38
- embedded : bool
39
- Flag to determine if object spec must be embedded in project spec.
40
- **kwargs : dict
41
- Spec keyword arguments.
18
+ **kwargs
19
+ Keyword arguments.
42
20
 
43
21
  Returns
44
22
  -------
45
23
  Workflow
46
24
  Object instance.
47
25
  """
48
- name = build_name(name)
49
- uuid = build_uuid(uuid)
50
- spec = build_spec(
51
- kind,
52
- **kwargs,
53
- )
54
- metadata = build_metadata(
55
- kind,
56
- project=project,
57
- name=name,
58
- version=uuid,
59
- description=description,
60
- labels=labels,
61
- embedded=embedded,
62
- )
63
- status = build_status(
64
- kind,
65
- )
66
- return Workflow(
67
- project=project,
68
- name=name,
69
- uuid=uuid,
70
- kind=kind,
71
- metadata=metadata,
72
- spec=spec,
73
- status=status,
74
- )
26
+ try:
27
+ kind = kwargs["kind"]
28
+ except KeyError:
29
+ raise BuilderError("Missing 'kind' parameter.")
30
+ return factory.build_entity_from_params(kind, **kwargs)
75
31
 
76
32
 
77
33
  def workflow_from_dict(obj: dict) -> Workflow:
@@ -88,4 +44,8 @@ def workflow_from_dict(obj: dict) -> Workflow:
88
44
  Workflow
89
45
  Object instance.
90
46
  """
91
- return Workflow.from_dict(obj)
47
+ try:
48
+ kind = obj["kind"]
49
+ except KeyError:
50
+ raise BuilderError("Missing 'kind' parameter.")
51
+ return factory.build_entity_from_dict(kind, obj)
@@ -41,7 +41,7 @@ def new_workflow(
41
41
  name : str
42
42
  Object name.
43
43
  uuid : str
44
- ID of the object (UUID4, e.g. 40f25c4b-d26b-4221-b048-9527aff291e2).
44
+ ID of the object.
45
45
  description : str
46
46
  Description of the object (human readable).
47
47
  labels : list[str]