Skip to content
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.25.1"
__version__ = "3.25.2"
16 changes: 12 additions & 4 deletions src/citrine/informatics/executions/predictor_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
from typing import List, Optional, Union
from uuid import UUID

from citrine.informatics.predictor_evaluation_result import PredictorEvaluationResult
from citrine.informatics.predictor_evaluator import PredictorEvaluator
from citrine.resources.status_detail import StatusDetail
from citrine._rest.asynchronous_object import AsynchronousObject
from citrine._rest.engine_resource import EngineResourceWithoutStatus
from citrine._rest.resource import PredictorRef
from citrine._serialization import properties
from citrine._serialization.serializable import Serializable
from citrine._session import Session
from citrine._utils.functions import format_escaped_url
from citrine.informatics.predictor_evaluation_result import PredictorEvaluationResult
from citrine.informatics.predictor_evaluator import PredictorEvaluator
from citrine.resources.status_detail import StatusDetail


class PredictorEvaluatorsResponse(Serializable['EvaluatorsPayload']):
Expand All @@ -36,7 +38,7 @@ def __init__(self,
self.predictor = PredictorRef(predictor_id, predictor_version)


class PredictorEvaluation(EngineResourceWithoutStatus['PredictorEvaluation']):
class PredictorEvaluation(EngineResourceWithoutStatus['PredictorEvaluation'], AsynchronousObject):
"""The evaluation of a predictor's performance."""

uid: UUID = properties.UUID('id', serializable=False)
Expand All @@ -56,6 +58,12 @@ class PredictorEvaluation(EngineResourceWithoutStatus['PredictorEvaluation']):
default=[], serializable=False)
""":List[StatusDetail]: a list of structured status info, containing the message and level"""

project_id: Optional[UUID] = None
_session: Optional[Session] = None
_in_progress_statuses = ["INPROGRESS"]
_succeeded_statuses = ["SUCCEEDED"]
_failed_statuses = ["FAILED"]

def _path(self):
return format_escaped_url(
'/projects/{project_id}/predictor-evaluations/{evaluation_id}',
Expand Down
25 changes: 25 additions & 0 deletions tests/resources/test_predictor_evaluations.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from copy import deepcopy
import uuid

import pytest

from citrine.resources.predictor_evaluation import PredictorEvaluationCollection
from citrine.informatics.executions.predictor_evaluation import PredictorEvaluationRequest
from citrine.informatics.predictors import GraphPredictor
from citrine.jobs.waiting import wait_while_executing

from tests.utils.factories import CrossValidationEvaluatorFactory, PredictorEvaluationDataFactory,\
PredictorEvaluationFactory, PredictorInstanceDataFactory, PredictorRefFactory
Expand Down Expand Up @@ -247,3 +249,26 @@ def test_delete_not_implemented():
pec = PredictorEvaluationCollection(uuid.uuid4(), session)
with pytest.raises(NotImplementedError):
pec.delete(uuid.uuid4())


def test_wait():
in_progress_response = PredictorEvaluationFactory(metadata__status={"major": "INPROGRESS", "minor": "EXECUTING", "detail": []})
completed_response = deepcopy(in_progress_response)
completed_response["metadata"]["status"]["major"] = "SUCCEEDED"
completed_response["metadata"]["status"]["minor"] = "COMPLETED"

session = FakeSession()
pec = PredictorEvaluationCollection(uuid.uuid4(), session)

# wait_while_executing makes two additional calls once it's done polling.
responses = 4 * [in_progress_response] + 3 * [completed_response]
session.set_responses(*responses)

evaluation = pec.build(in_progress_response)
wait_while_executing(collection=pec, execution=evaluation, interval=0.1)

expected_call = FakeCall(
method='GET',
path=f'/projects/{pec.project_id}/predictor-evaluations/{in_progress_response["id"]}'
)
assert (len(responses) * [expected_call]) == session.calls
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the call counts sufficient to validate? Or should there be validation of some de-serialization behavior?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The successful deserialization of .get is confirmed elsewhere. This is primarily to ensure predictor evaluations are properly handled by wait_while_executing

Loading