snk-cli 0.7.0__tar.gz → 0.7.2__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.7.2/.github/workflows/tests.yml +64 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/PKG-INFO +4 -3
- {snk_cli-0.7.0 → snk_cli-0.7.2}/pyproject.toml +7 -2
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/__about__.py +1 -1
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/config/config.py +1 -1
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/options/utils.py +10 -10
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/validate.py +15 -4
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/test_cli/test_dynamic_options.py +11 -0
- snk_cli-0.7.0/.github/workflows/tests.yml +0 -41
- {snk_cli-0.7.0 → snk_cli-0.7.2}/.github/workflows/publish.yml +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/.gitignore +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/LICENSE.txt +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/README.md +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/docs/index.md +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/docs/reference/cli.md +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/docs/reference/config.md +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/docs/reference/dynamic_typer.md +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/docs/reference/options.md +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/docs/reference/subcommands.md +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/docs/reference/testing.md +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/docs/reference/utils.md +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/docs/reference/validate.md +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/docs/reference/workflow.md +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/mkdocs.yml +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/__init__.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/cli.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/conda.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/config/__init__.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/config/utils.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/dynamic_typer.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/options/__init__.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/options/option.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/subcommands/__init__.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/subcommands/config.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/subcommands/env.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/subcommands/profile.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/subcommands/run.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/subcommands/script.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/testing.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/utils.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/src/snk_cli/workflow.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/__init__.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/conftest.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/artic_v4.1.bed +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/config.yaml +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/cov.fasta +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/print_config/Snakefile +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/print_config/cli.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/print_config/config.yaml +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/print_config/snk.yaml +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/workflow/cli.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/workflow/config.yaml +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/workflow/resources/data.txt +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/workflow/snk.yaml +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/workflow/things/__about__.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/workflow/workflow/Snakefile +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/workflow/workflow/envs/wget.yml +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/workflow/workflow/profiles/base/config.yaml +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/workflow/workflow/profiles/slurm/config.yaml +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/data/workflow/workflow/scripts/hello.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/test_SnkConfig.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/test_cli/__init__.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/test_cli/test_profile.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/test_cli/test_run.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/test_cli/test_snk_config.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/test_cli/test_subcommands.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/test_cli/test_validate.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/test_cli/test_workflow_cli.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/test_conda_env.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/test_dynamic_typer.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/test_types.py +0 -0
- {snk_cli-0.7.0 → snk_cli-0.7.2}/tests/utils.py +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
name: tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
- main
|
|
8
|
+
pull_request:
|
|
9
|
+
branches:
|
|
10
|
+
- "*"
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: write
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
test:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
strategy:
|
|
19
|
+
matrix:
|
|
20
|
+
python-version: [3.8, 3.9, "3.10", 3.11, 3.12]
|
|
21
|
+
snakemake-version: ["==7.32.4", ">8"]
|
|
22
|
+
exclude:
|
|
23
|
+
# Exclude incompatible combinations
|
|
24
|
+
- python-version: 3.8
|
|
25
|
+
snakemake-version: ">8"
|
|
26
|
+
- python-version: 3.9
|
|
27
|
+
snakemake-version: ">8"
|
|
28
|
+
- python-version: "3.10"
|
|
29
|
+
snakemake-version: ">8"
|
|
30
|
+
steps:
|
|
31
|
+
- name: Checkout repository
|
|
32
|
+
uses: actions/checkout@v4
|
|
33
|
+
with:
|
|
34
|
+
fetch-depth: 0
|
|
35
|
+
|
|
36
|
+
- name: Set up conda
|
|
37
|
+
uses: conda-incubator/setup-miniconda@v3
|
|
38
|
+
with:
|
|
39
|
+
auto-activate-base: false
|
|
40
|
+
channels: conda-forge,bioconda,defaults
|
|
41
|
+
channel-priority: strict
|
|
42
|
+
|
|
43
|
+
- name: Install pip dependencies
|
|
44
|
+
run: |
|
|
45
|
+
pip install hatch
|
|
46
|
+
|
|
47
|
+
- name: Install system dependencies
|
|
48
|
+
run: |
|
|
49
|
+
sudo apt-get update
|
|
50
|
+
sudo apt-get install -y llvm clang build-essential graphviz
|
|
51
|
+
|
|
52
|
+
- name: Run tests
|
|
53
|
+
env:
|
|
54
|
+
AR: /usr/bin/ar
|
|
55
|
+
shell: bash
|
|
56
|
+
run: |
|
|
57
|
+
hatch python install ${{ matrix.python-version }}
|
|
58
|
+
hatch --env "snakemake.py${{ matrix.python-version }}-${{ matrix.snakemake-version }}" run cov
|
|
59
|
+
|
|
60
|
+
- name: Upload coverage reports to Codecov
|
|
61
|
+
uses: codecov/codecov-action@v3
|
|
62
|
+
with:
|
|
63
|
+
files: ./coverage.xml
|
|
64
|
+
flags: ${{ matrix.python-version }}-snakemake-${{ matrix.snakemake-version }}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: snk-cli
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.2
|
|
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
|
|
7
7
|
Author-email: Wytamma Wirth <wytamma.wirth@me.com>
|
|
8
|
-
License: MIT
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE.txt
|
|
9
10
|
Classifier: Development Status :: 4 - Beta
|
|
10
11
|
Classifier: Programming Language :: Python
|
|
11
12
|
Classifier: Programming Language :: Python :: 3.8
|
|
@@ -45,7 +45,12 @@ path = "src/snk_cli/__about__.py"
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
[[tool.hatch.envs.snakemake.matrix]]
|
|
48
|
-
snakemake = ["==7.32.4"
|
|
48
|
+
snakemake = ["==7.32.4"] # Compatible with Python 3.9–3.12
|
|
49
|
+
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
|
50
|
+
|
|
51
|
+
[[tool.hatch.envs.snakemake.matrix]]
|
|
52
|
+
snakemake = [">8"] # Compatible only with Python 3.11 and 3.12
|
|
53
|
+
python = ["3.11", "3.12"]
|
|
49
54
|
|
|
50
55
|
[tool.hatch.envs.default]
|
|
51
56
|
dependencies = [
|
|
@@ -66,7 +71,7 @@ cov = [
|
|
|
66
71
|
]
|
|
67
72
|
|
|
68
73
|
[[tool.hatch.envs.all.matrix]]
|
|
69
|
-
python = ["3.9", "3.10", "3.11", "3.12"]
|
|
74
|
+
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
|
70
75
|
|
|
71
76
|
[tool.hatch.envs.types]
|
|
72
77
|
dependencies = [
|
|
@@ -117,7 +117,7 @@ class SnkConfig:
|
|
|
117
117
|
invalid_config_keys = set(snk_config_dict.keys()) - fields
|
|
118
118
|
if invalid_config_keys:
|
|
119
119
|
import warnings
|
|
120
|
-
warnings.warn(f"invalid keys
|
|
120
|
+
warnings.warn(f"""invalid keys '{" ".join(invalid_config_keys)}' in {snk_config_path}.""")
|
|
121
121
|
# filer out any invalid keys
|
|
122
122
|
snk_config_dict = {k: v for k, v in snk_config_dict.items() if k in fields}
|
|
123
123
|
snk_config = cls(**snk_config_dict)
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
from typing import List, Tuple, get_origin
|
|
1
|
+
from typing import Dict, List, Tuple, get_origin
|
|
2
2
|
from ..config.config import SnkConfig
|
|
3
3
|
from ..utils import get_default_type, flatten
|
|
4
4
|
from .option import Option
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from enum import Enum
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
allowed_option_types = {
|
|
9
8
|
"int": int,
|
|
10
9
|
"integer": int,
|
|
11
10
|
"float": float,
|
|
@@ -21,8 +20,8 @@ types = {
|
|
|
21
20
|
"list[float]": List[float],
|
|
22
21
|
"pair": Tuple[str, str],
|
|
23
22
|
"dict": dict,
|
|
24
|
-
"dict[str,
|
|
25
|
-
"dict[str,
|
|
23
|
+
"dict[str,str]": Dict[str, str],
|
|
24
|
+
"dict[str,int]": Dict[str, int],
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
# Define the basic types for the combinations
|
|
@@ -31,7 +30,7 @@ basic_types = [int, str, bool, float]
|
|
|
31
30
|
# Add the combinations of the basic types to the `types` dictionary
|
|
32
31
|
for t1 in basic_types:
|
|
33
32
|
for t2 in basic_types:
|
|
34
|
-
|
|
33
|
+
allowed_option_types[f"pair[{t1.__name__},{t2.__name__}]"] = Tuple[t1, t2]
|
|
35
34
|
|
|
36
35
|
def get_keys_from_annotation(annotations):
|
|
37
36
|
# Get the unique keys from the annotations
|
|
@@ -67,10 +66,11 @@ def create_option_from_annotation(
|
|
|
67
66
|
if config_default is None or default != config_default:
|
|
68
67
|
updated = True
|
|
69
68
|
annotation_type = annotation_values.get(f"{annotation_key}:type", None)
|
|
70
|
-
if annotation_type is not None:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
annotation_type =
|
|
69
|
+
if annotation_type is not None:
|
|
70
|
+
annotation_type = annotation_type.lower().replace(" ", "")
|
|
71
|
+
assert annotation_type in allowed_option_types, f"Type '{annotation_type}' for '{annotation_key}' is not supported."
|
|
72
|
+
annotation_type = (annotation_type or get_default_type(default)).lower()
|
|
73
|
+
annotation_type = allowed_option_types.get(
|
|
74
74
|
annotation_type, List[str] if "list" in annotation_type else str
|
|
75
75
|
)
|
|
76
76
|
name = annotation_values.get(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
from typing import Any, Dict, Union, get_origin
|
|
3
3
|
from .config import SnkConfig
|
|
4
|
-
from .options.utils import
|
|
4
|
+
from .options.utils import allowed_option_types
|
|
5
5
|
import inspect
|
|
6
6
|
|
|
7
7
|
class ValidationError(Exception):
|
|
@@ -52,24 +52,35 @@ def validate_and_transform_in_place(config: Dict[str, Any], validation: Validati
|
|
|
52
52
|
val_info = validation[key]
|
|
53
53
|
if isinstance(val_info, dict) and 'type' in val_info:
|
|
54
54
|
# Direct type validation
|
|
55
|
-
val_type =
|
|
55
|
+
val_type = allowed_option_types.get(val_info["type"].lower().replace(" ", ""), None)
|
|
56
56
|
if val_type is None:
|
|
57
57
|
raise ValueError(f"Unknown type '{val_info['type']}'")
|
|
58
58
|
try:
|
|
59
59
|
if getattr(val_type, "__origin__", None) is list:
|
|
60
|
+
# List e.g. List[str]
|
|
60
61
|
val_type = val_type.__args__[0]
|
|
61
62
|
if not isinstance(value, list):
|
|
62
63
|
raise ValueError(f"Expected a list for key '{key}'")
|
|
63
64
|
config[key] = [val_type(v) for v in value]
|
|
64
65
|
elif get_origin(val_type) is tuple:
|
|
65
|
-
|
|
66
|
+
# Tuple e.g. Tuple[str, int]
|
|
67
|
+
assert len(value) == 2, f"Tuple type should have 2 elements for key '{key}'"
|
|
66
68
|
key_type = val_type.__args__[0]
|
|
67
69
|
val_type = val_type.__args__[1]
|
|
68
70
|
config[key] = [key_type(value[0]), val_type(value[1])]
|
|
71
|
+
elif get_origin(val_type) is dict:
|
|
72
|
+
# Dict e.g. Dict[str, int]
|
|
73
|
+
if val_type.__args__ is None:
|
|
74
|
+
config[key] = value
|
|
75
|
+
continue
|
|
76
|
+
assert len(val_type.__args__) == 2, f"Dict type should have 2 arguments for key '{key}'"
|
|
77
|
+
val_type = val_type.__args__[1]
|
|
78
|
+
config[key] = {k: val_type(v) for k, v in value.items()}
|
|
69
79
|
else:
|
|
80
|
+
# basic
|
|
70
81
|
config[key] = val_type(value)
|
|
71
82
|
except (ValueError, TypeError) as e:
|
|
72
|
-
raise ValueError(f"Type conversion error for key '{key}'
|
|
83
|
+
raise ValueError(f"Type conversion error for key '{key}' ({val_info['type']}). Could not convert value '{value}' to type '{val_type}'.") from e
|
|
73
84
|
elif isinstance(value, dict):
|
|
74
85
|
# Nested dictionary validation
|
|
75
86
|
validate_and_transform_in_place(value, val_info)
|
|
@@ -38,6 +38,17 @@ def test_create_option_from_annotation(
|
|
|
38
38
|
assert option.type is str
|
|
39
39
|
assert option.required is True
|
|
40
40
|
|
|
41
|
+
|
|
42
|
+
def test_create_option_from_annotation_type_Case_insensitive(
|
|
43
|
+
default_annotation_values, default_default_values
|
|
44
|
+
):
|
|
45
|
+
default_annotation_values["test:type"] = "STR"
|
|
46
|
+
option = create_option_from_annotation(
|
|
47
|
+
"test", default_annotation_values, default_default_values
|
|
48
|
+
)
|
|
49
|
+
assert option.type is str
|
|
50
|
+
|
|
51
|
+
|
|
41
52
|
def test_create_option_from_annotation_with_short(
|
|
42
53
|
default_annotation_values, default_default_values
|
|
43
54
|
):
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
name: tests
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- master
|
|
7
|
-
- main
|
|
8
|
-
permissions:
|
|
9
|
-
contents: write
|
|
10
|
-
jobs:
|
|
11
|
-
test:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v4
|
|
15
|
-
with:
|
|
16
|
-
fetch-depth: 0
|
|
17
|
-
- uses: "conda-incubator/setup-miniconda@v2"
|
|
18
|
-
with:
|
|
19
|
-
python-version: 3.11
|
|
20
|
-
auto-activate-base: false
|
|
21
|
-
miniforge-variant: Mambaforge
|
|
22
|
-
channels: conda-forge,bioconda,defaults
|
|
23
|
-
channel-priority: strict
|
|
24
|
-
auto-update-conda: true
|
|
25
|
-
- uses: actions/setup-python@v5
|
|
26
|
-
with:
|
|
27
|
-
python-version: '3.11'
|
|
28
|
-
- uses: actions/cache@v2
|
|
29
|
-
with:
|
|
30
|
-
key: ${{ github.ref }}
|
|
31
|
-
path: .cache
|
|
32
|
-
- run: pip install hatch
|
|
33
|
-
- run: sudo apt-get update && sudo apt-get install -y llvm
|
|
34
|
-
- run: sudo apt-get -y install graphviz
|
|
35
|
-
- name: Run tests
|
|
36
|
-
shell: bash
|
|
37
|
-
run: hatch run snakemake:cov
|
|
38
|
-
- name: Upload coverage reports to Codecov
|
|
39
|
-
uses: codecov/codecov-action@v3
|
|
40
|
-
|
|
41
|
-
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|