Skip to content
This repository has been archived by the owner on Aug 13, 2018. It is now read-only.

Commit

Permalink
copy docstrings for now
Browse files Browse the repository at this point in the history
  • Loading branch information
quasiben committed Feb 8, 2016
1 parent fe87413 commit 8ff8407
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 17 deletions.
58 changes: 50 additions & 8 deletions knit/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
from subprocess import Popen, PIPE

from .utils import parse_xml, inherit_docstring_from
from .utils import parse_xml
from .env import CondaCreator
from .compatibility import FileNotFoundError, urlparse
from .exceptions import HDFSConfigException
Expand Down Expand Up @@ -238,14 +238,56 @@ def create_env(env_name, packages=None, conda_root=None, remove=False):

return path

@inherit_docstring_from(YARNAPI)
def logs(self, app_id, shell=False):
self.yarn_api.logs(app_id, shell=shell)
"""
Collect logs from RM (if running)
With shell=True, collect logs from HDFS after job completion
Parameters
----------
app_id: str
A yarn application ID string
shell: bool
Shell out to yarn CLI (default False)
Returns
-------
log: dictionary
logs from each container (when possible)
"""
return self.yarn_api.logs(app_id, shell=shell)

@inherit_docstring_from(YARNAPI)
def kill(self, app_id):
self.yarn_api.kill(app_id)
"""
Method to kill a yarn application
Parameters
----------
app_id: str
YARN application id
@inherit_docstring_from(YARNAPI)
def status(self, app_id, shell=False):
self.yarn_api.status(app_id, shell=shell)
Returns
-------
bool:
True if successful, False otherwise.
"""
return self.yarn_api.kill(app_id)

def status(self, app_id):
""" Get status of an application
Parameters
----------
app_id: str
A yarn application ID string
Returns
-------
log: dictionary
status of application
"""
return self.yarn_api.status(app_id)

@property
def apps(self):
return self.yarn_api.apps
10 changes: 1 addition & 9 deletions knit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

format = ('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logging.basicConfig(format=format, level=logging.INFO)

logging.getLogger("requests").setLevel(logging.WARNING)

def set_logging(level):
logger = logging.getLogger('knit')
Expand Down Expand Up @@ -83,11 +83,3 @@ def shell_out(cmd=None):
result of shell command
"""
return subprocess.check_output(cmd).decode('utf-8')


# https://groups.google.com/forum/#!topic/comp.lang.python/HkB1uhDcvdk
def inherit_docstring_from(cls):
def docstring_inheriting_decorator(fn):
fn.__doc__ = getattr(cls,fn.__name__).__doc__
return fn
return docstring_inheriting_decorator

0 comments on commit 8ff8407

Please sign in to comment.