digitalhub 0.8.0b6__py3-none-any.whl → 0.8.0b10__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 (64) hide show
  1. digitalhub/__init__.py +1 -1
  2. digitalhub/client/api.py +63 -0
  3. digitalhub/client/builder.py +0 -55
  4. digitalhub/client/dhcore/utils.py +1 -1
  5. digitalhub/context/api.py +93 -0
  6. digitalhub/context/builder.py +0 -84
  7. digitalhub/datastores/_base/datastore.py +2 -2
  8. digitalhub/datastores/api.py +37 -0
  9. digitalhub/datastores/builder.py +7 -31
  10. digitalhub/datastores/local/datastore.py +9 -1
  11. digitalhub/datastores/remote/datastore.py +8 -0
  12. digitalhub/datastores/s3/datastore.py +9 -1
  13. digitalhub/datastores/sql/datastore.py +9 -1
  14. digitalhub/entities/_base/api_utils.py +620 -0
  15. digitalhub/entities/_base/context/entity.py +2 -2
  16. digitalhub/entities/_base/crud.py +204 -408
  17. digitalhub/entities/_base/entity/entity.py +1 -1
  18. digitalhub/entities/_base/entity/status.py +12 -1
  19. digitalhub/entities/_base/executable/entity.py +7 -6
  20. digitalhub/entities/_base/material/entity.py +2 -2
  21. digitalhub/entities/artifact/crud.py +16 -42
  22. digitalhub/entities/dataitem/crud.py +19 -45
  23. digitalhub/entities/dataitem/table/entity.py +1 -1
  24. digitalhub/entities/function/crud.py +13 -39
  25. digitalhub/entities/model/crud.py +15 -42
  26. digitalhub/entities/project/_base/entity.py +65 -38
  27. digitalhub/entities/project/crud.py +8 -8
  28. digitalhub/entities/run/_base/entity.py +1 -14
  29. digitalhub/entities/run/_base/spec.py +0 -103
  30. digitalhub/entities/run/_base/status.py +0 -105
  31. digitalhub/entities/run/crud.py +17 -30
  32. digitalhub/entities/secret/_base/builder.py +1 -1
  33. digitalhub/entities/secret/_base/entity.py +1 -1
  34. digitalhub/entities/secret/crud.py +15 -27
  35. digitalhub/entities/task/_base/entity.py +3 -2
  36. digitalhub/entities/task/crud.py +17 -30
  37. digitalhub/entities/utils/utils.py +18 -0
  38. digitalhub/entities/workflow/crud.py +13 -39
  39. digitalhub/factory/api.py +31 -25
  40. digitalhub/factory/factory.py +7 -5
  41. digitalhub/readers/_base/builder.py +26 -0
  42. digitalhub/readers/api.py +80 -0
  43. digitalhub/readers/factory.py +133 -0
  44. digitalhub/readers/pandas/builder.py +29 -0
  45. digitalhub/readers/pandas/{readers.py → reader.py} +1 -1
  46. digitalhub/stores/api.py +54 -0
  47. digitalhub/stores/builder.py +0 -46
  48. {digitalhub-0.8.0b6.dist-info → digitalhub-0.8.0b10.dist-info}/METADATA +1 -1
  49. {digitalhub-0.8.0b6.dist-info → digitalhub-0.8.0b10.dist-info}/RECORD +53 -55
  50. digitalhub/entities/artifact/builder.py +0 -51
  51. digitalhub/entities/dataitem/builder.py +0 -51
  52. digitalhub/entities/function/builder.py +0 -51
  53. digitalhub/entities/model/builder.py +0 -51
  54. digitalhub/entities/project/builder.py +0 -51
  55. digitalhub/entities/run/builder.py +0 -51
  56. digitalhub/entities/secret/builder.py +0 -51
  57. digitalhub/entities/task/builder.py +0 -51
  58. digitalhub/entities/workflow/builder.py +0 -51
  59. digitalhub/readers/builder.py +0 -54
  60. digitalhub/readers/registry.py +0 -15
  61. /digitalhub/readers/_base/{readers.py → reader.py} +0 -0
  62. {digitalhub-0.8.0b6.dist-info → digitalhub-0.8.0b10.dist-info}/LICENSE.txt +0 -0
  63. {digitalhub-0.8.0b6.dist-info → digitalhub-0.8.0b10.dist-info}/WHEEL +0 -0
  64. {digitalhub-0.8.0b6.dist-info → digitalhub-0.8.0b10.dist-info}/top_level.txt +0 -0
