Skip to content

Commit

Permalink
RunningJob update info for certain properties when job is running - P…
Browse files Browse the repository at this point in the history
…ython client
  • Loading branch information
irontablee committed Jul 8, 2016
1 parent b13ce96 commit cb7b093
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
4 changes: 2 additions & 2 deletions genie-client/src/main/python/pygenie/jobs/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def hiveconf(self, name, value):
Example:
>>> # hive --hiveconf mapred.foo=fizz --hiveconf mapred.bar=buzz
>>> job = HiveJob() \\
... .property('mapred.foo', 'fizz') \\
... .property('mapred.bar', 'buzz')
... .hiveconf('mapred.foo', 'fizz') \\
... .hiveconf('mapred.bar', 'buzz')
Args:
name (str): The property name.
Expand Down
30 changes: 26 additions & 4 deletions genie-client/src/main/python/pygenie/jobs/running.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,34 @@
import sys
import time

from functools import wraps

from ..conf import GenieConf
from ..utils import dttm_to_epoch


logger = logging.getLogger('com.netflix.genie.jobs.running')


def update_info(func):
"""
Update information about the job.
"""

@wraps(func)
def wrapper(*args, **kwargs):
"""Wraps func."""

self = args[0]
status = self._info.get('status')
if status is None or status.upper() == 'RUNNING':
self.update()

return func(*args, **kwargs)

return wrapper


class RunningJob(object):
"""RunningJob."""

Expand Down Expand Up @@ -143,6 +164,7 @@ def file_dependencies(self):
return self.info.get('file_dependencies')

@property
@update_info
def finish_time(self):
"""
Get the job's finish epoch time (milliseconds). 0 means the job is still
Expand Down Expand Up @@ -201,8 +223,6 @@ def is_done(self):
boolean: True if the job is done, False if still running.
"""

if self.status == 'RUNNING':
self.update()
return self.status != 'RUNNING'

@property
Expand All @@ -218,8 +238,6 @@ def is_successful(self):
boolean: True if job completed successfully, False otherwise.
"""

if not self.is_done:
self.update()
return self.status == 'SUCCEEDED'

@property
Expand Down Expand Up @@ -365,6 +383,7 @@ def request_data(self):
return self.info.get('request_data')

@property
@update_info
def start_time(self):
"""
Get the job's start epoch time (milliseconds).
Expand All @@ -380,6 +399,7 @@ def start_time(self):
return self.__convert_dttm_to_epoch('started')

@property
@update_info
def status(self):
"""
Get the job's status.
Expand Down Expand Up @@ -448,6 +468,7 @@ def stdout(self, iterator=False):
return self._adapter.get_stdout(self._job_id, iterator=iterator)

@property
@update_info
def status_msg(self):
"""
Get the job's status message.
Expand Down Expand Up @@ -484,6 +505,7 @@ def update(self, info=None):
else self._adapter.get_info_for_rj(self._job_id)

@property
@update_info
def update_time(self):
"""
Get the last update time for the job in epoch time (milliseconds).
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.12',
version='3.0.13',
author='Netflix Inc.',
author_email='genieoss@googlegroups.com',
keywords='genie hadoop cloud netflix client bigdata presto',
Expand Down

0 comments on commit cb7b093

Please sign in to comment.