From 1806ff7ad423097cf3c791e8067ae7444862c827 Mon Sep 17 00:00:00 2001 From: Oleksandr Pryimak Date: Tue, 5 Jul 2016 23:48:53 +0200 Subject: [PATCH 1/3] Fix History REST API Use attempts/xxx to access attempt info --- tests/test_history_server.py | 4 ++-- yarn_api_client/history_server.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_history_server.py b/tests/test_history_server.py index bf7b6ad..79da061 100644 --- a/tests/test_history_server.py +++ b/tests/test_history_server.py @@ -77,8 +77,8 @@ def test_task_attempts(self, request_mock): def test_task_attempt(self, request_mock): self.hs.task_attempt('job_2', 'task_3', 'attempt_4') - request_mock.assert_called_with('/ws/v1/history/mapreduce/jobs/job_2/tasks/task_3/attempt/attempt_4') + request_mock.assert_called_with('/ws/v1/history/mapreduce/jobs/job_2/tasks/task_3/attempts/attempt_4') def test_task_attempt_counters(self, request_mock): self.hs.task_attempt_counters('job_2', 'task_3', 'attempt_4') - request_mock.assert_called_with('/ws/v1/history/mapreduce/jobs/job_2/tasks/task_3/attempt/attempt_4/counters') + request_mock.assert_called_with('/ws/v1/history/mapreduce/jobs/job_2/tasks/task_3/attempts/attempt_4/counters') diff --git a/yarn_api_client/history_server.py b/yarn_api_client/history_server.py index 089bdd2..22b219e 100644 --- a/yarn_api_client/history_server.py +++ b/yarn_api_client/history_server.py @@ -216,7 +216,7 @@ def task_attempt(self, job_id, task_id, attempt_id): :returns: API response object with JSON data :rtype: :py:class:`yarn_api_client.base.Response` """ - path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks/{taskid}/attempt/{attemptid}'.format( + path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks/{taskid}/attempts/{attemptid}'.format( jobid=job_id, taskid=task_id, attemptid=attempt_id) return self.request(path) @@ -232,7 +232,7 @@ def task_attempt_counters(self, job_id, task_id, attempt_id): :returns: API response object with JSON data :rtype: :py:class:`yarn_api_client.base.Response` """ - path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks/{taskid}/attempt/{attemptid}/counters'.format( + path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks/{taskid}/attempts/{attemptid}/counters'.format( jobid=job_id, taskid=task_id, attemptid=attempt_id) return self.request(path) From 7d4f1b1c2af69395ed4ac771241883b56079812b Mon Sep 17 00:00:00 2001 From: Oleksandr Pryimak Date: Tue, 5 Jul 2016 23:57:57 +0200 Subject: [PATCH 2/3] Read response before raising the exception One MUST read response before launching a new request. Otherwise it is imposible to get a new response object --- yarn_api_client/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yarn_api_client/base.py b/yarn_api_client/base.py index c86a617..af2a10f 100644 --- a/yarn_api_client/base.py +++ b/yarn_api_client/base.py @@ -38,7 +38,8 @@ def request(self, api_path, **query_args): if response.status == OK: return self.response_class(response) else: - msg = 'Response finished with status: %s' % response.status + explanation = response.read() + msg = 'Response finished with status: %s. Details: %s' % (response.status, explanation) raise APIError(msg) def construct_parameters(self, arguments): From c116b69b83641fa9845726f909df029fd63b786b Mon Sep 17 00:00:00 2001 From: Oleksandr Pryimak Date: Sun, 27 Nov 2016 23:35:48 +0100 Subject: [PATCH 3/3] Bump the version --- yarn_api_client/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn_api_client/__init__.py b/yarn_api_client/__init__.py index 6f4ff0b..4c91f4b 100644 --- a/yarn_api_client/__init__.py +++ b/yarn_api_client/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -__version__ = '0.2.4' +__version__ = '0.2.5' __all__ = ['ApplicationMaster', 'HistoryServer', 'NodeManager', 'ResourceManager']