Skip to content
Permalink
Browse files
fix: fix pepfile handling in case of module usage (#1387)
* fix: fix pepfile handling in case of module usage

* skip on win
  • Loading branch information
johanneskoester committed Feb 9, 2022
1 parent 7a8da9f commit f097a761472248d779113cdb22b5274395828bcb
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 11 deletions.
@@ -248,7 +248,9 @@ class Configfile(GlobalKeywordState):


class Pepfile(GlobalKeywordState):
pass
@property
def keyword(self):
return "set_pepfile"


class Pepschema(GlobalKeywordState):
@@ -1241,40 +1241,36 @@ def workdir(self, workdir):

def configfile(self, fp):
"""Update the global config with data from the given file."""
global config
if not self.modifier.skip_configfile:
if os.path.exists(fp):
self.configfiles.append(fp)
c = snakemake.io.load_configfile(fp)
update_config(config, c)
update_config(self.config, c)
if self.overwrite_config:
logger.info(
"Config file {} is extended by additional config specified via the command line.".format(
fp
)
)
update_config(config, self.overwrite_config)
update_config(self.config, self.overwrite_config)
elif not self.overwrite_configfiles:
raise WorkflowError(
"Workflow defines configfile {} but it is not present or accessible.".format(
fp
)
)

def pepfile(self, path):
global pep
def set_pepfile(self, path):

try:
import peppy
except ImportError:
raise WorkflowError("For PEP support, please install peppy.")

self.pepfile = path
pep = peppy.Project(self.pepfile)
self.globals["pep"] = peppy.Project(self.pepfile)

def pepschema(self, schema):
global pep

try:
import eido
except ImportError:
@@ -1285,7 +1281,9 @@ def pepschema(self, schema):
schema = self.current_basedir.join(schema).get_path_or_uri()
if self.pepfile is None:
raise WorkflowError("Please specify a PEP with the pepfile directive.")
eido.validate_project(project=pep, schema=schema, exclude_case=True)
eido.validate_project(
project=self.globals["pep"], schema=schema, exclude_case=True
)

def report(self, path):
"""Define a global report description in .rst format."""
@@ -0,0 +1,15 @@
shell.executable("bash")

configfile: "config/config.yaml"


module test:
snakefile:
"module-test/Snakefile"
config:
config
prefix:
"foo"


use rule * from test
@@ -0,0 +1,2 @@
test: 1
pepfile: "pep/config.yaml"
@@ -0,0 +1 @@
1
@@ -0,0 +1,14 @@
configfile: "config.yaml" # does not exist, but this statement should be ignored on module import
pepfile: config["pepfile"]

def some_func():
return 15

print(pep)

rule a:
output:
"results/test.out",
"/tmp/foo.txt"
shell:
"echo {config[test]} > {output[0]}; touch {output[1]}"
@@ -0,0 +1,2 @@
pep_version: "2.0.0"
sample_table: sample_table.csv
@@ -0,0 +1,3 @@
sample_name,protocol
a,test
b,test2
@@ -1,5 +1,7 @@
pepfile: "pep/config.yaml"
pepschema: "schemas/pep.yaml"
pepfile: "pep/config.yaml" # test overwriting

pepschema: "workflow/schemas/pep.yaml"

rule all:
input:
Empty file.
Empty file.
@@ -1289,6 +1289,11 @@ def test_modules_prefix():
run(dpath("test_modules_prefix"), targets=["a"])


@skip_on_windows
def test_modules_peppy():
run(dpath("test_modules_peppy"), targets=["a"])


def test_modules_specific():
run(dpath("test_modules_specific"), targets=["test_a"])

@@ -1427,3 +1432,8 @@ def test_github_issue1384():
)
finally:
shutil.rmtree(tmpdir)


@skip_on_windows
def test_peppy():
run(dpath("test_peppy"))

0 comments on commit f097a76

Please sign in to comment.