snk-cli 0.3.3__tar.gz → 0.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {snk_cli-0.3.3 → snk_cli-0.3.4}/PKG-INFO +1 -1
- {snk_cli-0.3.3 → snk_cli-0.3.4}/pyproject.toml +2 -2
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/__about__.py +1 -1
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/cli.py +12 -6
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/config/config.py +4 -1
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/subcommands/env.py +0 -5
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/subcommands/run.py +4 -1
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/subcommands/script.py +0 -6
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/test_cli/test_run.py +1 -1
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/test_cli/test_snk_config.py +16 -1
- {snk_cli-0.3.3 → snk_cli-0.3.4}/.github/workflows/publish.yml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/.github/workflows/tests.yml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/.gitignore +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/LICENSE.txt +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/README.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/docs/index.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/docs/reference/cli.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/docs/reference/config.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/docs/reference/dynamic_typer.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/docs/reference/options.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/docs/reference/subcommands.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/docs/reference/testing.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/docs/reference/utils.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/docs/reference/validate.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/docs/reference/workflow.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/mkdocs.yml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/__init__.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/conda.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/config/__init__.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/config/utils.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/dynamic_typer.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/options/__init__.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/options/option.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/options/utils.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/subcommands/__init__.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/subcommands/config.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/subcommands/profile.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/testing.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/utils.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/validate.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/src/snk_cli/workflow.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/__init__.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/conftest.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/artic_v4.1.bed +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/config.yaml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/cov.fasta +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/print_config/Snakefile +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/print_config/cli.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/print_config/config.yaml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/print_config/snk.yaml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/workflow/cli.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/workflow/config.yaml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/workflow/resources/data.txt +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/workflow/snk.yaml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/workflow/things/__about__.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/workflow/workflow/Snakefile +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/workflow/workflow/envs/wget.yml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/workflow/workflow/profiles/base/config.yaml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/workflow/workflow/profiles/slurm/config.yaml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/data/workflow/workflow/scripts/hello.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/test_cli/__init__.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/test_cli/test_dynamic_options.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/test_cli/test_profile.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/test_cli/test_subcommands.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/test_cli/test_validate.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/test_cli/test_workflow_cli.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/test_conda_env.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/test_dynamic_typer.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.3.4}/tests/utils.py +0 -0
|
@@ -44,13 +44,13 @@ path = "src/snk_cli/__about__.py"
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
[[tool.hatch.envs.snakemake.matrix]]
|
|
47
|
-
snakemake = ["7.32.4", "8
|
|
47
|
+
snakemake = ["==7.32.4", ">8"]
|
|
48
48
|
|
|
49
49
|
[tool.hatch.envs.default]
|
|
50
50
|
dependencies = [
|
|
51
51
|
"coverage[toml]>=6.5",
|
|
52
52
|
"pytest",
|
|
53
|
-
"snakemake
|
|
53
|
+
"snakemake{matrix:snakemake:==7.32.4}",
|
|
54
54
|
]
|
|
55
55
|
[tool.hatch.envs.default.scripts]
|
|
56
56
|
test = "pytest {args:tests}"
|
|
@@ -15,6 +15,7 @@ from snk_cli.config.config import (
|
|
|
15
15
|
SnkConfig,
|
|
16
16
|
load_workflow_snakemake_config,
|
|
17
17
|
)
|
|
18
|
+
from snk_cli.config.utils import load_configfile
|
|
18
19
|
from snk_cli.options.utils import build_dynamic_cli_options
|
|
19
20
|
from snk_cli.workflow import Workflow
|
|
20
21
|
|
|
@@ -52,7 +53,7 @@ class CLI(DynamicTyper):
|
|
|
52
53
|
if workflow_dir_path.is_file():
|
|
53
54
|
workflow_dir_path = workflow_dir_path.parent
|
|
54
55
|
self.workflow = Workflow(path=workflow_dir_path)
|
|
55
|
-
|
|
56
|
+
|
|
56
57
|
if snk_config is None:
|
|
57
58
|
self.snk_config = SnkConfig.from_workflow_dir(
|
|
58
59
|
workflow_dir_path, create_if_not_exists=True
|
|
@@ -63,8 +64,17 @@ class CLI(DynamicTyper):
|
|
|
63
64
|
self.version = self.workflow.version
|
|
64
65
|
else:
|
|
65
66
|
self.version = self.snk_config.version
|
|
67
|
+
if self.snk_config.configfile:
|
|
68
|
+
self.snakemake_config = load_configfile(self.snk_config.configfile)
|
|
69
|
+
else:
|
|
70
|
+
self.snakemake_config = load_workflow_snakemake_config(workflow_dir_path)
|
|
66
71
|
self.options = build_dynamic_cli_options(self.snakemake_config, self.snk_config)
|
|
67
|
-
self.
|
|
72
|
+
print(self.options)
|
|
73
|
+
# try to load the snakefile from the snakemake config
|
|
74
|
+
snakefile = self.snk_config.snakefile
|
|
75
|
+
if not snakefile:
|
|
76
|
+
snakefile = self._find_snakefile()
|
|
77
|
+
self.snakefile = snakefile
|
|
68
78
|
self.conda_prefix_dir = self.workflow.conda_prefix_dir
|
|
69
79
|
self.singularity_prefix_dir = self.workflow.singularity_prefix_dir
|
|
70
80
|
self.name = self.workflow.name
|
|
@@ -122,8 +132,6 @@ class CLI(DynamicTyper):
|
|
|
122
132
|
EnvApp(
|
|
123
133
|
workflow=self.workflow,
|
|
124
134
|
conda_prefix_dir=self.conda_prefix_dir,
|
|
125
|
-
snakemake_config=self.snakemake_config,
|
|
126
|
-
snakefile=self.snakefile,
|
|
127
135
|
),
|
|
128
136
|
name="env",
|
|
129
137
|
help="Access the workflow conda environments.",
|
|
@@ -133,8 +141,6 @@ class CLI(DynamicTyper):
|
|
|
133
141
|
ScriptApp(
|
|
134
142
|
workflow=self.workflow,
|
|
135
143
|
conda_prefix_dir=self.conda_prefix_dir,
|
|
136
|
-
snakemake_config=self.snakemake_config,
|
|
137
|
-
snakefile=self.snakefile,
|
|
138
144
|
),
|
|
139
145
|
name="script",
|
|
140
146
|
help="Access the workflow scripts.",
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
from typing import List, Optional
|
|
3
|
-
import snakemake
|
|
4
3
|
from dataclasses import dataclass, field
|
|
5
4
|
from .utils import get_version_from_config, load_configfile
|
|
6
5
|
import yaml
|
|
@@ -72,6 +71,8 @@ class SnkConfig:
|
|
|
72
71
|
skip_missing: bool = False # skip any missing cli options (i.e. those not in the snk file)
|
|
73
72
|
additional_snakemake_args: List[str] = field(default_factory=list)
|
|
74
73
|
commands: List[str] = field(default_factory=lambda: ["run", "script", "env", "profile", "info", "config"])
|
|
74
|
+
snakefile: Optional[Path] = None
|
|
75
|
+
configfile: Optional[Path] = None
|
|
75
76
|
cli: dict = field(default_factory=dict)
|
|
76
77
|
_snk_config_path: Path = None
|
|
77
78
|
|
|
@@ -113,6 +114,8 @@ class SnkConfig:
|
|
|
113
114
|
]
|
|
114
115
|
snk_config.validate_resources(snk_config.resources)
|
|
115
116
|
snk_config._snk_config_path = snk_config_path
|
|
117
|
+
snk_config.snakefile = Path(snk_config.snakefile) if snk_config.snakefile else None
|
|
118
|
+
snk_config.configfile = Path(snk_config.configfile) if snk_config.configfile else None
|
|
116
119
|
return snk_config
|
|
117
120
|
|
|
118
121
|
@classmethod
|
|
@@ -42,14 +42,9 @@ class EnvApp(DynamicTyper):
|
|
|
42
42
|
self,
|
|
43
43
|
workflow: Workflow,
|
|
44
44
|
conda_prefix_dir: Path,
|
|
45
|
-
snakemake_config,
|
|
46
|
-
snakefile: Path,
|
|
47
45
|
):
|
|
48
46
|
self.workflow = workflow
|
|
49
47
|
self.conda_prefix_dir = conda_prefix_dir
|
|
50
|
-
self.snakemake_config = snakemake_config
|
|
51
|
-
self.snakefile = snakefile
|
|
52
|
-
self.configfile = get_config_from_workflow_dir(self.workflow.path)
|
|
53
48
|
self.register_command(self.list, help="List the environments in the workflow.")
|
|
54
49
|
self.register_command(self.show, help="Show the contents of an environment.")
|
|
55
50
|
self.register_command(
|
|
@@ -197,7 +197,10 @@ class RunApp(DynamicTyper):
|
|
|
197
197
|
args.append(f"--snakefile={self.snakefile}")
|
|
198
198
|
|
|
199
199
|
if not configfile:
|
|
200
|
-
|
|
200
|
+
if self.snk_config.configfile:
|
|
201
|
+
configfile = self.snk_config.configfile
|
|
202
|
+
else:
|
|
203
|
+
configfile = get_config_from_workflow_dir(self.workflow.path)
|
|
201
204
|
if configfile:
|
|
202
205
|
args.append(f"--configfile={configfile}")
|
|
203
206
|
|
|
@@ -11,7 +11,6 @@ from ..workflow import Workflow
|
|
|
11
11
|
from rich.console import Console
|
|
12
12
|
from rich.syntax import Syntax
|
|
13
13
|
from snakemake.deployment.conda import Conda
|
|
14
|
-
from snk_cli.config.config import get_config_from_workflow_dir
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
class ScriptApp(DynamicTyper):
|
|
@@ -19,14 +18,9 @@ class ScriptApp(DynamicTyper):
|
|
|
19
18
|
self,
|
|
20
19
|
workflow: Workflow,
|
|
21
20
|
conda_prefix_dir: Path,
|
|
22
|
-
snakemake_config,
|
|
23
|
-
snakefile: Path,
|
|
24
21
|
):
|
|
25
22
|
self.workflow = workflow
|
|
26
23
|
self.conda_prefix_dir = conda_prefix_dir
|
|
27
|
-
self.snakemake_config = snakemake_config
|
|
28
|
-
self.snakefile = snakefile
|
|
29
|
-
self.configfile = get_config_from_workflow_dir(self.workflow.path)
|
|
30
24
|
self.register_command(self.list, help="List the scripts in the workflow.")
|
|
31
25
|
self.register_command(
|
|
32
26
|
self.show, help="Show the contents of a script."
|
|
@@ -47,4 +47,4 @@ def test_snakemake_help(local_runner: SnkCliRunner):
|
|
|
47
47
|
def test_snakemake_version(local_runner: SnkCliRunner):
|
|
48
48
|
res = local_runner(["run", "--snake-v"])
|
|
49
49
|
assert res.exit_code == 0, res.stderr
|
|
50
|
-
assert res.stdout
|
|
50
|
+
assert res.stdout.startswith("7.32.4") or res.stdout.startswith("8.")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from snk_cli.config import SnkConfig
|
|
2
2
|
from ..utils import dynamic_runner
|
|
3
|
-
|
|
3
|
+
from pathlib import Path
|
|
4
4
|
|
|
5
5
|
def test_skip_missing(tmp_path):
|
|
6
6
|
runner = dynamic_runner({"missing": True}, SnkConfig(skip_missing=True, cli={"visible": {"help": "visible"}}), tmp_path=tmp_path)
|
|
@@ -27,3 +27,18 @@ def test_snk_config_commands_run_only(tmp_path):
|
|
|
27
27
|
assert "script" not in res.stdout, res.stderr
|
|
28
28
|
assert "profile" not in res.stdout, res.stderr
|
|
29
29
|
|
|
30
|
+
def test_non_standard_snakefile(tmp_path):
|
|
31
|
+
with open(tmp_path / "Snakefile2", "w") as f:
|
|
32
|
+
f.write("print('Snakefile2')")
|
|
33
|
+
runner = dynamic_runner({}, SnkConfig(snakefile=tmp_path / "Snakefile2"), tmp_path=tmp_path)
|
|
34
|
+
res = runner.invoke(["run"])
|
|
35
|
+
assert res.exit_code == 0, res.stderr
|
|
36
|
+
assert "Snakefile2" in res.stdout, res.stderr
|
|
37
|
+
|
|
38
|
+
def test_non_standard_configfile(tmp_path):
|
|
39
|
+
with open(tmp_path / "config2.yaml", "w") as f:
|
|
40
|
+
f.write("value: config2")
|
|
41
|
+
runner = dynamic_runner({}, SnkConfig(configfile=tmp_path / "config2.yaml"), tmp_path=tmp_path)
|
|
42
|
+
res = runner.invoke(["run"])
|
|
43
|
+
assert res.exit_code == 0, res.stderr
|
|
44
|
+
assert "config2" in res.stdout, res.stderr
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|