|
8 | 8 |
|
9 | 9 | from pydantic.v1 import Field, validator
|
10 | 10 |
|
11 |
| -from pyatlan.model.enums import AIModelStatus |
| 11 | +from pyatlan.model.enums import AIDatasetType, AIModelStatus |
12 | 12 | from pyatlan.model.fields.atlan_fields import KeywordField, RelationField, TextField
|
13 |
| -from pyatlan.utils import init_guid, to_camel_case, validate_required_fields |
| 13 | +from pyatlan.utils import ( |
| 14 | + get_epoch_timestamp, |
| 15 | + init_guid, |
| 16 | + to_camel_case, |
| 17 | + validate_required_fields, |
| 18 | +) |
14 | 19 |
|
15 | 20 | from .a_i import AI
|
16 | 21 |
|
@@ -63,6 +68,43 @@ def creator(
|
63 | 68 | )
|
64 | 69 | return cls(attributes=attributes)
|
65 | 70 |
|
| 71 | + @classmethod |
| 72 | + def process_creator( |
| 73 | + cls, client, a_i_model_guid: str, database_dict: dict[AIDatasetType, list] |
| 74 | + ) -> AIModel: |
| 75 | + from pyatlan.model.assets import Process |
| 76 | + |
| 77 | + process_list = [] |
| 78 | + output_asset = client.asset.get_by_guid(guid=a_i_model_guid, asset_type=AIModel) |
| 79 | + for key, value_list in database_dict.items(): |
| 80 | + for value in value_list: |
| 81 | + input_asset = client.asset.get_by_guid(guid=value.guid) |
| 82 | + if key == AIDatasetType.OUTPUT: |
| 83 | + process_name = f"{output_asset.name} -> {input_asset.name}" |
| 84 | + process_created = Process.creator( |
| 85 | + name=process_name, |
| 86 | + connection_qualified_name="default/ai/dataset", |
| 87 | + inputs=[AIModel.ref_by_guid(guid=a_i_model_guid)], |
| 88 | + outputs=[value], |
| 89 | + process_id=str(get_epoch_timestamp()), |
| 90 | + ) |
| 91 | + process_created.ai_dataset_type = key |
| 92 | + else: |
| 93 | + process_name = f"{input_asset.name} -> {output_asset.name}" |
| 94 | + process_created = Process.creator( |
| 95 | + name=process_name, |
| 96 | + connection_qualified_name="default/ai/dataset", |
| 97 | + inputs=[value], |
| 98 | + outputs=[AIModel.ref_by_guid(guid=a_i_model_guid)], |
| 99 | + process_id=str(get_epoch_timestamp()), |
| 100 | + ) |
| 101 | + process_created.ai_dataset_type = key |
| 102 | + process_list.append(process_created) |
| 103 | + |
| 104 | + response = client.asset.save(process_list) |
| 105 | + |
| 106 | + return response |
| 107 | + |
66 | 108 | type_name: str = Field(default="AIModel", allow_mutation=False)
|
67 | 109 |
|
68 | 110 | @validator("type_name")
|
|
0 commit comments