Skip to content

Commit 9c13c50

Browse files
committed
add signature documentation
1 parent 2dbd9a6 commit 9c13c50

File tree

3 files changed

+167
-0
lines changed

3 files changed

+167
-0
lines changed

yarn_api_client/application_master.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ class ApplicationMaster(BaseYarnAPI):
1111
equivalent to a running MapReduce job. The information includes the jobs
1212
the app master is running and all the job particulars like tasks,
1313
counters, configuration, attempts, etc.
14+
15+
If `address` argument is `None` client will try to extract `address` and
16+
`port` from Hadoop configuration files.
17+
18+
:param str address: Proxy HTTP address
19+
:param int port: Proxy HTTP port
20+
:param int timeout: API connection timeout in seconds
1421
"""
1522
def __init__(self, address=None, port=8088, timeout=30):
1623
self.address, self.port, self.timeout = address, port, timeout
@@ -24,6 +31,9 @@ def application_information(self, application_id):
2431
The MapReduce application master information resource provides overall
2532
information about that mapreduce application master.
2633
This includes application id, time it was started, user, name, etc.
34+
35+
:returns: API response object with JSON data
36+
:rtype: :py:class:`yarn_api_client.base.Response`
2737
"""
2838
path = '/proxy/{appid}/ws/v1/mapreduce/info'.format(
2939
appid=application_id)
@@ -34,6 +44,10 @@ def jobs(self, application_id):
3444
"""
3545
The jobs resource provides a list of the jobs running on this
3646
application master.
47+
48+
:param str application_id: The application id
49+
:returns: API response object with JSON data
50+
:rtype: :py:class:`yarn_api_client.base.Response`
3751
"""
3852
path = '/proxy/{appid}/ws/v1/mapreduce/jobs'.format(
3953
appid=application_id)
@@ -45,6 +59,11 @@ def job(self, application_id, job_id):
4559
A job resource contains information about a particular job that was
4660
started by this application master. Certain fields are only accessible
4761
if user has permissions - depends on acl settings.
62+
63+
:param str application_id: The application id
64+
:param str job_id: The job id
65+
:returns: API response object with JSON data
66+
:rtype: :py:class:`yarn_api_client.base.Response`
4867
"""
4968
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}'.format(
5069
appid=application_id, jobid=job_id)
@@ -55,13 +74,22 @@ def job_attempts(self, job_id):
5574
"""
5675
With the job attempts API, you can obtain a collection of resources
5776
that represent the job attempts.
77+
78+
:param str job_id: The job id
79+
:returns: API response object with JSON data
80+
:rtype: :py:class:`yarn_api_client.base.Response`
5881
"""
5982
pass
6083

6184
def job_counters(self, application_id, job_id):
6285
"""
6386
With the job counters API, you can object a collection of resources
6487
that represent all the counters for that job.
88+
89+
:param str application_id: The application id
90+
:param str job_id: The job id
91+
:returns: API response object with JSON data
92+
:rtype: :py:class:`yarn_api_client.base.Response`
6593
"""
6694
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/counters'.format(
6795
appid=application_id, jobid=job_id)
@@ -72,6 +100,11 @@ def job_conf(self, application_id, job_id):
72100
"""
73101
A job configuration resource contains information about the job
74102
configuration for this job.
103+
104+
:param str application_id: The application id
105+
:param str job_id: The job id
106+
:returns: API response object with JSON data
107+
:rtype: :py:class:`yarn_api_client.base.Response`
75108
"""
76109
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/conf'.format(
77110
appid=application_id, jobid=job_id)
@@ -82,6 +115,11 @@ def job_tasks(self, application_id, job_id):
82115
"""
83116
With the tasks API, you can obtain a collection of resources that
84117
represent all the tasks for a job.
118+
119+
:param str application_id: The application id
120+
:param str job_id: The job id
121+
:returns: API response object with JSON data
122+
:rtype: :py:class:`yarn_api_client.base.Response`
85123
"""
86124
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/tasks'.format(
87125
appid=application_id, jobid=job_id)
@@ -92,6 +130,12 @@ def job_task(self, application_id, job_id, task_id):
92130
"""
93131
A Task resource contains information about a particular
94132
task within a job.
133+
134+
:param str application_id: The application id
135+
:param str job_id: The job id
136+
:param str task_id: The task id
137+
:returns: API response object with JSON data
138+
:rtype: :py:class:`yarn_api_client.base.Response`
95139
"""
96140
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/tasks/{taskid}'.format(
97141
appid=application_id, jobid=job_id, taskid=task_id)
@@ -102,6 +146,12 @@ def task_counters(self, application_id, job_id, task_id):
102146
"""
103147
With the task counters API, you can object a collection of resources
104148
that represent all the counters for that task.
149+
150+
:param str application_id: The application id
151+
:param str job_id: The job id
152+
:param str task_id: The task id
153+
:returns: API response object with JSON data
154+
:rtype: :py:class:`yarn_api_client.base.Response`
105155
"""
106156
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/tasks/{taskid}/counters'.format(
107157
appid=application_id, jobid=job_id, taskid=task_id)
@@ -112,6 +162,12 @@ def task_attempts(self, application_id, job_id, task_id):
112162
"""
113163
With the task attempts API, you can obtain a collection of resources
114164
that represent a task attempt within a job.
165+
166+
:param str application_id: The application id
167+
:param str job_id: The job id
168+
:param str task_id: The task id
169+
:returns: API response object with JSON data
170+
:rtype: :py:class:`yarn_api_client.base.Response`
115171
"""
116172
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/tasks/{taskid}/attempts'.format(
117173
appid=application_id, jobid=job_id, taskid=task_id)
@@ -122,6 +178,13 @@ def task_attempt(self, application_id, job_id, task_id, attempt_id):
122178
"""
123179
A Task Attempt resource contains information about a particular task
124180
attempt within a job.
181+
182+
:param str application_id: The application id
183+
:param str job_id: The job id
184+
:param str task_id: The task id
185+
:param str attempt_id: The attempt id
186+
:returns: API response object with JSON data
187+
:rtype: :py:class:`yarn_api_client.base.Response`
125188
"""
126189
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/tasks/{taskid}/attempt/{attemptid}'.format(
127190
appid=application_id, jobid=job_id, taskid=task_id,
@@ -133,6 +196,13 @@ def task_attempt_counters(self, application_id, job_id, task_id, attempt_id):
133196
"""
134197
With the task attempt counters API, you can object a collection
135198
of resources that represent al the counters for that task attempt.
199+
200+
:param str application_id: The application id
201+
:param str job_id: The job id
202+
:param str task_id: The task id
203+
:param str attempt_id: The attempt id
204+
:returns: API response object with JSON data
205+
:rtype: :py:class:`yarn_api_client.base.Response`
136206
"""
137207
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/tasks/{taskid}/attempt/{attemptid}/counters'.format(
138208
appid=application_id, jobid=job_id, taskid=task_id,

yarn_api_client/history_server.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ class HistoryServer(BaseYarnAPI):
1111
The history server REST API's allow the user to get status on finished
1212
applications. Currently it only supports MapReduce and provides
1313
information on finished jobs.
14+
15+
If `address` argument is `None` client will try to extract `address` and
16+
`port` from Hadoop configuration files.
17+
18+
:param str address: HistoryServer HTTP address
19+
:param int port: HistoryServer HTTP port
20+
:param int timeout: API connection timeout in seconds
1421
"""
1522
def __init__(self, address=None, port=19888, timeout=30):
1623
self.address, self.port, self.timeout = address, port, timeout
@@ -23,6 +30,9 @@ def application_information(self):
2330
"""
2431
The history server information resource provides overall information
2532
about the history server.
33+
34+
:returns: API response object with JSON data
35+
:rtype: :py:class:`yarn_api_client.base.Response`
2636
"""
2737
path = '/ws/v1/history/info'
2838

