Skip to content
Permalink
Browse files

attempt support for old compute key in PIface; pepkit#184

  • Loading branch information...
vreuter committed May 20, 2019
1 parent c2fd06f commit a7ced87c73c75ec94f134ea8db35df8ad4a5e060
Showing with 20 additions and 2 deletions.
  1. +20 −2 looper/pipeline_interface.py
@@ -19,6 +19,7 @@
from .utils import get_logger
from attmap import PathExAttMap
from divvy import DEFAULT_COMPUTE_RESOURCES_NAME, NEW_COMPUTE_KEY as COMPUTE_KEY
from divvy.const import OLD_COMPUTE_KEY
from peppy import utils as peputil
from ubiquerg import expandpath

@@ -86,6 +87,18 @@ def __repr__(self):
return "{} from {}, with {} pipeline(s): {}".format(
self.__class__.__name__, source, num_pipelines, pipelines)

@property
def compute(self):
"""
Backcompat for compute section declaration in pipeline interface
:return attmap.PathExAttMap: nested key-value mapping that specifies
computing resource options
"""
warnings.warn(peputil.get_name_depr_msg(
OLD_COMPUTE_KEY, COMPUTE_KEY, self.__class__))
return self.get(COMPUTE_KEY, PathExAttMap())

def choose_resource_package(self, pipeline_name, file_size):
"""
Select resource bundle for given input file size to given pipeline.
@@ -115,11 +128,16 @@ def notify(msg):

pl = self.select_pipeline(pipeline_name)

universal_compute = {}
try:
universal_compute = pl[COMPUTE_KEY]
except KeyError:
notify("No compute settings")
notify("No compute settings (by {})".format(COMPUTE_KEY))
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
universal_compute = self.compute
if universal_compute:
warnings.warn(peputil.get_name_depr_msg(
OLD_COMPUTE_KEY, COMPUTE_KEY, self.__class__))

try:
resources = universal_compute[RESOURCES_KEY]

0 comments on commit a7ced87

Please sign in to comment.
You can’t perform that action at this time.