digitalhub/__init__.py CHANGED
@@ -76,7 +76,7 @@ from digitalhub.client.dhcore.utils import refresh_token, set_dhcore_env
76
76
 
77
77
  # Register entities into registry
78
78
  from digitalhub.factory.utils import register_entities, register_runtimes_entities
79
- from digitalhub.stores.builder import set_store
79
+ from digitalhub.stores.api import set_store
80
80
 
81
81
  register_entities()
82
82
  register_runtimes_entities()
@@ -0,0 +1,63 @@
1
+ from __future__ import annotations
2
+
3
+ import typing
4
+
5
+ from digitalhub.client.builder import client_builder
6
+
7
+ if typing.TYPE_CHECKING:
8
+ from digitalhub.client._base.client import Client
9
+
10
+
11
+ def check_client_exists(local: bool = False) -> bool:
12
+ """
13
+ Check if client exists.
14
+
15
+ Parameters
16
+ ----------
17
+ local : bool
18
+ Check client existence by local.
19
+
20
+ Returns
21
+ -------
22
+ bool
23
+ True if client exists, False otherwise.
24
+ """
25
+ if local:
26
+ return client_builder._local is not None
27
+ return client_builder._dhcore is not None
28
+
29
+
30
+ def build_client(local: bool = False, config: dict | None = None) -> None:
31
+ """
32
+ Wrapper around ClientBuilder.build.
33
+
34
+ Parameters
35
+ ----------
36
+ local : bool
37
+ Whether to create a local client or not.
38
+ config : dict
39
+ DHCore environment configuration.
40
+
41
+ Returns
42
+ -------
43
+ Client
44
+ The client instance.
45
+ """
46
+ client_builder.build(local, config)
47
+
48
+
49
+ def get_client(local: bool = False) -> Client:
50
+ """
51
+ Wrapper around ClientBuilder.build.
52
+
53
+ Parameters
54
+ ----------
55
+ local : bool
56
+ Whether to create a local client or not.
57
+
58
+ Returns
59
+ -------
60
+ Client
61
+ The client instance.
62
+ """
63
+ return client_builder.build(local)
@@ -47,59 +47,4 @@ class ClientBuilder:
47
47
  return self._dhcore
48
48
 
49
49
 
50
- def get_client(local: bool = False) -> Client:
51
- """
52
- Wrapper around ClientBuilder.build.
53
-
54
- Parameters
55
- ----------
56
- local : bool
57
- Whether to create a local client or not.
58
-
59
- Returns
60
- -------
61
- Client
62
- The client instance.
63
- """
64
- return client_builder.build(local)
65
-
66
-
67
- def build_client(local: bool = False, config: dict | None = None) -> None:
68
- """
69
- Wrapper around ClientBuilder.build.
70
-
71
- Parameters
72
- ----------
73
- local : bool
74
- Whether to create a local client or not.
75
- config : dict
76
- DHCore environment configuration.
77
-
78
- Returns
79
- -------
80
- Client
81
- The client instance.
82
- """
83
- client_builder.build(local, config)
84
-
85
-
86
- def check_client_exists(local: bool = False) -> bool:
87
- """
88
- Check if client exists.
89
-
90
- Parameters
91
- ----------
92
- local : bool
93
- Check client existence by local.
94
-
95
- Returns
96
- -------
97
- bool
98
- True if client exists, False otherwise.
99
- """
100
- if local:
101
- return client_builder._local is not None
102
- return client_builder._dhcore is not None
103
-
104
-
105
50
  client_builder = ClientBuilder()
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import os
4
4
  import typing
5
5
 
