digitalhub 0.14.0b5__py3-none-any.whl → 0.14.9__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.
Files changed (93) hide show
  1. digitalhub/__init__.py +2 -2
  2. digitalhub/context/api.py +43 -6
  3. digitalhub/context/builder.py +1 -1
  4. digitalhub/context/context.py +3 -6
  5. digitalhub/entities/_base/context/entity.py +0 -3
  6. digitalhub/entities/_base/executable/entity.py +29 -11
  7. digitalhub/entities/_base/material/entity.py +2 -2
  8. digitalhub/entities/_base/material/utils.py +0 -4
  9. digitalhub/entities/_commons/enums.py +1 -0
  10. digitalhub/entities/_commons/utils.py +19 -0
  11. digitalhub/entities/_processors/base/crud.py +15 -24
  12. digitalhub/entities/_processors/base/import_export.py +3 -7
  13. digitalhub/entities/_processors/base/processor.py +4 -7
  14. digitalhub/entities/_processors/base/special_ops.py +4 -8
  15. digitalhub/entities/_processors/context/crud.py +27 -29
  16. digitalhub/entities/_processors/context/import_export.py +7 -7
  17. digitalhub/entities/_processors/context/material.py +2 -2
  18. digitalhub/entities/_processors/context/special_ops.py +25 -25
  19. digitalhub/entities/_processors/utils.py +7 -116
  20. digitalhub/entities/artifact/crud.py +3 -3
  21. digitalhub/entities/artifact/utils.py +2 -2
  22. digitalhub/entities/builders.py +2 -0
  23. digitalhub/entities/dataitem/crud.py +3 -3
  24. digitalhub/entities/dataitem/utils.py +10 -14
  25. digitalhub/entities/function/_base/entity.py +0 -3
  26. digitalhub/entities/function/crud.py +3 -3
  27. digitalhub/entities/model/crud.py +3 -3
  28. digitalhub/entities/model/mlflow/utils.py +29 -20
  29. digitalhub/entities/model/utils.py +2 -2
  30. digitalhub/entities/project/_base/builder.py +0 -6
  31. digitalhub/entities/project/_base/entity.py +264 -114
  32. digitalhub/entities/project/_base/spec.py +4 -4
  33. digitalhub/entities/project/crud.py +16 -51
  34. digitalhub/entities/project/utils.py +7 -3
  35. digitalhub/entities/secret/crud.py +2 -2
  36. digitalhub/entities/task/_base/models.py +13 -16
  37. digitalhub/entities/trigger/crud.py +28 -9
  38. digitalhub/entities/workflow/_base/entity.py +0 -5
  39. digitalhub/entities/workflow/crud.py +3 -6
  40. digitalhub/stores/client/{dhcore/api_builder.py → api_builder.py} +2 -3
  41. digitalhub/stores/client/builder.py +20 -32
  42. digitalhub/stores/client/client.py +322 -0
  43. digitalhub/stores/client/{dhcore/configurator.py → configurator.py} +148 -195
  44. digitalhub/stores/client/{_base/enums.py → enums.py} +11 -0
  45. digitalhub/stores/client/header_manager.py +61 -0
  46. digitalhub/stores/client/http_handler.py +152 -0
  47. digitalhub/stores/client/{_base/key_builder.py → key_builder.py} +14 -14
  48. digitalhub/stores/client/{dhcore/params_builder.py → params_builder.py} +51 -12
  49. digitalhub/stores/client/response_processor.py +102 -0
  50. digitalhub/stores/client/utils.py +35 -0
  51. digitalhub/stores/{credentials → configurator}/api.py +5 -9
  52. digitalhub/stores/configurator/configurator.py +123 -0
  53. digitalhub/stores/{credentials → configurator}/enums.py +26 -10
  54. digitalhub/stores/configurator/handler.py +213 -0
  55. digitalhub/stores/{credentials → configurator}/ini_module.py +31 -6
  56. digitalhub/stores/data/_base/store.py +0 -4
  57. digitalhub/stores/data/api.py +4 -6
  58. digitalhub/stores/data/builder.py +6 -38
  59. digitalhub/stores/data/s3/configurator.py +30 -114
  60. digitalhub/stores/data/s3/store.py +9 -22
  61. digitalhub/stores/data/sql/configurator.py +49 -71
  62. digitalhub/stores/data/sql/store.py +26 -61
  63. digitalhub/utils/generic_utils.py +0 -12
  64. digitalhub/utils/git_utils.py +0 -8
  65. digitalhub/utils/io_utils.py +0 -8
  66. digitalhub/utils/store_utils.py +1 -1
  67. {digitalhub-0.14.0b5.dist-info → digitalhub-0.14.9.dist-info}/METADATA +3 -3
  68. {digitalhub-0.14.0b5.dist-info → digitalhub-0.14.9.dist-info}/RECORD +73 -86
  69. {digitalhub-0.14.0b5.dist-info → digitalhub-0.14.9.dist-info}/WHEEL +1 -1
  70. digitalhub/stores/client/_base/api_builder.py +0 -34
  71. digitalhub/stores/client/_base/client.py +0 -243
  72. digitalhub/stores/client/_base/params_builder.py +0 -82
  73. digitalhub/stores/client/api.py +0 -32
  74. digitalhub/stores/client/dhcore/__init__.py +0 -3
  75. digitalhub/stores/client/dhcore/client.py +0 -553
  76. digitalhub/stores/client/dhcore/enums.py +0 -18
  77. digitalhub/stores/client/dhcore/key_builder.py +0 -62
  78. digitalhub/stores/client/dhcore/utils.py +0 -86
  79. digitalhub/stores/client/local/__init__.py +0 -3
  80. digitalhub/stores/client/local/api_builder.py +0 -116
  81. digitalhub/stores/client/local/client.py +0 -605
  82. digitalhub/stores/client/local/enums.py +0 -15
  83. digitalhub/stores/client/local/key_builder.py +0 -62
  84. digitalhub/stores/client/local/params_builder.py +0 -97
  85. digitalhub/stores/credentials/__init__.py +0 -3
  86. digitalhub/stores/credentials/configurator.py +0 -185
  87. digitalhub/stores/credentials/handler.py +0 -164
  88. digitalhub/stores/credentials/store.py +0 -77
  89. digitalhub/stores/data/enums.py +0 -15
  90. /digitalhub/stores/client/{dhcore/error_parser.py → error_parser.py} +0 -0
  91. /digitalhub/stores/{client/_base → configurator}/__init__.py +0 -0
  92. {digitalhub-0.14.0b5.dist-info → digitalhub-0.14.9.dist-info}/licenses/AUTHORS +0 -0
  93. {digitalhub-0.14.0b5.dist-info → digitalhub-0.14.9.dist-info}/licenses/LICENSE +0 -0
