def test_refresh(self, stub): message = job_pb2.Job(id="foo") refresh_message = job_pb2.Job(id="foo", status=job_pb2.STATUS_UNKNOWN) job = Job(message) stub.return_value.GetJob.return_value = refresh_message job.refresh() stub.return_value.GetJob.assert_called_with( job_pb2.GetJobRequest(id=job.id), timeout=Client.DEFAULT_TIMEOUT) assert job._message == refresh_message
def test_get(self, stub, client): id_ = "foo" message = job_pb2.Job(id=id_) stub.return_value.GetJob.return_value = message job = Job.get(id_, client=client) assert job._message == message stub.return_value.GetJob.assert_called_with( job_pb2.GetJobRequest(id=id_), timeout=Client.DEFAULT_TIMEOUT) if client is not None: assert job._client == client else: assert isinstance(job._client, Client)
def get(cls, id, client=None): """Get a currently-running `Job` by its ID. Example ------- >>> from descarteslabs.workflows import Job >>> job = Job.get('3754676080bbb2b857fbc04a3e48f6312732e1bc42e0bd7b') # doctest: +SKIP """ if client is None: client = Client() message = client.api["GetJob"](job_pb2.GetJobRequest(id=id), timeout=client.DEFAULT_TIMEOUT) return cls(message, client)
def test_refresh(self, stub): message = job_pb2.Job(id="foo") refresh_message = job_pb2.Job( id="foo", state=job_pb2.Job.State(stage=job_pb2.Job.Stage.QUEUED)) job = Job._from_proto(message) stub.return_value.GetJob.return_value = refresh_message job.refresh() stub.return_value.GetJob.assert_called_with( job_pb2.GetJobRequest(id=job.id), timeout=Client.DEFAULT_TIMEOUT, metadata=(("x-wf-channel", _channel.__channel__), ), ) assert job._message == refresh_message
def refresh(self): """ Refresh the attributes and state of the job. Example ------- >>> from descarteslabs.workflows import Job, Int >>> job = Job(Int(1), {}) # doctest: +SKIP >>> job.stage # doctest: +SKIP QUEUED >>> job.refresh() # doctest: +SKIP >>> job.stage # doctest: +SKIP SUCCEEDED """ message = self._client.api["GetJob"]( job_pb2.GetJobRequest(id=self.id), timeout=self._client.DEFAULT_TIMEOUT ) self._message = message
def refresh(self): """ Refresh the attributes and status of the job. Example ------- >>> from descarteslabs.workflows import Job, Int >>> job = Job.build(Int(1), {}) >>> job.execute() # doctest: +SKIP >>> job.stage # doctest: +SKIP STAGE_UNKNOWN >>> job.refresh() # doctest: +SKIP >>> job.stage # doctest: +SKIP STAGE_DONE """ message = self._client.api["GetJob"]( job_pb2.GetJobRequest(id=self.id), timeout=self._client.DEFAULT_TIMEOUT) self._message = message
def get(cls, id, client=None): """ Get a currently-running `Job` by its ID. Parameters ---------- id: string The ID of a running job. client : `.workflows.client.Client`, optional Allows you to use a specific client instance with non-default auth and parameters Example ------- >>> from descarteslabs.workflows import Job >>> job = Job.get('3754676080bbb2b857fbc04a3e48f6312732e1bc42e0bd7b') # doctest: +SKIP """ if client is None: client = get_global_grpc_client() message = client.api["GetJob"](job_pb2.GetJobRequest(id=id), timeout=client.DEFAULT_TIMEOUT) return cls._from_proto(message, client)