6
- from digitalhub.client.builder import check_client_exists, get_client
6
+ from digitalhub.client.api import check_client_exists, get_client
7
7
 
8
8
  if typing.TYPE_CHECKING:
9
9
  from digitalhub.client.dhcore.client import ClientDHCore
@@ -0,0 +1,93 @@
1
+ from __future__ import annotations
2
+
3
+ import typing
4
+
5
+ from digitalhub.context.builder import context_builder
6
+
7
+ if typing.TYPE_CHECKING:
8
+ from digitalhub.context.context import Context
9
+ from digitalhub.entities.project._base.entity import Project
10
+
11
+
12
+ def check_context(project: str) -> None:
13
+ """
14
+ Check if the given project is in the context.
15
+
16
+ Parameters
17
+ ----------
18
+ project : str
19
+ Project name.
20
+
21
+ Returns
22
+ -------
23
+ bool
24
+ True if the project is in the context, False otherwise.
25
+ """
26
+ if project not in context_builder._instances:
27
+ msg = f"Context missing. Set context by creating or importing a project named '{project}'."
28
+ raise RuntimeError(msg)
29
+
30
+
31
+ def set_context(project: Project) -> None:
32
+ """
33
+ Wrapper for ContextBuilder.build().
34
+
35
+ Parameters
36
+ ----------
37
+ project : Project
38
+ The project object used to set the current context.
39
+
40
+ Returns
41
+ -------
42
+ None
43
+ """
44
+ context_builder.build(project)
45
+
46
+
47
+ def get_context(project: str) -> Context:
48
+ """
49
+ Wrapper for ContextBuilder.get().
50
+
51
+ Parameters
52
+ ----------
53
+ project : str
54
+ Project name.
55
+
56
+ Returns
57
+ -------
58
+ Context
59
+ The context for the given project name.
60
+ """
61
+ return context_builder.get(project)
62
+
63
+
64
+ def set_context_object(context: Context) -> None:
65
+ """
66
+ Wrapper for ContextBuilder.set().
67
+
68
+ Parameters
69
+ ----------
70
+ context : Context
71
+ The context to set.
72
+
73
+ Returns
74
+ -------
75
+ None
76
+ """
77
+ context_builder.set(context)
78
+
79
+
80
+ def delete_context(project: str) -> None:
81
+ """
82
+ Wrapper for ContextBuilder.remove().
83
+
84
+ Parameters
85
+ ----------
86
+ project : str
87
+ Project name.
88
+
89
+ Returns
90
+ -------
91
+ None
92
+ """
93
+ context_builder.remove(project)
@@ -91,88 +91,4 @@ class ContextBuilder:
91
91
  self._instances[context.name] = context
92
92
 
93
93
 
94
- def set_context(project: Project) -> None:
95
- """
96
- Wrapper for ContextBuilder.build().
97
-
98
- Parameters
99
- ----------
100
- project : Project
101
- The project object used to set the current context.
102
-
103
- Returns
104
- -------
105
- None
106
- """
107
- context_builder.build(project)
108
-
109
-
110
- def set_context_object(context: Context) -> None:
111
- """
112
- Wrapper for ContextBuilder.set().
113
-
114
- Parameters
115
- ----------
116
- context : Context
117
- The context to set.
118
-
119
- Returns
120
- -------
121
- None
122
- """
123
- context_builder.set(context)
124
-
125
-
126
- def get_context(project: str) -> Context:
127
- """
128
- Wrapper for ContextBuilder.get().
129
-
130
- Parameters
131
- ----------
132
- project : str
133
- Project name.
134
-
135
- Returns
136
- -------
137
- Context
138
- The context for the given project name.
139
- """
140
- return context_builder.get(project)
141
-
142
-
143
- def delete_context(project: str) -> None:
144
- """
145
- Wrapper for ContextBuilder.remove().
146
-
147
- Parameters
148
- ----------
149
- project : str
150
- Project name.
151
-
152
- Returns
153
- -------
154
- None
155
- """
156
- context_builder.remove(project)
157
-
158
-
159
- def check_context(project: str) -> None:
160
- """
161
- Check if the given project is in the context.
162
-
163
- Parameters
164
- ----------
165
- project : str
166
- Project name.
167
-
168
- Returns
169
- -------
170
- bool
171
- True if the project is in the context, False otherwise.
172
- """
173
- if project not in context_builder._instances:
174
- msg = f"Context missing. Set context by creating or importing a project named '{project}'."
175
- raise RuntimeError(msg)
176
-
177
-
178
94
  context_builder = ContextBuilder()
