Skip to content

Commit

Permalink
adding 'until_running' kwarg for RunningJob.wait() in Python client
Browse files Browse the repository at this point in the history
  • Loading branch information
irontablee committed Jul 28, 2016
1 parent d5fd8dd commit f143295
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 0 additions & 1 deletion genie-client/src/main/python/pygenie/adapter/genie_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def get_info_for_rj(self, job_id, full=True, *args, **kwargs):
.format(scheme=link_parts.scheme,
netloc=link_parts.netloc,
job_id=data.get('id'))

job_link = '{scheme}://{netloc}/jobs?id={job_id}&showDetails={job_id}' \
.format(scheme=link_parts.scheme,
netloc=link_parts.netloc,
Expand Down
9 changes: 7 additions & 2 deletions genie-client/src/main/python/pygenie/jobs/running.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def username(self):

return self.info.get('user')

def wait(self, sleep_seconds=10, suppress_stream=False):
def wait(self, sleep_seconds=10, suppress_stream=False, until_running=False):
"""
Blocking call that will wait for the job to complete.
Expand All @@ -580,14 +580,19 @@ def wait(self, sleep_seconds=10, suppress_stream=False):
suppress_stream (bool, optional): If True, do not write anything to
the sys stream (stderr/stdout) while waiting for the job to
complete (default: False).
until_running (bool, optional): If True, only block until the job
status becomes 'RUNNING' (default: False).
Returns:
:py:class:`RunningJob`: self
"""

i = 0

while self._adapter.get_status(self._job_id).upper() in RUNNING_STATUSES:
statuses = {s for s in RUNNING_STATUSES \
if not until_running or s.upper() != 'RUNNING'}

while self._adapter.get_status(self._job_id).upper() in statuses:
if i % 3 == 0 and not suppress_stream:
self._write_to_stream('.')
time.sleep(sleep_seconds)
Expand Down
2 changes: 1 addition & 1 deletion genie-client/src/main/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

setup(
name='nflx-genie-client',
version='3.0.18',
version='3.0.19',
author='Netflix Inc.',
author_email='genieoss@googlegroups.com',
keywords='genie hadoop cloud netflix client bigdata presto',
Expand Down

0 comments on commit f143295

Please sign in to comment.