snk-cli 0.3.3__tar.gz → 0.4.0__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.4.0}/PKG-INFO +4 -3
- {snk_cli-0.3.3 → snk_cli-0.4.0}/pyproject.toml +5 -4
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/__about__.py +1 -1
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/cli.py +12 -10
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/config/config.py +4 -1
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/subcommands/env.py +1 -7
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/subcommands/profile.py +21 -24
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/subcommands/run.py +4 -1
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/subcommands/script.py +0 -6
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/workflow.py +0 -54
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/test_cli/test_profile.py +5 -3
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/test_cli/test_run.py +1 -1
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/test_cli/test_snk_config.py +16 -1
- {snk_cli-0.3.3 → snk_cli-0.4.0}/.github/workflows/publish.yml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/.github/workflows/tests.yml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/.gitignore +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/LICENSE.txt +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/README.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/docs/index.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/docs/reference/cli.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/docs/reference/config.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/docs/reference/dynamic_typer.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/docs/reference/options.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/docs/reference/subcommands.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/docs/reference/testing.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/docs/reference/utils.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/docs/reference/validate.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/docs/reference/workflow.md +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/mkdocs.yml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/__init__.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/conda.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/config/__init__.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/config/utils.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/dynamic_typer.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/options/__init__.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/options/option.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/options/utils.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/subcommands/__init__.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/subcommands/config.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/testing.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/utils.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/src/snk_cli/validate.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/__init__.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/conftest.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/artic_v4.1.bed +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/config.yaml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/cov.fasta +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/print_config/Snakefile +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/print_config/cli.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/print_config/config.yaml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/print_config/snk.yaml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/workflow/cli.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/workflow/config.yaml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/workflow/resources/data.txt +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/workflow/snk.yaml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/workflow/things/__about__.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/workflow/workflow/Snakefile +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/workflow/workflow/envs/wget.yml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/workflow/workflow/profiles/base/config.yaml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/workflow/workflow/profiles/slurm/config.yaml +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/data/workflow/workflow/scripts/hello.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/test_cli/__init__.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/test_cli/test_dynamic_options.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/test_cli/test_subcommands.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/test_cli/test_validate.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/test_cli/test_workflow_cli.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/test_conda_env.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/test_dynamic_typer.py +0 -0
- {snk_cli-0.3.3 → snk_cli-0.4.0}/tests/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: snk-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Project-URL: Documentation, https://github.com/wytamma/snk-cli#readme
|
|
5
5
|
Project-URL: Issues, https://github.com/wytamma/snk-cli/issues
|
|
6
6
|
Project-URL: Source, https://github.com/wytamma/snk-cli
|
|
@@ -19,11 +19,12 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
|
19
19
|
Requires-Python: >=3.8
|
|
20
20
|
Requires-Dist: art~=5.9
|
|
21
21
|
Requires-Dist: datrie>=0.8.2
|
|
22
|
-
Requires-Dist: gitpython~=3.1
|
|
23
22
|
Requires-Dist: makefun~=1.15
|
|
24
23
|
Requires-Dist: pulp<2.8
|
|
24
|
+
Requires-Dist: rich>=10.11.0
|
|
25
|
+
Requires-Dist: shellingham>=1.3.0
|
|
25
26
|
Requires-Dist: snakemake>=7
|
|
26
|
-
Requires-Dist: typer
|
|
27
|
+
Requires-Dist: typer~=0.9
|
|
27
28
|
Description-Content-Type: text/markdown
|
|
28
29
|
|
|
29
30
|
# snk-cli
|
|
@@ -26,8 +26,9 @@ classifiers = [
|
|
|
26
26
|
]
|
|
27
27
|
dependencies = [
|
|
28
28
|
"snakemake>=7",
|
|
29
|
-
"typer
|
|
30
|
-
"
|
|
29
|
+
"typer~=0.9",
|
|
30
|
+
"shellingham >=1.3.0",
|
|
31
|
+
"rich >=10.11.0",
|
|
31
32
|
"pulp<2.8", # Pin pulp <2.8 for snakemake: https://github.com/snakemake/snakemake/issues/2607
|
|
32
33
|
"art~=5.9",
|
|
33
34
|
"makefun~=1.15",
|
|
@@ -44,13 +45,13 @@ path = "src/snk_cli/__about__.py"
|
|
|
44
45
|
|
|
45
46
|
|
|
46
47
|
[[tool.hatch.envs.snakemake.matrix]]
|
|
47
|
-
snakemake = ["7.32.4", "8
|
|
48
|
+
snakemake = ["==7.32.4", ">8"]
|
|
48
49
|
|
|
49
50
|
[tool.hatch.envs.default]
|
|
50
51
|
dependencies = [
|
|
51
52
|
"coverage[toml]>=6.5",
|
|
52
53
|
"pytest",
|
|
53
|
-
"snakemake
|
|
54
|
+
"snakemake{matrix:snakemake:==7.32.4}",
|
|
54
55
|
]
|
|
55
56
|
[tool.hatch.envs.default.scripts]
|
|
56
57
|
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,19 +53,24 @@ 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
|
|
59
60
|
)
|
|
60
61
|
else:
|
|
61
62
|
self.snk_config = snk_config
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
self.version = self.snk_config.version
|
|
64
|
+
if self.snk_config.configfile:
|
|
65
|
+
self.snakemake_config = load_configfile(self.snk_config.configfile)
|
|
66
|
+
else:
|
|
67
|
+
self.snakemake_config = load_workflow_snakemake_config(workflow_dir_path)
|
|
66
68
|
self.options = build_dynamic_cli_options(self.snakemake_config, self.snk_config)
|
|
67
|
-
|
|
69
|
+
# try to load the snakefile from the snakemake config
|
|
70
|
+
snakefile = self.snk_config.snakefile
|
|
71
|
+
if not snakefile:
|
|
72
|
+
snakefile = self._find_snakefile()
|
|
73
|
+
self.snakefile = snakefile
|
|
68
74
|
self.conda_prefix_dir = self.workflow.conda_prefix_dir
|
|
69
75
|
self.singularity_prefix_dir = self.workflow.singularity_prefix_dir
|
|
70
76
|
self.name = self.workflow.name
|
|
@@ -122,8 +128,6 @@ class CLI(DynamicTyper):
|
|
|
122
128
|
EnvApp(
|
|
123
129
|
workflow=self.workflow,
|
|
124
130
|
conda_prefix_dir=self.conda_prefix_dir,
|
|
125
|
-
snakemake_config=self.snakemake_config,
|
|
126
|
-
snakefile=self.snakefile,
|
|
127
131
|
),
|
|
128
132
|
name="env",
|
|
129
133
|
help="Access the workflow conda environments.",
|
|
@@ -133,8 +137,6 @@ class CLI(DynamicTyper):
|
|
|
133
137
|
ScriptApp(
|
|
134
138
|
workflow=self.workflow,
|
|
135
139
|
conda_prefix_dir=self.conda_prefix_dir,
|
|
136
|
-
snakemake_config=self.snakemake_config,
|
|
137
|
-
snakefile=self.snakefile,
|
|
138
140
|
),
|
|
139
141
|
name="script",
|
|
140
142
|
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
|
|
@@ -11,8 +11,7 @@ from snk_cli.conda import conda_environment_factory
|
|
|
11
11
|
from ..workflow import Workflow
|
|
12
12
|
from rich.console import Console
|
|
13
13
|
from rich.syntax import Syntax
|
|
14
|
-
from snakemake.deployment.conda import Conda,
|
|
15
|
-
from snk_cli.config.config import get_config_from_workflow_dir
|
|
14
|
+
from snakemake.deployment.conda import Conda, CreateCondaEnvironmentException
|
|
16
15
|
|
|
17
16
|
from concurrent.futures import ProcessPoolExecutor
|
|
18
17
|
|
|
@@ -42,14 +41,9 @@ class EnvApp(DynamicTyper):
|
|
|
42
41
|
self,
|
|
43
42
|
workflow: Workflow,
|
|
44
43
|
conda_prefix_dir: Path,
|
|
45
|
-
snakemake_config,
|
|
46
|
-
snakefile: Path,
|
|
47
44
|
):
|
|
48
45
|
self.workflow = workflow
|
|
49
46
|
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
47
|
self.register_command(self.list, help="List the environments in the workflow.")
|
|
54
48
|
self.register_command(self.show, help="Show the contents of an environment.")
|
|
55
49
|
self.register_command(
|
|
@@ -78,31 +78,28 @@ class ProfileApp(DynamicTyper):
|
|
|
78
78
|
import os
|
|
79
79
|
import platform
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
subprocess.
|
|
92
|
-
["which", e], stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
|
93
|
-
)
|
|
94
|
-
== 0
|
|
95
|
-
):
|
|
96
|
-
editor = e
|
|
97
|
-
break
|
|
98
|
-
if editor:
|
|
99
|
-
subprocess.call([editor, file_path])
|
|
100
|
-
else:
|
|
101
|
-
self.error(
|
|
102
|
-
"No suitable text editor found. Please install nano or vim."
|
|
81
|
+
if platform.system() == "Windows":
|
|
82
|
+
os.startfile(file_path)
|
|
83
|
+
elif platform.system() == "Darwin": # macOS
|
|
84
|
+
subprocess.call(("open", file_path))
|
|
85
|
+
else: # Linux and other Unix-like systems
|
|
86
|
+
editors = ["nano", "vim", "vi"]
|
|
87
|
+
editor = None
|
|
88
|
+
for e in editors:
|
|
89
|
+
if (
|
|
90
|
+
subprocess.call(
|
|
91
|
+
["which", e], stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
|
103
92
|
)
|
|
104
|
-
|
|
105
|
-
|
|
93
|
+
== 0
|
|
94
|
+
):
|
|
95
|
+
editor = e
|
|
96
|
+
break
|
|
97
|
+
if editor:
|
|
98
|
+
subprocess.call([editor, file_path])
|
|
99
|
+
else:
|
|
100
|
+
self.error(
|
|
101
|
+
"No suitable text editor found. Please install nano or vim."
|
|
102
|
+
)
|
|
106
103
|
|
|
107
104
|
def edit(self, name: str = typer.Argument(..., help="The name of the profile.")):
|
|
108
105
|
profile_path = self._get_profile_path(name)
|
|
@@ -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."
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
import sys
|
|
3
3
|
from typing import Optional
|
|
4
|
-
from git import Repo, InvalidGitRepositoryError
|
|
5
4
|
import importlib.util
|
|
6
5
|
import os
|
|
7
6
|
|
|
@@ -30,61 +29,8 @@ class Workflow:
|
|
|
30
29
|
"""
|
|
31
30
|
self.path = path
|
|
32
31
|
self.editable = self.check_is_editable()
|
|
33
|
-
if self.editable: # editable mode
|
|
34
|
-
self.repo = None
|
|
35
|
-
else:
|
|
36
|
-
try:
|
|
37
|
-
self.repo = Repo(path)
|
|
38
|
-
except InvalidGitRepositoryError:
|
|
39
|
-
self.repo = None
|
|
40
32
|
self.name = self.path.name
|
|
41
33
|
|
|
42
|
-
|
|
43
|
-
@property
|
|
44
|
-
def tag(self):
|
|
45
|
-
"""
|
|
46
|
-
Gets the tag of the workflow.
|
|
47
|
-
|
|
48
|
-
Returns:
|
|
49
|
-
str: The tag of the workflow, or None if no tag is found.
|
|
50
|
-
"""
|
|
51
|
-
try:
|
|
52
|
-
tag = self.repo.git.describe(["--tags", "--exact-match"])
|
|
53
|
-
except Exception:
|
|
54
|
-
tag = None
|
|
55
|
-
return tag
|
|
56
|
-
|
|
57
|
-
@property
|
|
58
|
-
def commit(self):
|
|
59
|
-
"""
|
|
60
|
-
Gets the commit SHA of the workflow.
|
|
61
|
-
|
|
62
|
-
Returns:
|
|
63
|
-
str: The commit SHA of the workflow.
|
|
64
|
-
"""
|
|
65
|
-
try:
|
|
66
|
-
sha = self.repo.head.object.hexsha
|
|
67
|
-
commit = self.repo.git.rev_parse(sha, short=8)
|
|
68
|
-
except Exception:
|
|
69
|
-
commit = None
|
|
70
|
-
return commit
|
|
71
|
-
|
|
72
|
-
@property
|
|
73
|
-
def version(self):
|
|
74
|
-
"""
|
|
75
|
-
Gets the version of the workflow.
|
|
76
|
-
|
|
77
|
-
Returns:
|
|
78
|
-
str: The version of the workflow, or None if no version is found.
|
|
79
|
-
"""
|
|
80
|
-
if self.repo is None:
|
|
81
|
-
return None
|
|
82
|
-
if self.tag:
|
|
83
|
-
version = self.tag
|
|
84
|
-
else:
|
|
85
|
-
version = self.commit
|
|
86
|
-
return version
|
|
87
|
-
|
|
88
34
|
@property
|
|
89
35
|
def executable(self):
|
|
90
36
|
"""
|
|
@@ -15,7 +15,8 @@ def mock_platform_system():
|
|
|
15
15
|
|
|
16
16
|
@pytest.fixture
|
|
17
17
|
def mock_os_startfile():
|
|
18
|
-
if platform
|
|
18
|
+
# Only patch os.startfile if the platform is Windows
|
|
19
|
+
if hasattr(os, 'startfile'):
|
|
19
20
|
with patch('os.startfile') as mock:
|
|
20
21
|
yield mock
|
|
21
22
|
else:
|
|
@@ -26,6 +27,7 @@ def mock_subprocess_call():
|
|
|
26
27
|
with patch('subprocess.call') as mock:
|
|
27
28
|
yield mock
|
|
28
29
|
|
|
30
|
+
@pytest.mark.skipif(platform.system() != 'Windows', reason="Requires Windows")
|
|
29
31
|
def test_open_text_editor_windows(mock_platform_system, mock_os_startfile, local_runner: SnkCliRunner):
|
|
30
32
|
mock_platform_system.return_value = 'Windows'
|
|
31
33
|
file_path = Path('tests/data/workflow/workflow/profiles/slurm/config.yaml')
|
|
@@ -48,7 +50,7 @@ def test_open_text_editor_linux(mock_platform_system, mock_subprocess_call, loca
|
|
|
48
50
|
file_path = Path('tests/data/workflow/workflow/profiles/slurm/config.yaml')
|
|
49
51
|
|
|
50
52
|
with patch('subprocess.call') as mock_call:
|
|
51
|
-
mock_call.side_effect = [1, 1, 0] # Mocking 'which' command results: nano not found, vim not found, vi found
|
|
53
|
+
mock_call.side_effect = [1, 1, 0, 0] # Mocking 'which' command results: nano not found, vim not found, vi found
|
|
52
54
|
|
|
53
55
|
res = local_runner(["profile", "edit", "slurm"])
|
|
54
56
|
assert res.exit_code == 0, res.stderr
|
|
@@ -65,5 +67,5 @@ def test_open_text_editor_no_editor_found(mock_platform_system, mock_subprocess_
|
|
|
65
67
|
|
|
66
68
|
with patch('typer.secho') as mock_print:
|
|
67
69
|
res = local_runner(["profile", "edit", "slurm"])
|
|
68
|
-
assert res.exit_code ==
|
|
70
|
+
assert res.exit_code == 1, res.stderr
|
|
69
71
|
mock_print.assert_called_once_with("No suitable text editor found. Please install nano or vim.", fg='red', err=True)
|
|
@@ -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
|