Skip to content

Commit 26bf57e

Browse files
committed
[PNE-6610] Expose more candidate attributes.
Expose the pinned metadata, hidden attribubte, and name of each candidate as read-only properties.
1 parent a4b8c92 commit 26bf57e

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

src/citrine/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.15.1"
1+
__version__ = "3.16.0"

src/citrine/informatics/design_candidate.py

+8
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,14 @@ class DesignCandidate(Serializable["DesignCandidate"]):
177177
and constraints (higher is better)"""
178178
material = properties.Object(DesignMaterial, 'material')
179179
""":DesignMaterial: the material returned by the design workflow"""
180+
name = properties.String('name')
181+
""":str: the name of the candidate"""
182+
hidden = properties.Boolean('hidden')
183+
""":str: whether the candidate is marked hidden"""
184+
pinned_by = properties.Optional(properties.UUID, 'pinned.user')
185+
""":Optional[UUID]: id of the user who pinned the candidate, if it's been pinned"""
186+
pinned_time = properties.Optional(properties.Datetime, 'pinned.time')
187+
""":Optional[datetime]: date and time at which the candidate was pinned, if it's been pinned"""
180188

181189

182190
class HierarchicalDesignCandidate(Serializable["HierarchicalDesignCandidate"]):

tests/conftest.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,9 @@ def example_candidates(example_design_material):
849849
"material_id": str(uuid.uuid4()),
850850
"identifiers": [],
851851
"primary_score": 0,
852-
"material": example_design_material
852+
"material": example_design_material,
853+
"name": "Example candidate",
854+
"hidden": True
853855
}]
854856
}
855857

tests/resources/test_design_executions.py

+27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import pytest
22
import uuid
3+
from copy import deepcopy
4+
from datetime import datetime
35

46
from citrine.informatics.executions.design_execution import DesignExecution
57
from citrine.resources.design_execution import DesignExecutionCollection
@@ -99,6 +101,31 @@ def test_workflow_execution_results(workflow_execution: DesignExecution, session
99101
assert session.last_call == FakeCall(method='GET', path=expected_path, params={"per_page": 4, 'page': 1})
100102

101103

104+
def test_workflow_execution_results_pinned(workflow_execution: DesignExecution, session, example_candidates):
105+
# Given
106+
pinned_by = uuid.uuid4()
107+
pinned_time = datetime.now()
108+
example_candidates_pinned = deepcopy(example_candidates)
109+
example_candidates_pinned["response"][0]["pinned"] = {
110+
"user": pinned_by,
111+
"time": pinned_time
112+
}
113+
session.set_response(example_candidates_pinned)
114+
115+
# When
116+
candidates = list(workflow_execution.candidates(per_page=4))
117+
118+
# Then
119+
expected_path = '/projects/{}/design-workflows/{}/executions/{}/candidates'.format(
120+
workflow_execution.project_id,
121+
workflow_execution.workflow_id,
122+
workflow_execution.uid,
123+
)
124+
assert session.last_call == FakeCall(method='GET', path=expected_path, params={"per_page": 4, 'page': 1})
125+
assert candidates[0].pinned_by == pinned_by
126+
assert candidates[0].pinned_time == pinned_time
127+
128+
102129
def test_list(collection: DesignExecutionCollection, session):
103130
session.set_response({"per_page": 4, "next": "", "response": []})
104131
lst = list(collection.list(per_page=4))

0 commit comments

Comments
 (0)