Skip to content
Snippets Groups Projects
Commit 38953f3c authored by John Chilton's avatar John Chilton
Browse files

Improve logging and commenting for base DRMAA manager.

 - Fixup docstrings.
 - Log native specification and source if conflicting.
parent 8ad0fbeb
No related branches found
No related tags found
No related merge requests found
from .external import ExternalBaseManager """Module defines a base class for Pulsar managers using DRMAA."""
from ..util.drmaa import DrmaaSessionFactory import logging
from pulsar.managers import status
try: try:
from drmaa import JobState from drmaa import JobState
except (OSError, ImportError): except (OSError, ImportError):
JobState = None JobState = None
import logging from .external import ExternalBaseManager
from ..util.drmaa import DrmaaSessionFactory
from pulsar.managers import status
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
IGNORE_SUBMISSION_SPEC_MESSAGE = "Submission recieved native_specification but being overridden by manager specification."
class BaseDrmaaManager(ExternalBaseManager): class BaseDrmaaManager(ExternalBaseManager):
"""Base class for Pulsar managers using DRMAA."""
def __init__(self, name, app, **kwds): def __init__(self, name, app, **kwds):
"""Setup native specification and drmaa session factory."""
super(BaseDrmaaManager, self).__init__(name, app, **kwds) super(BaseDrmaaManager, self).__init__(name, app, **kwds)
self.native_specification = kwds.get('native_specification', None) self.native_specification = kwds.get('native_specification', None)
drmaa_session_factory_class = kwds.get('drmaa_session_factory_class', DrmaaSessionFactory) drmaa_session_factory_class = kwds.get('drmaa_session_factory_class', DrmaaSessionFactory)
...@@ -21,6 +29,7 @@ class BaseDrmaaManager(ExternalBaseManager): ...@@ -21,6 +29,7 @@ class BaseDrmaaManager(ExternalBaseManager):
self.drmaa_session = drmaa_session_factory.get() self.drmaa_session = drmaa_session_factory.get()
def shutdown(self, timeout=None): def shutdown(self, timeout=None):
"""Cleanup DRMAA session and call shutdown of parent."""
try: try:
super(BaseDrmaaManager, self).shutdown(timeout) super(BaseDrmaaManager, self).shutdown(timeout)
except Exception: except Exception:
...@@ -52,8 +61,20 @@ class BaseDrmaaManager(ExternalBaseManager): ...@@ -52,8 +61,20 @@ class BaseDrmaaManager(ExternalBaseManager):
"outputPath": ":%s" % stdout_path, "outputPath": ":%s" % stdout_path,
"errorPath": ":%s" % stderr_path, "errorPath": ":%s" % stderr_path,
} }
submit_native_specification = submit_params.get("native_specification", None)
native_specification = None
if self.native_specification: if self.native_specification:
attributes["nativeSpecification"] = self.native_specification native_specification = self.native_specification
elif submit_params.get("native_specification", None): if submit_native_specification is not None:
attributes["nativeSpecification"] = submit_params["native_specification"] log.warn(IGNORE_SUBMISSION_SPEC_MESSAGE)
elif submit_native_specification:
native_specification = submit_params["native_specification"]
if native_specification is not None:
attributes["nativeSpecification"] = native_specification
log.info("Submitting DRMAA job with nativeSpecification [%s]" % native_specification)
else:
log.debug("Not native specification supplied, DRMAA job will be submitted with default parameters.")
return attributes return attributes
__all__ = ["BaseDrmaaManager"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment