-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a datasource field to the DesignWorkflow object #968
Changes from all commits
f53a021
b03680b
e777535
f5f7538
169e809
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "3.9.0" | ||
__version__ = "3.10.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
from citrine._rest.resource import Resource | ||
from citrine._serialization import properties | ||
from citrine.informatics.data_sources import DataSource | ||
from citrine.informatics.workflows.workflow import Workflow | ||
from citrine.resources.design_execution import DesignExecutionCollection | ||
from citrine._rest.ai_resource_metadata import AIResourceMetadata | ||
|
@@ -31,11 +32,12 @@ class DesignWorkflow(Resource['DesignWorkflow'], Workflow, AIResourceMetadata): | |
design_space_id = properties.Optional(properties.UUID, 'design_space_id') | ||
predictor_id = properties.Optional(properties.UUID, 'predictor_id') | ||
predictor_version = properties.Optional( | ||
properties.Union([properties.Integer(), properties.String()]), 'predictor_version') | ||
properties.Union([properties.Integer, properties.String]), 'predictor_version') | ||
branch_root_id: Optional[UUID] = properties.Optional(properties.UUID, 'branch_root_id') | ||
""":Optional[UUID]: Root ID of the branch that contains this workflow.""" | ||
branch_version: Optional[int] = properties.Optional(properties.Integer, 'branch_version') | ||
""":Optional[int]: Version number of the branch that contains this workflow.""" | ||
data_source = properties.Optional(properties.Object(DataSource), "data_source") | ||
|
||
status_description = properties.String('status_description', serializable=False) | ||
""":str: more detailed description of the workflow's status""" | ||
|
@@ -50,20 +52,54 @@ def __init__(self, | |
design_space_id: Optional[UUID] = None, | ||
predictor_id: Optional[UUID] = None, | ||
predictor_version: Optional[Union[int, str]] = None, | ||
data_source: Optional[DataSource] = None, | ||
description: Optional[str] = None): | ||
self.name = name | ||
self.design_space_id = design_space_id | ||
self.predictor_id = predictor_id | ||
self.predictor_version = predictor_version | ||
self.data_source = data_source | ||
self.description = description | ||
|
||
def __str__(self): | ||
return '<DesignWorkflow {!r}>'.format(self.name) | ||
|
||
@classmethod | ||
def _pre_build(cls, data: dict) -> dict: | ||
"""Run data modification before building.""" | ||
data_source_id = data.pop("data_source_id", None) | ||
if data_source_id is not None: | ||
data["data_source"] = DataSource.from_data_source_id(data_source_id).dump() | ||
return data | ||
|
||
def _post_dump(self, data: dict) -> dict: | ||
"""Run data modification after dumping.""" | ||
data_source = data.pop("data_source", None) | ||
if data_source is not None: | ||
data["data_source_id"] = DataSource.build(data_source).to_data_source_id() | ||
else: | ||
data["data_source_id"] = None | ||
return data | ||
|
||
Comment on lines
+67
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This uses the existing serde hooks to filter out |
||
@property | ||
def design_executions(self) -> DesignExecutionCollection: | ||
"""Return a resource representing all visible executions of this workflow.""" | ||
if getattr(self, 'project_id', None) is None: | ||
raise AttributeError('Cannot initialize execution without project reference!') | ||
return DesignExecutionCollection( | ||
project_id=self.project_id, session=self._session, workflow_id=self.uid) | ||
|
||
@property | ||
def data_source_id(self) -> Optional[str]: | ||
"""A resource referencing the workflow's data source.""" | ||
if self.data_source is None: | ||
return None | ||
else: | ||
return self.data_source.to_data_source_id() | ||
|
||
@data_source_id.setter | ||
def data_source_id(self, value: Optional[str]): | ||
if value is None: | ||
self.data_source = None | ||
else: | ||
self.data_source = DataSource.from_data_source_id(value) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -949,16 +949,3 @@ def predictor_evaluation_workflow_dict(generic_entity, example_cv_evaluator_dict | |
"evaluators": [example_cv_evaluator_dict, example_holdout_evaluator_dict] | ||
}) | ||
return ret | ||
|
||
@pytest.fixture | ||
def design_workflow_dict(generic_entity): | ||
ret = generic_entity.copy() | ||
ret.update({ | ||
"name": "Example Design Workflow", | ||
"description": "A description! Of the Design Workflow! So you know what it's for!", | ||
"design_space_id": str(uuid.uuid4()), | ||
"predictor_id": str(uuid.uuid4()), | ||
"predictor_version": random.randint(1, 10), | ||
"branch_id": str(uuid.uuid4()), | ||
}) | ||
return ret | ||
Comment on lines
-952
to
-964
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having two different DesignWorkflow test objects (a fixture & a Factory) made testing on the updated object complicated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will presumably be useful soon, since it's the next step after Multistep Materials tables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, Bill and I were just talking about what's needed to properly support training, etc on snapshots.