@@ -4,7 +4,7 @@ import typing
4
4
  from abc import ABCMeta, abstractmethod
5
5
  from typing import Any
6
6
 
7
- from digitalhub.readers.builder import get_reader_by_engine
7
+ from digitalhub.readers.api import get_reader_by_engine
8
8
 
9
9
  if typing.TYPE_CHECKING:
10
10
  from digitalhub.stores._base.store import Store
@@ -32,7 +32,7 @@ class Datastore(metaclass=ABCMeta):
32
32
  self,
33
33
  path: str | list[str],
34
34
  extension: str,
35
- engine: str | None = "pandas",
35
+ engine: str | None = None,
36
36
  **kwargs,
37
37
  ) -> Any:
38
38
  """
@@ -0,0 +1,37 @@
1
+ from __future__ import annotations
2
+
3
+ import typing
4
+
5
+ from digitalhub.datastores.builder import builder
6
+
7
+ if typing.TYPE_CHECKING:
8
+ from digitalhub.datastores._base.datastore import Datastore
9
+
10
+
11
+ def get_datastore(uri: str) -> Datastore:
12
+ """
13
+ Get a datastore instance by URI.
14
+
15
+ Parameters
16
+ ----------
17
+ uri : str
18
+ URI to parse.
19
+
20
+ Returns
21
+ -------
22
+ Datastore
23
+ The datastore instance.
24
+ """
25
+ return builder.get(uri)
26
+
27
+
28
+ def get_default_datastore() -> Datastore:
29
+ """
30
+ Get the default datastore instance.
31
+
32
+ Returns
33
+ -------
34
+ Datastore
35
+ The default datastore instance.
36
+ """
37
+ return builder.default()
@@ -6,7 +6,7 @@ from digitalhub.datastores.local.datastore import LocalDatastore
6
6
  from digitalhub.datastores.remote.datastore import RemoteDatastore
7
7
  from digitalhub.datastores.s3.datastore import S3Datastore
8
8
  from digitalhub.datastores.sql.datastore import SqlDatastore
9
- from digitalhub.stores.builder import get_default_store, get_store
9
+ from digitalhub.stores.api import get_default_store, get_store
10
10
  from digitalhub.utils.uri_utils import map_uri_scheme
11
11
 
12
12
  if typing.TYPE_CHECKING:
@@ -14,7 +14,12 @@ if typing.TYPE_CHECKING:
14
14
  from digitalhub.stores._base.store import Store
15
15
 
16
16
 
17
- REGISTRY_DATASTORES = {"local": LocalDatastore, "remote": RemoteDatastore, "s3": S3Datastore, "sql": SqlDatastore}
17
+ REGISTRY_DATASTORES = {
18
+ "local": LocalDatastore,
19
+ "remote": RemoteDatastore,
20
+ "s3": S3Datastore,
21
+ "sql": SqlDatastore,
22
+ }
18
23
 
19
24
 
20
25
  class DatastoreBuilder:
@@ -103,32 +108,3 @@ class DatastoreBuilder:
103
108
 
104
109
 
105
110
  builder = DatastoreBuilder()
106
-
107
-
108
- def get_datastore(uri: str) -> Datastore:
109
- """
110
- Get a datastore instance by URI.
111
-
112
- Parameters
113
- ----------
114
- uri : str
115
- URI to parse.
116
-
117
- Returns
118
- -------
119
- Datastore
120
- The datastore instance.
121
- """
122
- return builder.get(uri)
123
-
124
-
125
- def get_default_datastore() -> Datastore:
126
- """
127
- Get the default datastore instance.
128
-
129
- Returns
130
- -------
131
- Datastore
132
- The default datastore instance.
133
- """
134
- return builder.default()
@@ -1,10 +1,14 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import typing
3
4
  from pathlib import Path
4
5
  from typing import Any
5
6
 
6
7
  from digitalhub.datastores._base.datastore import Datastore
7
- from digitalhub.readers.builder import get_reader_by_object
8
+ from digitalhub.readers.api import get_reader_by_object
9
+
10
+ if typing.TYPE_CHECKING:
11
+ from digitalhub.stores.local.store import LocalStore
8
12
 
9
13
 
10
14
  class LocalDatastore(Datastore):
@@ -12,6 +16,10 @@ class LocalDatastore(Datastore):
12
16
  Local Datastore class.
13
17
  """