@@ -34,6 +44,23 @@ def jobs(self, state=None, user=None, queue=None, limit=None,
3444
"""
3545
The jobs resource provides a list of the MapReduce jobs that have
3646
finished. It does not currently return a full list of parameters.
47+
48+
:param str user: user name
49+
:param str state: the job state
50+
:param str queue: queue name
51+
:param str limit: total number of app objects to be returned
52+
:param str started_time_begin: jobs with start time beginning with
53+
this time, specified in ms since epoch
54+
:param str started_time_end: jobs with start time ending with this
55+
time, specified in ms since epoch
56+
:param str finished_time_begin: jobs with finish time beginning with
57+
this time, specified in ms since epoch
58+
:param str finished_time_end: jobs with finish time ending with this
59+
time, specified in ms since epoch
60+
:returns: API response object with JSON data
61+
:rtype: :py:class:`yarn_api_client.base.Response`
62+
:raises yarn_api_client.errors.IllegalArgumentError: if `state`
63+
incorrect
3764
"""
3865
path = '/ws/v1/history/mapreduce/jobs'
3966

@@ -60,6 +87,10 @@ def job(self, job_id):
6087
"""
6188
A Job resource contains information about a particular job identified
6289
by jobid.
90+
91+
:param str job_id: The job id
92+
:returns: API response object with JSON data
93+
:rtype: :py:class:`yarn_api_client.base.Response`
6394
"""
6495
path = '/ws/v1/history/mapreduce/jobs/{jobid}'.format(jobid=job_id)
6596

@@ -79,6 +110,10 @@ def job_counters(self, job_id):
79110
"""
80111
With the job counters API, you can object a collection of resources
81112
that represent al the counters for that job.
113+
114+
:param str job_id: The job id
115+
:returns: API response object with JSON data
116+
:rtype: :py:class:`yarn_api_client.base.Response`
82117
"""
83118
path = '/ws/v1/history/mapreduce/jobs/{jobid}/counters'.format(
84119
jobid=job_id)
@@ -89,6 +124,10 @@ def job_conf(self, job_id):
89124
"""
90125
A job configuration resource contains information about the job
91126
configuration for this job.
127+
128+
:param str job_id: The job id
129+
:returns: API response object with JSON data
130+
:rtype: :py:class:`yarn_api_client.base.Response`
92131
"""
93132
path = '/ws/v1/history/mapreduce/jobs/{jobid}/conf'.format(jobid=job_id)
94133

@@ -98,6 +137,12 @@ def job_tasks(self, job_id, type=None):
98137
"""
99138
With the tasks API, you can obtain a collection of resources that
100139
represent a task within a job.
140+
141+
:param str job_id: The job id
142+
:param str type: type of task, valid values are m or r. m for map
143+
task or r for reduce task
144+
:returns: API response object with JSON data
145+
:rtype: :py:class:`yarn_api_client.base.Response`
101146
"""
102147
path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks'.format(
103148
jobid=job_id)
@@ -119,6 +164,11 @@ def job_task(self, job_id, task_id):
119164
"""
120165
A Task resource contains information about a particular task
121166
within a job.
167+
168+
:param str job_id: The job id
169+
:param str task_id: The task id
170+
:returns: API response object with JSON data
171+
:rtype: :py:class:`yarn_api_client.base.Response`
122172
"""
123173
path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks/{taskid}'.format(
124174
jobid=job_id, taskid=task_id)
@@ -129,6 +179,11 @@ def task_counters(self, job_id, task_id):
129179
"""
130180
With the task counters API, you can object a collection of resources
131181
that represent all the counters for that task.
182+
183+
:param str job_id: The job id
184+
:param str task_id: The task id
185+
:returns: API response object with JSON data
186+
:rtype: :py:class:`yarn_api_client.base.Response`
132187
"""
133188
path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks/{taskid}/counters'.format(
134189
jobid=job_id, taskid=task_id)
@@ -139,6 +194,11 @@ def task_attempts(self, job_id, task_id):
139194
"""
140195
With the task attempts API, you can obtain a collection of resources
141196
that represent a task attempt within a job.
197+
198+
:param str job_id: The job id
199+
:param str task_id: The task id
200+
:returns: API response object with JSON data
201+
:rtype: :py:class:`yarn_api_client.base.Response`
142202
"""
143203
path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks/{taskid}/attempts'.format(
144204
jobid=job_id, taskid=task_id)
@@ -149,6 +209,12 @@ def task_attempt(self, job_id, task_id, attempt_id):
149209
"""
150210
A Task Attempt resource contains information about a particular task
151211
attempt within a job.
212+
213+
:param str job_id: The job id
214+
:param str task_id: The task id
215+
:param str attempt_id: The attempt id
216+
:returns: API response object with JSON data
217+
:rtype: :py:class:`yarn_api_client.base.Response`
152218
"""
153219
path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks/{taskid}/attempt/{attemptid}'.format(
154220
jobid=job_id, taskid=task_id, attemptid=attempt_id)
@@ -159,6 +225,12 @@ def task_attempt_counters(self, job_id, task_id, attempt_id):
159225
"""
160226
With the task attempt counters API, you can object a collection of
161227
resources that represent al the counters for that task attempt.
228+
229+
:param str job_id: The job id
230+
:param str task_id: The task id
231+
:param str attempt_id: The attempt id
232+
:returns: API response object with JSON data
233+
:rtype: :py:class:`yarn_api_client.base.Response`
162234
"""
163235
path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks/{taskid}/attempt/{attemptid}/counters'.format(
164236
jobid=job_id, taskid=task_id, attemptid=attempt_id)

