pepkit / peppy

Project metadata manager for PEPs in Python
https://pep.databio.org/peppy
BSD 2-Clause "Simplified" License
37 stars 12 forks source link

Env variables in config file are not expanding #464

Closed donaldcampbelljr closed 7 months ago

donaldcampbelljr commented 7 months ago

Looking at pep-pipelines for snakemake integration:

https://github.com/pepkit/pep-pipelines/blob/805cbc75ca2dfdf57bfee412987816e5f7c52d0a/pipelines/pep-snakemake/simple/examples/wc_config.yaml#L1-L11

name: snakemake-line-count

pep_version: 2.0.0
sample_table: wc_sample_table.csv
output_dir: $HOME/pep-snakemake/simple/examples

sample_modifiers:
  derive:
    attributes: [filename]
    sources:
      F: $CODE/pep-snakemake/simple/examples/{sample_name}.txt

The environment variables are not being expanded. I confirmed that, if I add the absolute path manually, the pipeline works fine.

Using peppy v0.40.0a5

nsheff commented 7 months ago

probably due to change; the new yacman requires you to use .exp to expand variables and this may not have been updated somewhere

khoroshevskyi commented 7 months ago

We weren't using yacman. That's why all config paths weren't expanding. I tried to change it to yacman using following lines of code: image

But If I am running pytests outside the pycharm, all of the tests start to fail. It's very weird behavior. Otherwise everything works fine

The error that I am getting:

TestSample.test_pickle_in_samples[basic] ____________________________________________________________________________________________

self = <tests.smoketests.test_Sample.TestSample object at 0x7f3e1242ee60>, example_pep_cfg_path = '/home/alex/databio/repos/peppy/tests/data/example_peps-master/example_basic/project_config.yaml'

    @pytest.mark.parametrize("example_pep_cfg_path", ["basic"], indirect=True)
    def test_pickle_in_samples(self, example_pep_cfg_path):
        import pickle

>       p = Project(cfg=example_pep_cfg_path)

tests/smoketests/test_Sample.py:74: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
peppy/project.py:132: in __init__
    self.parse_config_file(cfg, amendments)
peppy/project.py:361: in parse_config_file
    config = yacman.YAMLConfigManager(filepath=cfg_path)
../../venv/peppy/lib/python3.10/site-packages/yacman/yacman1.py:135: in __init__
    with self as _:
../../venv/peppy/lib/python3.10/site-packages/yacman/yacman1.py:248: in __enter__
    signal(SIGTERM, self._interrupt_handler)
/usr/lib/python3.10/signal.py:57: in signal
    return _int_to_enum(handler, Handlers)
/usr/lib/python3.10/signal.py:29: in _int_to_enum
    return enum_klass(value)
/usr/lib/python3.10/enum.py:385: in __call__
    return cls.__new__(cls, value)
/usr/lib/python3.10/enum.py:708: in __new__
    ve_exc = ValueError("%r is not a valid %s" % (value, cls.__qualname__))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <[AttributeError("'YAMLConfigManager' object has no attribute 'data'") raised in repr()] YAMLConfigManager object at 0x7f3e116ed780>

    def __repr__(self):
        # Here we want to render the data in a nice way; and we want to indicate
        # the class if it's NOT a YacAttMap. If it is a YacAttMap we just want
        # to give you the data without the class name.
>       return self.to_yaml(self.data)
E       AttributeError: 'YAMLConfigManager' object has no attribute 'data'

../../venv/peppy/lib/python3.10/site-packages/yacman/yacman1.py:241: AttributeError