14
18
 
19
+ def __init__(self, store: LocalStore, **kwargs) -> None:
20
+ super().__init__(store, **kwargs)
21
+ self.store: LocalStore
22
+
15
23
  def write_df(self, df: Any, dst: str, extension: str | None = None, **kwargs) -> str:
16
24
  """
17
25
  Method to write a dataframe to a file. Kwargs are passed to df.to_parquet().
@@ -1,15 +1,23 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import typing
3
4
  from typing import Any
4
5
 
5
6
  from digitalhub.datastores._base.datastore import Datastore
6
7
 
8
+ if typing.TYPE_CHECKING:
9
+ from digitalhub.stores.remote.store import RemoteStore
10
+
7
11
 
8
12
  class RemoteDatastore(Datastore):
9
13
  """
10
14
  Remote Datastore class.
11
15
  """
12
16
 
17
+ def __init__(self, store: RemoteStore, **kwargs) -> None:
18
+ super().__init__(store, **kwargs)
19
+ self.store: RemoteStore
20
+
13
21
  def write_df(self, df: Any, dst: str, extension: str | None = None, **kwargs) -> str:
14
22
  """
15
23
  Method to write a dataframe to a file. Note that this method is not implemented
@@ -1,10 +1,14 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import typing
3
4
  from io import BytesIO
4
5
  from typing import Any
5
6
 
6
7
  from digitalhub.datastores._base.datastore import Datastore
7
- from digitalhub.readers.builder import get_reader_by_object
8
+ from digitalhub.readers.api import get_reader_by_object
9
+
10
+ if typing.TYPE_CHECKING:
11
+ from digitalhub.stores.s3.store import S3Store
8
12
 
9
13
 
10
14
  class S3Datastore(Datastore):
@@ -12,6 +16,10 @@ class S3Datastore(Datastore):
12
16
  S3 Datastore class.
13
17
  """
14
18
 
19
+ def __init__(self, store: S3Store, **kwargs) -> None:
20
+ super().__init__(store, **kwargs)
21
+ self.store: S3Store
22
+
15
23
  def write_df(self, df: Any, dst: str, extension: str | None = None, **kwargs) -> str:
16
24
  """
17
25
  Write a dataframe to S3 based storage. Kwargs are passed to df.to_parquet().
@@ -1,9 +1,13 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import typing
3
4
  from typing import Any
4
5
 
5
6
  from digitalhub.datastores._base.datastore import Datastore
6
- from digitalhub.readers.builder import get_reader_by_object
7
+ from digitalhub.readers.api import get_reader_by_object
8
+
9
+ if typing.TYPE_CHECKING:
10
+ from digitalhub.stores.sql.store import SqlStore
7
11
 
8
12
 
9
13
  class SqlDatastore(Datastore):
@@ -11,6 +15,10 @@ class SqlDatastore(Datastore):
11
15
  Sql Datastore class.
12
16
  """
13
17
 
18
+ def __init__(self, store: SqlStore, **kwargs) -> None:
19
+ super().__init__(store, **kwargs)
20
+ self.store: SqlStore
21
+
14
22
  def write_df(self, df: Any, dst: str, extension: str | None = None, **kwargs) -> str:
15
23
  """
16
24
  Write a dataframe to a database. Kwargs are passed to df.to_sql().