Beispiel #1
0
    def set_trial_status(self, trial, status, heartbeat=None, was=None):
        """Update the trial status and the heartbeat

        Raises
        ------
        FailedUpdate
            The exception is raised if the status of the trial object
            does not match the status in the database

        """
        was = was or trial.status

        validate_status(status)
        validate_status(was)
        try:
            result_trial = self.backend.fetch_and_update_trial(
                {
                    "uid": trial.id,
                    "status": get_track_status(was)
                },
                "set_trial_status",
                status=get_track_status(status),
            )

        except ItemNotFound as e:
            raise FailedUpdate() from e

        trial.status = status
        return result_trial
Beispiel #2
0
    def set_trial_status(self, trial, status, heartbeat=None):
        """Update the trial status and the heartbeat

        Raises
        ------
        FailedUpdate
            The exception is raised if the status of the trial object
            does not match the status in the database

        """
        validate_status(status)
        try:
            result_trial = self.backend.fetch_and_update_trial(
                {
                    'uid': trial.id,
                    'status': get_track_status(trial.status)
                },
                'set_trial_status',
                status=get_track_status(status))

        except ItemNotFound as e:
            raise FailedUpdate() from e

        trial.status = status
        return result_trial
Beispiel #3
0
    def push_trial_results(self, trial):
        """See :func:`orion.storage.base.BaseStorageProtocol.push_trial_results`"""
        rc = self.update_trial(trial,
                               **trial.to_dict(),
                               where={
                                   "_id": trial.id,
                                   "status": "reserved"
                               })
        if not rc:
            raise FailedUpdate()

        return rc
Beispiel #4
0
    def push_trial_results(self, trial):
        """See :func:`~orion.storage.BaseStorageProtocol.push_trial_results`"""
        rc = self._update_trial(trial,
                                **trial.to_dict(),
                                where={
                                    '_id': trial.id,
                                    'status': 'reserved'
                                })
        if not rc:
            raise FailedUpdate()

        return rc
Beispiel #5
0
    def set_trial_status(self, trial, status, heartbeat=None):
        """See :func:`orion.storage.base.BaseStorageProtocol.set_trial_status`"""
        if heartbeat is None:
            heartbeat = datetime.datetime.utcnow()

        update = dict(status=status,
                      heartbeat=heartbeat,
                      experiment=trial.experiment)

        validate_status(status)

        rc = self.update_trial(trial,
                               **update,
                               where={
                                   "status": trial.status,
                                   "_id": trial.id
                               })

        if not rc:
            raise FailedUpdate()

        trial.status = status
Beispiel #6
0
    def set_trial_status(self, trial, status, heartbeat=None):
        """See :func:`~orion.storage.BaseStorageProtocol.set_trial_status`"""
        if heartbeat is None:
            heartbeat = datetime.datetime.utcnow()

        update = dict(status=status,
                      heartbeat=heartbeat,
                      experiment=trial.experiment)
        if trial.status == 'new':
            update["start_time"] = datetime.datetime.utcnow()

        elif status == 'completed':
            update["end_time"] = datetime.datetime.utcnow()

        rc = self._update_trial(trial,
                                **update,
                                where={
                                    'status': trial.status,
                                    '_id': trial.id
                                })
        trial.status = status

        if not rc:
            raise FailedUpdate()