Skip to content

Commit

Permalink
Revert "fix tests #334"
Browse files Browse the repository at this point in the history
This reverts commit a1640f2.
  • Loading branch information
donaldcampbelljr committed Jun 19, 2024
1 parent a1640f2 commit e8f8801
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 41 deletions.
38 changes: 3 additions & 35 deletions looper/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,13 @@
_LOGGER = logging.getLogger(__name__)


def _get_yaml_path(
namespaces,
template_key,
template_subkey=None,
default_name_appendix="",
filename=None,
):
def _get_yaml_path(namespaces, template_key, default_name_appendix="", filename=None):
"""
Get a path to a YAML file for the sample.
:param dict[dict]] namespaces: namespaces mapping
:param str template_key: the name of the key in 'var_templates' piface
section that points to a template to render to get the
user-provided target YAML path OR it is a 1st level key.
:param str template_subkey: the name of the key nested under template_key that that points to a template to render to get the
user-provided target YAML path
:param str default_name_appendix: a string to append to insert in target
YAML file name: '{sample.sample_name}<>.yaml'
Expand All @@ -60,33 +52,11 @@ def _get_yaml_path(
if (
VAR_TEMPL_KEY in namespaces["pipeline"]
and template_key in namespaces["pipeline"][VAR_TEMPL_KEY]
and template_subkey in namespaces["pipeline"][VAR_TEMPL_KEY][template_key]
):
_LOGGER.debug(f"Sample namespace: {namespaces['sample']}")
x = jinja_render_template_strictly("{sample.sample_name}", namespaces)
_LOGGER.debug(f"x: {x}")
cpy = namespaces["pipeline"][VAR_TEMPL_KEY][template_key][template_subkey]
_LOGGER.debug(f"cpy: {cpy}")
path = expandpath(jinja_render_template_strictly(cpy, namespaces))
_LOGGER.debug(f"path: {path}")

if not path.endswith(SAMPLE_YAML_EXT) and not filename:
raise ValueError(
f"{template_key} is not a valid target YAML file path. "
f"It needs to end with: {' or '.join(SAMPLE_YAML_EXT)}"
)
final_path = os.path.join(path, filename) if filename else path
if not os.path.exists(os.path.dirname(final_path)):
os.makedirs(os.path.dirname(final_path), exist_ok=True)

elif (
VAR_TEMPL_KEY in namespaces["pipeline"]
and template_subkey in namespaces["pipeline"][VAR_TEMPL_KEY]
):
_LOGGER.debug(f"Sample namespace: {namespaces['sample']}")
x = jinja_render_template_strictly("{sample.sample_name}", namespaces)
_LOGGER.debug(f"x: {x}")
cpy = namespaces["pipeline"][VAR_TEMPL_KEY][template_subkey]
cpy = namespaces["pipeline"][VAR_TEMPL_KEY][template_key]
_LOGGER.debug(f"cpy: {cpy}")
path = expandpath(jinja_render_template_strictly(cpy, namespaces))
_LOGGER.debug(f"path: {path}")
Expand Down Expand Up @@ -146,9 +116,7 @@ def write_submission_yaml(namespaces):
:param dict namespaces: variable namespaces dict
:return dict: sample namespace dict
"""
path = _get_yaml_path(
namespaces, "write_submission_yaml", SAMPLE_CWL_YAML_PATH_KEY, "_submission"
)
path = _get_yaml_path(namespaces, SAMPLE_CWL_YAML_PATH_KEY, "_submission")
my_namespaces = {}
for namespace, values in namespaces.items():
my_namespaces.update({str(namespace): dict(values)})
Expand Down
10 changes: 4 additions & 6 deletions looper/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ def write_sample_yaml_prj(namespaces):
"""
sample = namespaces["sample"]
sample.to_yaml(
_get_yaml_path(
namespaces, "write_sample_yaml_prj", SAMPLE_YAML_PRJ_PATH_KEY, "_sample_prj"
),
_get_yaml_path(namespaces, SAMPLE_YAML_PRJ_PATH_KEY, "_sample_prj"),
add_prj_ref=True,
)
return {"sample": sample}
Expand Down Expand Up @@ -56,7 +54,7 @@ def load_template(pipeline):

tpl = load_template(namespaces["pipeline"])
content = tpl.render(namespaces)
pth = _get_yaml_path(namespaces, "custom_template_output", None, "config")
pth = _get_yaml_path(namespaces, "custom_template_output", "config")
namespaces["sample"]["custom_template_output"] = pth
with open(pth, "wb") as fh:
# print(content)
Expand Down Expand Up @@ -97,7 +95,7 @@ def _get_schema_source(
# File and Directory object types directly.
sample = namespaces["sample"]
sample.sample_yaml_cwl = _get_yaml_path(
namespaces, "write_sample_yaml_cwl", SAMPLE_CWL_YAML_PATH_KEY, "_sample_cwl"
namespaces, SAMPLE_CWL_YAML_PATH_KEY, "_sample_cwl"
)

if "input_schema" in namespaces["pipeline"]:
Expand Down Expand Up @@ -156,7 +154,7 @@ def write_sample_yaml(namespaces):
"""
sample = namespaces["sample"]
sample["sample_yaml_path"] = _get_yaml_path(
namespaces, "write_sample_yaml", SAMPLE_YAML_PATH_KEY, "_sample"
namespaces, SAMPLE_YAML_PATH_KEY, "_sample"
)
sample.to_yaml(sample["sample_yaml_path"], add_prj_ref=False)
return {"sample": sample}

0 comments on commit e8f8801

Please sign in to comment.