yarn_api_client/node_manager.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class NodeManager(BaseYarnAPI):
88
"""
99
The NodeManager REST API's allow the user to get status on the node and
1010
information about applications and containers running on that node.
11+
12+
:param str address: NodeManager HTTP address
13+
:param int port: NodeManager HTTP port
14+
:param int timeout: API connection timeout in seconds
1115
"""
1216
def __init__(self, address=None, port=8042, timeout=30):
1317
self.address, self.port, self.timeout = address, port, timeout
@@ -16,6 +20,9 @@ def node_information(self):
1620
"""
1721
The node information resource provides overall information about that
1822
particular node.
23+
24+
:returns: API response object with JSON data
25+
:rtype: :py:class:`yarn_api_client.base.Response`
1926
"""
2027
path = '/ws/v1/node/info'
2128
return self.request(path)
@@ -24,6 +31,13 @@ def node_applications(self, state=None, user=None):
2431
"""
2532
With the Applications API, you can obtain a collection of resources,
2633
each of which represents an application.
34+
35+
:param str state: application state
36+
:param str user: user name
37+
:returns: API response object with JSON data
38+
:rtype: :py:class:`yarn_api_client.base.Response`
39+
:raises yarn_api_client.errors.IllegalArgumentError: if `state`
40+
incorrect
2741
"""
2842
path = '/ws/v1/node/apps'
2943

@@ -44,6 +58,10 @@ def node_application(self, application_id):
4458
"""
4559
An application resource contains information about a particular
4660
application that was run or is running on this NodeManager.
61+
62+
:param str application_id: The application id
63+
:returns: API response object with JSON data
64+
:rtype: :py:class:`yarn_api_client.base.Response`
4765
"""
4866
path = '/ws/v1/node/apps/{appid}'.format(appid=application_id)
4967

@@ -53,6 +71,9 @@ def node_containers(self):
5371
"""
5472
With the containers API, you can obtain a collection of resources,
5573
each of which represents a container.
74+
75+
:returns: API response object with JSON data
76+
:rtype: :py:class:`yarn_api_client.base.Response`
5677
"""
5778
path = '/ws/v1/node/containers'
5879

@@ -62,6 +83,10 @@ def node_container(self, container_id):
6283
"""
6384
A container resource contains information about a particular container
6485
that is running on this NodeManager.
86+
87+
:param str container_id: The container id
88+
:returns: API response object with JSON data
89+
:rtype: :py:class:`yarn_api_client.base.Response`
6590
"""
6691
path = '/ws/v1/node/containers/{containerid}'.format(
6792
containerid=container_id)

0 commit comments

Comments
 (0)