acryl-datahub 1.0.0.3rc4__py3-none-any.whl → 1.0.0.3rc5__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 acryl-datahub might be problematic. Click here for more details.
- {acryl_datahub-1.0.0.3rc4.dist-info → acryl_datahub-1.0.0.3rc5.dist-info}/METADATA +2488 -2488
- {acryl_datahub-1.0.0.3rc4.dist-info → acryl_datahub-1.0.0.3rc5.dist-info}/RECORD +12 -10
- datahub/_version.py +1 -1
- datahub/sdk/_all_entities.py +4 -0
- datahub/sdk/_shared.py +140 -0
- datahub/sdk/entity_client.py +8 -0
- datahub/sdk/mlmodel.py +301 -0
- datahub/sdk/mlmodelgroup.py +233 -0
- {acryl_datahub-1.0.0.3rc4.dist-info → acryl_datahub-1.0.0.3rc5.dist-info}/WHEEL +0 -0
- {acryl_datahub-1.0.0.3rc4.dist-info → acryl_datahub-1.0.0.3rc5.dist-info}/entry_points.txt +0 -0
- {acryl_datahub-1.0.0.3rc4.dist-info → acryl_datahub-1.0.0.3rc5.dist-info}/licenses/LICENSE +0 -0
- {acryl_datahub-1.0.0.3rc4.dist-info → acryl_datahub-1.0.0.3rc5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import Dict, List, Optional, Sequence, Type, Union
|
|
5
|
+
|
|
6
|
+
from typing_extensions import Self
|
|
7
|
+
|
|
8
|
+
from datahub.emitter.mce_builder import DEFAULT_ENV
|
|
9
|
+
from datahub.metadata.schema_classes import (
|
|
10
|
+
AspectBag,
|
|
11
|
+
MLModelGroupPropertiesClass,
|
|
12
|
+
)
|
|
13
|
+
from datahub.metadata.urns import DataProcessInstanceUrn, MlModelGroupUrn, Urn
|
|
14
|
+
from datahub.sdk._shared import (
|
|
15
|
+
DomainInputType,
|
|
16
|
+
HasDomain,
|
|
17
|
+
HasInstitutionalMemory,
|
|
18
|
+
HasOwnership,
|
|
19
|
+
HasPlatformInstance,
|
|
20
|
+
HasTags,
|
|
21
|
+
HasTerms,
|
|
22
|
+
LinksInputType,
|
|
23
|
+
OwnersInputType,
|
|
24
|
+
TagsInputType,
|
|
25
|
+
TermsInputType,
|
|
26
|
+
make_time_stamp,
|
|
27
|
+
parse_time_stamp,
|
|
28
|
+
)
|
|
29
|
+
from datahub.sdk.entity import Entity, ExtraAspectsType
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class MLModelGroup(
|
|
33
|
+
HasPlatformInstance,
|
|
34
|
+
HasOwnership,
|
|
35
|
+
HasInstitutionalMemory,
|
|
36
|
+
HasTags,
|
|
37
|
+
HasTerms,
|
|
38
|
+
HasDomain,
|
|
39
|
+
Entity,
|
|
40
|
+
):
|
|
41
|
+
__slots__ = ()
|
|
42
|
+
|
|
43
|
+
@classmethod
|
|
44
|
+
def get_urn_type(cls) -> Type[MlModelGroupUrn]:
|
|
45
|
+
return MlModelGroupUrn
|
|
46
|
+
|
|
47
|
+
def __init__(
|
|
48
|
+
self,
|
|
49
|
+
id: str,
|
|
50
|
+
platform: str,
|
|
51
|
+
name: Optional[str] = "",
|
|
52
|
+
platform_instance: Optional[str] = None,
|
|
53
|
+
env: str = DEFAULT_ENV,
|
|
54
|
+
# Model group properties
|
|
55
|
+
description: Optional[str] = None,
|
|
56
|
+
display_name: Optional[str] = None,
|
|
57
|
+
external_url: Optional[str] = None,
|
|
58
|
+
custom_properties: Optional[Dict[str, str]] = None,
|
|
59
|
+
created: Optional[datetime] = None,
|
|
60
|
+
last_modified: Optional[datetime] = None,
|
|
61
|
+
# Standard aspects
|
|
62
|
+
owners: Optional[OwnersInputType] = None,
|
|
63
|
+
links: Optional[LinksInputType] = None,
|
|
64
|
+
tags: Optional[TagsInputType] = None,
|
|
65
|
+
terms: Optional[TermsInputType] = None,
|
|
66
|
+
domain: Optional[DomainInputType] = None,
|
|
67
|
+
training_jobs: Optional[Sequence[Union[str, DataProcessInstanceUrn]]] = None,
|
|
68
|
+
downstream_jobs: Optional[Sequence[Union[str, DataProcessInstanceUrn]]] = None,
|
|
69
|
+
extra_aspects: ExtraAspectsType = None,
|
|
70
|
+
):
|
|
71
|
+
urn = MlModelGroupUrn(platform=platform, name=id, env=env)
|
|
72
|
+
super().__init__(urn)
|
|
73
|
+
self._set_extra_aspects(extra_aspects)
|
|
74
|
+
|
|
75
|
+
self._set_platform_instance(urn.platform, platform_instance)
|
|
76
|
+
|
|
77
|
+
# Set MLModelGroupProperties aspect
|
|
78
|
+
self._ensure_model_group_props(name=display_name or name)
|
|
79
|
+
|
|
80
|
+
if description is not None:
|
|
81
|
+
self.set_description(description)
|
|
82
|
+
if external_url is not None:
|
|
83
|
+
self.set_external_url(external_url)
|
|
84
|
+
if custom_properties is not None:
|
|
85
|
+
self.set_custom_properties(custom_properties)
|
|
86
|
+
if created is not None:
|
|
87
|
+
self.set_created(created)
|
|
88
|
+
if last_modified is not None:
|
|
89
|
+
self.set_last_modified(last_modified)
|
|
90
|
+
|
|
91
|
+
# Standard aspects
|
|
92
|
+
if owners is not None:
|
|
93
|
+
self.set_owners(owners)
|
|
94
|
+
if links is not None:
|
|
95
|
+
self.set_links(links)
|
|
96
|
+
if tags is not None:
|
|
97
|
+
self.set_tags(tags)
|
|
98
|
+
if terms is not None:
|
|
99
|
+
self.set_terms(terms)
|
|
100
|
+
if domain is not None:
|
|
101
|
+
self.set_domain(domain)
|
|
102
|
+
|
|
103
|
+
# ML model group specific aspects
|
|
104
|
+
if training_jobs is not None:
|
|
105
|
+
self.set_training_jobs(training_jobs)
|
|
106
|
+
if downstream_jobs is not None:
|
|
107
|
+
self.set_downstream_jobs(downstream_jobs)
|
|
108
|
+
|
|
109
|
+
@classmethod
|
|
110
|
+
def _new_from_graph(cls, urn: Urn, current_aspects: AspectBag) -> Self:
|
|
111
|
+
assert isinstance(urn, MlModelGroupUrn)
|
|
112
|
+
entity = cls(
|
|
113
|
+
platform=urn.platform,
|
|
114
|
+
id=urn.name,
|
|
115
|
+
env=urn.env,
|
|
116
|
+
)
|
|
117
|
+
return entity._init_from_graph(current_aspects)
|
|
118
|
+
|
|
119
|
+
@property
|
|
120
|
+
def urn(self) -> MlModelGroupUrn:
|
|
121
|
+
return self._urn # type: ignore
|
|
122
|
+
|
|
123
|
+
def _ensure_model_group_props(
|
|
124
|
+
self, *, name: Optional[str] = None
|
|
125
|
+
) -> MLModelGroupPropertiesClass:
|
|
126
|
+
if name is not None:
|
|
127
|
+
return self._setdefault_aspect(MLModelGroupPropertiesClass(name=name))
|
|
128
|
+
|
|
129
|
+
props = self._get_aspect(MLModelGroupPropertiesClass)
|
|
130
|
+
if props is None:
|
|
131
|
+
# If we need properties but they don't exist and no name was provided
|
|
132
|
+
return self._setdefault_aspect(
|
|
133
|
+
MLModelGroupPropertiesClass(name=self.urn.name)
|
|
134
|
+
)
|
|
135
|
+
return props
|
|
136
|
+
|
|
137
|
+
@property
|
|
138
|
+
def name(self) -> Optional[str]:
|
|
139
|
+
return self._ensure_model_group_props().name
|
|
140
|
+
|
|
141
|
+
def set_name(self, display_name: str) -> None:
|
|
142
|
+
self._ensure_model_group_props().name = display_name
|
|
143
|
+
|
|
144
|
+
@property
|
|
145
|
+
def description(self) -> Optional[str]:
|
|
146
|
+
return self._ensure_model_group_props().description
|
|
147
|
+
|
|
148
|
+
def set_description(self, description: str) -> None:
|
|
149
|
+
self._ensure_model_group_props().description = description
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def external_url(self) -> Optional[str]:
|
|
153
|
+
return self._ensure_model_group_props().externalUrl
|
|
154
|
+
|
|
155
|
+
def set_external_url(self, external_url: str) -> None:
|
|
156
|
+
self._ensure_model_group_props().externalUrl = external_url
|
|
157
|
+
|
|
158
|
+
@property
|
|
159
|
+
def custom_properties(self) -> Optional[Dict[str, str]]:
|
|
160
|
+
return self._ensure_model_group_props().customProperties
|
|
161
|
+
|
|
162
|
+
def set_custom_properties(self, custom_properties: Dict[str, str]) -> None:
|
|
163
|
+
self._ensure_model_group_props().customProperties = custom_properties
|
|
164
|
+
|
|
165
|
+
@property
|
|
166
|
+
def created(self) -> Optional[datetime]:
|
|
167
|
+
return parse_time_stamp(self._ensure_model_group_props().created)
|
|
168
|
+
|
|
169
|
+
def set_created(self, created: datetime) -> None:
|
|
170
|
+
self._ensure_model_group_props().created = make_time_stamp(created)
|
|
171
|
+
|
|
172
|
+
@property
|
|
173
|
+
def last_modified(self) -> Optional[datetime]:
|
|
174
|
+
return parse_time_stamp(self._ensure_model_group_props().lastModified)
|
|
175
|
+
|
|
176
|
+
def set_last_modified(self, last_modified: datetime) -> None:
|
|
177
|
+
self._ensure_model_group_props().lastModified = make_time_stamp(last_modified)
|
|
178
|
+
|
|
179
|
+
@property
|
|
180
|
+
def training_jobs(self) -> Optional[List[str]]:
|
|
181
|
+
return self._ensure_model_group_props().trainingJobs
|
|
182
|
+
|
|
183
|
+
def set_training_jobs(
|
|
184
|
+
self, training_jobs: Sequence[Union[str, DataProcessInstanceUrn]]
|
|
185
|
+
) -> None:
|
|
186
|
+
self._ensure_model_group_props().trainingJobs = [
|
|
187
|
+
str(job) for job in training_jobs
|
|
188
|
+
]
|
|
189
|
+
|
|
190
|
+
def add_training_job(
|
|
191
|
+
self, training_job: Union[str, DataProcessInstanceUrn]
|
|
192
|
+
) -> None:
|
|
193
|
+
props = self._ensure_model_group_props()
|
|
194
|
+
if props.trainingJobs is None:
|
|
195
|
+
props.trainingJobs = []
|
|
196
|
+
props.trainingJobs.append(str(training_job))
|
|
197
|
+
|
|
198
|
+
def remove_training_job(
|
|
199
|
+
self, training_job: Union[str, DataProcessInstanceUrn]
|
|
200
|
+
) -> None:
|
|
201
|
+
props = self._ensure_model_group_props()
|
|
202
|
+
if props.trainingJobs is not None:
|
|
203
|
+
props.trainingJobs = [
|
|
204
|
+
job for job in props.trainingJobs if job != str(training_job)
|
|
205
|
+
]
|
|
206
|
+
|
|
207
|
+
@property
|
|
208
|
+
def downstream_jobs(self) -> Optional[List[str]]:
|
|
209
|
+
return self._ensure_model_group_props().downstreamJobs
|
|
210
|
+
|
|
211
|
+
def set_downstream_jobs(
|
|
212
|
+
self, downstream_jobs: Sequence[Union[str, DataProcessInstanceUrn]]
|
|
213
|
+
) -> None:
|
|
214
|
+
self._ensure_model_group_props().downstreamJobs = [
|
|
215
|
+
str(job) for job in downstream_jobs
|
|
216
|
+
]
|
|
217
|
+
|
|
218
|
+
def add_downstream_job(
|
|
219
|
+
self, downstream_job: Union[str, DataProcessInstanceUrn]
|
|
220
|
+
) -> None:
|
|
221
|
+
props = self._ensure_model_group_props()
|
|
222
|
+
if props.downstreamJobs is None:
|
|
223
|
+
props.downstreamJobs = []
|
|
224
|
+
props.downstreamJobs.append(str(downstream_job))
|
|
225
|
+
|
|
226
|
+
def remove_downstream_job(
|
|
227
|
+
self, downstream_job: Union[str, DataProcessInstanceUrn]
|
|
228
|
+
) -> None:
|
|
229
|
+
props = self._ensure_model_group_props()
|
|
230
|
+
if props.downstreamJobs is not None:
|
|
231
|
+
props.downstreamJobs = [
|
|
232
|
+
job for job in props.downstreamJobs if job != str(downstream_job)
|
|
233
|
+
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|