diff --git a/tes/client.py b/tes/client.py index 0a9a999..fb36e79 100644 --- a/tes/client.py +++ b/tes/client.py @@ -1,5 +1,4 @@ import requests -import time from attr import attrs, attrib from attr.validators import instance_of, optional @@ -9,7 +8,7 @@ from tes.models import (Task, ListTasksRequest, ListTasksResponse, ServiceInfo, GetTaskRequest, CancelTaskRequest, CreateTaskResponse, strconv) -from tes.utils import unmarshal, TimeoutError +from tes.utils import unmarshal def append_suffixes_to_url( @@ -173,27 +172,6 @@ def list_tasks( response = send_request(paths=paths, kwargs_requests=kwargs) return unmarshal(response.json(), ListTasksResponse) - def wait(self, task_id: str, timeout=None) -> Task: - def check_success(data: Task) -> bool: - return data.state not in ["QUEUED", "RUNNING", "INITIALIZING"] - - max_time = time.time() + timeout if timeout else None - - response: Optional[Task] = None - while True: - try: - response = self.get_task(task_id, "MINIMAL") - except Exception: - pass - - if response is not None: - if check_success(response): - return response - - if max_time is not None and time.time() >= max_time: - raise TimeoutError("last_response: {response.as_dict()}") - time.sleep(0.5) - def _request_params( self, data: Optional[str] = None, params: Optional[Dict] = None diff --git a/tests/test_client.py b/tests/test_client.py index 08b2448..2f7bbc2 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -6,7 +6,6 @@ from tes.client import append_suffixes_to_url, HTTPClient, send_request from tes.models import Task, Executor -from tes.utils import TimeoutError class TestHTTPClient(unittest.TestCase): @@ -176,33 +175,6 @@ def test_get_service_info(self): with self.assertRaises(requests.HTTPError): self.cli.get_service_info() - def test_wait(self): - with self.assertRaises(TimeoutError): - with requests_mock.Mocker() as m: - m.get( - "%s/ga4gh/tes/v1/tasks/%s" % (self.mock_url, self.mock_id), - status_code=200, - json={ - "id": self.mock_id, - "state": "RUNNING", - } - ) - self.cli.wait(self.mock_id, timeout=1) - - with requests_mock.Mocker() as m: - m.get( - "%s/ga4gh/tes/v1/tasks/%s" % (self.mock_url, self.mock_id), - [ - {"status_code": 200, - "json": {"id": self.mock_id, "state": "INITIALIZING"}}, - {"status_code": 200, - "json": {"id": self.mock_id, "state": "RUNNING"}}, - {"status_code": 200, - "json": {"id": self.mock_id, "state": "COMPLETE"}} - ] - ) - self.cli.wait(self.mock_id, timeout=2) - def test_append_suffixes_to_url(): urls = ["http://example.com", "http://example.com/"]