Skip to content
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

[PNE-6610] Expose more candidate attributes. #987

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/citrine/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.15.1"
__version__ = "3.16.0"
8 changes: 8 additions & 0 deletions src/citrine/informatics/design_candidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ class DesignCandidate(Serializable["DesignCandidate"]):
and constraints (higher is better)"""
material = properties.Object(DesignMaterial, 'material')
""":DesignMaterial: the material returned by the design workflow"""
name = properties.String('name')
""":str: the name of the candidate"""
hidden = properties.Boolean('hidden')
""":str: whether the candidate is marked hidden"""
pinned_by = properties.Optional(properties.UUID, 'pinned.user')
""":Optional[UUID]: id of the user who pinned the candidate, if it's been pinned"""
pinned_time = properties.Optional(properties.Datetime, 'pinned.time')
""":Optional[datetime]: date and time at which the candidate was pinned, if it's been pinned"""


class HierarchicalDesignCandidate(Serializable["HierarchicalDesignCandidate"]):
Expand Down
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,9 @@ def example_candidates(example_design_material):
"material_id": str(uuid.uuid4()),
"identifiers": [],
"primary_score": 0,
"material": example_design_material
"material": example_design_material,
"name": "Example candidate",
"hidden": True
}]
}

Expand Down
27 changes: 27 additions & 0 deletions tests/resources/test_design_executions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest
import uuid
from copy import deepcopy
from datetime import datetime

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


def test_workflow_execution_results_pinned(workflow_execution: DesignExecution, session, example_candidates):
# Given
pinned_by = uuid.uuid4()
pinned_time = datetime.now()
example_candidates_pinned = deepcopy(example_candidates)
example_candidates_pinned["response"][0]["pinned"] = {
"user": pinned_by,
"time": pinned_time
}
session.set_response(example_candidates_pinned)

# When
candidates = list(workflow_execution.candidates(per_page=4))

# Then
expected_path = '/projects/{}/design-workflows/{}/executions/{}/candidates'.format(
workflow_execution.project_id,
workflow_execution.workflow_id,
workflow_execution.uid,
)
assert session.last_call == FakeCall(method='GET', path=expected_path, params={"per_page": 4, 'page': 1})
assert candidates[0].pinned_by == pinned_by
assert candidates[0].pinned_time == pinned_time


def test_list(collection: DesignExecutionCollection, session):
session.set_response({"per_page": 4, "next": "", "response": []})
lst = list(collection.list(per_page=4))
Expand Down