Skip to content

Commit

Permalink
♻️ Move _config_lookup method into ResourcePool
Browse files Browse the repository at this point in the history
  • Loading branch information
shnizzedy committed Jul 17, 2024
1 parent cf85273 commit 84274b9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions CPAC/pipeline/engine/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,6 @@ def json_outdir_ingress(

return json_info, pipe_idx, node_name, data_label

def _config_lookup(self, keylist, fallback_type: type = NoneType) -> Any:
"""Lookup a config key, return None if not found."""
try:
return self.cfg[keylist]
except (AttributeError, KeyError):
return fallback_type()

@staticmethod
def generate_prov_string(prov: LIST_OF_LIST_OF_STR | tuple) -> tuple[str, str]:
"""Generate a string from a SINGLE RESOURCE'S dictionary of MULTIPLE PRECEDING RESOURCES (or single, if just one).
Expand Down Expand Up @@ -2962,6 +2955,15 @@ def get_resource_strats_from_prov(prov: list | str) -> dict[str, list | str]:
strat_resource[resource] = entry
return strat_resource

def _config_lookup(
self, keylist: str | list[str], fallback_type: type = NoneType
) -> Any:
"""Lookup a config key, return None if not found."""
try:
return self.cfg[keylist]
except (AttributeError, KeyError):
return fallback_type()

def _get_pipe_number(self, pipe_idx: str | tuple) -> int:
"""Return the index of a strategy in ``self.pipe_list``."""
return self.pipe_list.index(pipe_idx)
Expand Down

0 comments on commit 84274b9

Please sign in to comment.