Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RunningJob update info for certain properties when job is running - Python client #306

Merged
merged 1 commit into from
Jul 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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