@@ -1,62 +0,0 @@
1
- # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
- #
3
- # SPDX-License-Identifier: Apache-2.0
4
-
5
- from __future__ import annotations
6
-
7
- from digitalhub.stores.client._base.key_builder import ClientKeyBuilder
8
-
9
-
10
- class ClientDHCoreKeyBuilder(ClientKeyBuilder):
11
- """
12
- Class that build the key of entities.
13
- """
14
-
15
- def base_entity_key(self, entity_id: str) -> str:
16
- """
17
- Build for base entity key.
18
-
19
- Parameters
20
- ----------
21
- entity_id : str
22
- Entity id.
23
-
24
- Returns
25
- -------
26
- str
27
- Key.
28
- """
29
- return f"store://{entity_id}"
30
-
31
- def context_entity_key(
32
- self,
33
- project: str,
34
- entity_type: str,
35
- entity_kind: str,
36
- entity_name: str,
37
- entity_id: str | None = None,
38
- ) -> str:
39
- """
40
- Build for context entity key.
41
-
42
- Parameters
43
- ----------
44
- project : str
45
- Project name.
46
- entity_type : str
47
- Entity type.
48
- entity_kind : str
49
- Entity kind.
50
- entity_name : str
51
- Entity name.
52
- entity_id : str
53
- Entity ID.
54
-
55
- Returns
56
- -------
57
- str
58
- Key.
59
- """
60
- if entity_id is None:
61
- return f"store://{project}/{entity_type}/{entity_kind}/{entity_name}"
62
- return f"store://{project}/{entity_type}/{entity_kind}/{entity_name}:{entity_id}"
@@ -1,86 +0,0 @@
1
- # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
- #
3
- # SPDX-License-Identifier: Apache-2.0
4
-
5
- from __future__ import annotations
6
-
7
- import os
8
- import typing
9
-
10
- from digitalhub.stores.client.api import get_client
11
- from digitalhub.stores.credentials.enums import CredsEnvVar
12
-
13
- if typing.TYPE_CHECKING:
14
- from digitalhub.stores.client.dhcore.client import ClientDHCore
15
-
16
-
17
- def set_dhcore_env(
18
- endpoint: str | None = None,
19
- user: str | None = None,
20
- password: str | None = None,
21
- access_token: str | None = None,
22
- refresh_token: str | None = None,
23
- client_id: str | None = None,
24
- ) -> None:
25
- """
26
- Set DHCore environment variables and reload client configuration.
27
-
28
- Updates environment variables for DHCore configuration and automatically
29
- reloads the client configurator to apply new settings. Overwrites existing
30
- environment variables if already set.
31
-
32
- Parameters
33
- ----------
34
- endpoint : str, optional
35
- DHCore backend endpoint URL.
36
- user : str, optional
37
- Username for basic authentication.
38
- password : str, optional
39
- Password for basic authentication.
40
- access_token : str, optional
41
- OAuth2 access token.
42
- refresh_token : str, optional
43
- OAuth2 refresh token.
44
- client_id : str, optional
45
- OAuth2 client identifier.
46
-
47
- Returns
48
- -------
49
- None
50
- """
51
- if endpoint is not None:
52
- os.environ[CredsEnvVar.DHCORE_ENDPOINT.value] = endpoint
53
- if user is not None:
54
- os.environ[CredsEnvVar.DHCORE_USER.value] = user
55
- if password is not None:
56
- os.environ[CredsEnvVar.DHCORE_PASSWORD.value] = password
57
- if access_token is not None:
58
- os.environ[CredsEnvVar.DHCORE_ACCESS_TOKEN.value] = access_token
59
- if refresh_token is not None:
60
- os.environ[CredsEnvVar.DHCORE_REFRESH_TOKEN.value] = refresh_token
61
- if client_id is not None:
62
- os.environ[CredsEnvVar.DHCORE_CLIENT_ID.value] = client_id
63
-
64
- client: ClientDHCore = get_client(local=False)
65
- client._configurator.load_env_vars()
66
-
67
-
68
- def refresh_token() -> None:
69
- """
70
- Refresh the current OAuth2 access token.
71
-
72
- Uses the refresh token stored in client configuration to obtain a new
73
- access token. Requires OAuth2 authentication configuration.
74
-
75
- Returns
76
- -------
77
- None
78
-
79
- Raises
80
- ------
81
- ClientError
82
- If client not properly configured or token refresh fails.
83
- """
84
- client: ClientDHCore = get_client(local=False)
85
- client._configurator.check_config()
86
- client._configurator.refresh_credentials()
@@ -1,3 +0,0 @@
1
- # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
- #
3
- # SPDX-License-Identifier: Apache-2.0
@@ -1,116 +0,0 @@
1
- # SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
2
- #
3
- # SPDX-License-Identifier: Apache-2.0
4
-
5
- from __future__ import annotations
6
-
7
- from digitalhub.stores.client._base.api_builder import ClientApiBuilder
8
- from digitalhub.stores.client._base.enums import ApiCategories, BackendOperations
9
- from digitalhub.stores.client.local.enums import LocalClientVar
10
- from digitalhub.utils.exceptions import BackendError
11
-
12
- API_BASE = "/api/v1"
13
- API_CONTEXT = f"{API_BASE}/-"
14
-
15
-
16
- class ClientLocalApiBuilder(ClientApiBuilder):
17
- """
18
- This class is used to build the API for the Local client.
19
- """
20
-
21
- def build_api(self, category: str, operation: str, **kwargs) -> str:
22
- """
23
- Build the API for the client.
24
-
25
- Parameters
26
- ----------
27
- category : str
28
- API category.
29
- operation : str
30
- API operation.
31
- **kwargs : dict
32
- Additional parameters.
33
-
34
- Returns
35
- -------
36
- str
37
- API formatted.
38
- """
39
- if category == ApiCategories.BASE.value:
40
- return self.build_api_base(operation, **kwargs)
41
- return self.build_api_context(operation, **kwargs)
42
-
43
- def build_api_base(self, operation: str, **kwargs) -> str:
44
- """
45
- Build the base API for the client.
46
-
47
- Parameters
48
- ----------
49
- operation : str
50
- API operation.
51
- **kwargs : dict
52
- Additional parameters.
53
-
54
- Returns
55
- -------
56
- str
57
- API formatted.
58
- """
59
- entity_type = kwargs["entity_type"] + "s"
60
- if operation in (
61
- BackendOperations.CREATE.value,
62
- BackendOperations.LIST.value,
63
- ):
64
- return f"{API_BASE}/{entity_type}"
65
- elif operation in (
66
- BackendOperations.READ.value,
67
- BackendOperations.UPDATE.value,
68
- BackendOperations.DELETE.value,
69
- ):
70
- return f"{API_BASE}/{entity_type}/{kwargs['entity_name']}"
71
- raise BackendError(f"API for operation '{operation}' for entity type '{entity_type}' not implemented in Local.")
72
-
73
- def build_api_context(self, operation: str, **kwargs) -> str:
74
- """
75
- Build the context API for the client.
76
-
77
- Parameters
78
- ----------
79
- operation : str
80
- The API operation.
81
- **kwargs : dict
82
- Additional parameters including project, entity_type, entity_id, etc.
83
-
84
- Returns
85
- -------
86
- str
87
- The formatted context API endpoint.
88
-
89
- Raises
90
- ------
91
- BackendError
92
- If the operation is not supported for the entity type.
93
- """
94
- try:
95
- entity_type = kwargs["entity_type"] + "s"
96
- except KeyError:
97
- pass
98
- project = kwargs["project"]
99
- if operation in (
100
- BackendOperations.CREATE.value,
101
- BackendOperations.LIST.value,
102
- ):
103
- return f"{API_CONTEXT}/{project}/{entity_type}"
104
- elif operation in (
105
- BackendOperations.READ.value,
106
- BackendOperations.UPDATE.value,
107
- BackendOperations.DELETE.value,
108
- ):
109
- return f"{API_CONTEXT}/{project}/{entity_type}/{kwargs['entity_id']}"
110
- elif operation in (
111
- BackendOperations.LOGS.value,
112
- BackendOperations.FILES.value,
113
- BackendOperations.METRICS.value,
114
- ):
115
- return LocalClientVar.EMPTY.value
116
- raise BackendError(f"API for operation '{operation}' for entity type '{entity_type}' not implemented in Local.")