Skip to content

Commit

Permalink
Merge pull request #450 from pepkit/fix-divvy-yacman
Browse files Browse the repository at this point in the history
finish removing attmap from divvy
  • Loading branch information
nsheff committed Feb 2, 2024
2 parents 380de82 + 5ee9a73 commit 9a5220d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
31 changes: 17 additions & 14 deletions looper/divvy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
import sys
import shutil
import yaml
from yaml import SafeLoader
from shutil import copytree


from shutil import copytree
from yacman import YAMLConfigManager as YAMLConfigManager
from yacman import FILEPATH_KEY, load_yaml, select_config
from yaml import SafeLoader
from ubiquerg import is_writable, VersionInHelpParser
import yacman


from .const import (
COMPUTE_SETTINGS_VARNAME,
Expand All @@ -28,7 +31,7 @@
# This is the divvy.py submodule from divvy


class ComputingConfiguration(yacman.YAMLConfigManager):
class ComputingConfiguration(YAMLConfigManager):
"""
Represents computing configuration objects.
Expand Down Expand Up @@ -73,7 +76,7 @@ def __init__(self, entries=None, filepath=None):

def write(self, filename=None):
super(ComputingConfiguration, self).write(filepath=filename, exclude_case=True)
filename = filename or getattr(self, yacman.FILEPATH_KEY)
filename = filename or getattr(self, FILEPATH_KEY)
filedir = os.path.dirname(filename)
# For this object, we *also* have to write the template files
for pkg_name, pkg in self["compute_packages"].items():
Expand Down Expand Up @@ -151,7 +154,7 @@ def activate_package(self, package_name):
# Augment compute, creating it if needed.
if self.compute is None:
_LOGGER.debug("Creating Project compute")
self.compute = yacman.YAMLConfigManager()
self.compute = YAMLConfigManager()
_LOGGER.debug(
"Adding entries for package_name '{}'".format(package_name)
)
Expand Down Expand Up @@ -200,11 +203,11 @@ def clean_start(self, package_name):
self.reset_active_settings()
return self.activate_package(package_name)

def get_active_package(self):
def get_active_package(self) -> YAMLConfigManager:
"""
Returns settings for the currently active compute package
:return yacman.YacAttMap: data defining the active compute package
:return YAMLConfigManager: data defining the active compute package
"""
return self.compute

Expand All @@ -222,7 +225,7 @@ def reset_active_settings(self):
:return bool: success flag
"""
self.compute = yacman.YacAttMap()
self.compute = YAMLConfigManager()
return True

def update_packages(self, config_file):
Expand All @@ -235,11 +238,11 @@ def update_packages(self, config_file):
:param str config_file: path to file with new divvy configuration data
"""
entries = yacman.load_yaml(config_file)
entries = load_yaml(config_file)
self.update(entries)
return True

def get_adapters(self):
def get_adapters(self) -> YAMLConfigManager:
"""
Get current adapters, if defined.
Expand All @@ -248,9 +251,9 @@ def get_adapters(self):
package-specific set of adapters, if any defined in 'adapters' section
under currently active compute package.
:return yacman.YAMLConfigManager: current adapters mapping
:return YAMLConfigManager: current adapters mapping
"""
adapters = yacman.YAMLConfigManager()
adapters = YAMLConfigManager()
if "adapters" in self and self["adapters"] is not None:
adapters.update(self["adapters"])
if "compute" in self and "adapters" in self.compute:
Expand Down Expand Up @@ -376,7 +379,7 @@ def select_divvy_config(filepath):
:param str | NoneType filepath: direct file path specification
:return str: path to the config file to read
"""
divcfg = yacman.select_config(
divcfg = select_config(
config_filepath=filepath,
config_env_vars=COMPUTE_SETTINGS_VARNAME,
default_config_filepath=DEFAULT_CONFIG_FILEPATH,
Expand Down
18 changes: 9 additions & 9 deletions tests/smoketests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ def test_looper_single_pipeline(self, prep_temp_pep):
pifaces = config_data[SAMPLE_MODS_KEY][CONSTANT_KEY][
PIPELINE_INTERFACES_KEY
]
config_data[SAMPLE_MODS_KEY][CONSTANT_KEY][
PIPELINE_INTERFACES_KEY
] = pifaces[1]
config_data[SAMPLE_MODS_KEY][CONSTANT_KEY][PIPELINE_INTERFACES_KEY] = (
pifaces[1]
)

x = test_args_expansion(tp, "run")
try:
Expand All @@ -140,9 +140,9 @@ def test_looper_var_templates(self, prep_temp_pep):
pifaces = config_data[SAMPLE_MODS_KEY][CONSTANT_KEY][
PIPELINE_INTERFACES_KEY
]
config_data[SAMPLE_MODS_KEY][CONSTANT_KEY][
PIPELINE_INTERFACES_KEY
] = pifaces[1]
config_data[SAMPLE_MODS_KEY][CONSTANT_KEY][PIPELINE_INTERFACES_KEY] = (
pifaces[1]
)
x = test_args_expansion(tp, "run")
try:
# Test that {looper.piface_dir} is correctly rendered to a path which will show up in the final .sub file
Expand Down Expand Up @@ -211,9 +211,9 @@ def test_looper_pipeline_invalid(self, prep_temp_pep):
pifaces = config_data[SAMPLE_MODS_KEY][CONSTANT_KEY][
PIPELINE_INTERFACES_KEY
]
config_data[SAMPLE_MODS_KEY][CONSTANT_KEY][
PIPELINE_INTERFACES_KEY
] = pifaces[1]
config_data[SAMPLE_MODS_KEY][CONSTANT_KEY][PIPELINE_INTERFACES_KEY] = (
pifaces[1]
)
piface_path = os.path.join(os.path.dirname(tp), pifaces[1])
with mod_yaml_data(piface_path) as piface_data:
del piface_data["pipeline_name"]
Expand Down

0 comments on commit 9a5220d

Please sign in to comment.