snk-cli 0.7.1__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.
Files changed (72) hide show
  1. snk_cli-0.7.2/.github/workflows/tests.yml +64 -0
  2. {snk_cli-0.7.1 → snk_cli-0.7.2}/PKG-INFO +4 -3
  3. {snk_cli-0.7.1 → snk_cli-0.7.2}/pyproject.toml +7 -2
  4. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/__about__.py +1 -1
  5. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/config/config.py +1 -1
  6. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/options/utils.py +8 -9
  7. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/validate.py +15 -4
  8. snk_cli-0.7.1/.github/workflows/tests.yml +0 -41
  9. {snk_cli-0.7.1 → snk_cli-0.7.2}/.github/workflows/publish.yml +0 -0
  10. {snk_cli-0.7.1 → snk_cli-0.7.2}/.gitignore +0 -0
  11. {snk_cli-0.7.1 → snk_cli-0.7.2}/LICENSE.txt +0 -0
  12. {snk_cli-0.7.1 → snk_cli-0.7.2}/README.md +0 -0
  13. {snk_cli-0.7.1 → snk_cli-0.7.2}/docs/index.md +0 -0
  14. {snk_cli-0.7.1 → snk_cli-0.7.2}/docs/reference/cli.md +0 -0
  15. {snk_cli-0.7.1 → snk_cli-0.7.2}/docs/reference/config.md +0 -0
  16. {snk_cli-0.7.1 → snk_cli-0.7.2}/docs/reference/dynamic_typer.md +0 -0
  17. {snk_cli-0.7.1 → snk_cli-0.7.2}/docs/reference/options.md +0 -0
  18. {snk_cli-0.7.1 → snk_cli-0.7.2}/docs/reference/subcommands.md +0 -0
  19. {snk_cli-0.7.1 → snk_cli-0.7.2}/docs/reference/testing.md +0 -0
  20. {snk_cli-0.7.1 → snk_cli-0.7.2}/docs/reference/utils.md +0 -0
  21. {snk_cli-0.7.1 → snk_cli-0.7.2}/docs/reference/validate.md +0 -0
  22. {snk_cli-0.7.1 → snk_cli-0.7.2}/docs/reference/workflow.md +0 -0
  23. {snk_cli-0.7.1 → snk_cli-0.7.2}/mkdocs.yml +0 -0
  24. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/__init__.py +0 -0
  25. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/cli.py +0 -0
  26. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/conda.py +0 -0
  27. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/config/__init__.py +0 -0
  28. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/config/utils.py +0 -0
  29. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/dynamic_typer.py +0 -0
  30. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/options/__init__.py +0 -0
  31. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/options/option.py +0 -0
  32. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/subcommands/__init__.py +0 -0
  33. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/subcommands/config.py +0 -0
  34. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/subcommands/env.py +0 -0
  35. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/subcommands/profile.py +0 -0
  36. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/subcommands/run.py +0 -0
  37. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/subcommands/script.py +0 -0
  38. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/testing.py +0 -0
  39. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/utils.py +0 -0
  40. {snk_cli-0.7.1 → snk_cli-0.7.2}/src/snk_cli/workflow.py +0 -0
  41. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/__init__.py +0 -0
  42. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/conftest.py +0 -0
  43. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/artic_v4.1.bed +0 -0
  44. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/config.yaml +0 -0
  45. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/cov.fasta +0 -0
  46. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/print_config/Snakefile +0 -0
  47. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/print_config/cli.py +0 -0
  48. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/print_config/config.yaml +0 -0
  49. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/print_config/snk.yaml +0 -0
  50. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/workflow/cli.py +0 -0
  51. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/workflow/config.yaml +0 -0
  52. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/workflow/resources/data.txt +0 -0
  53. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/workflow/snk.yaml +0 -0
  54. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/workflow/things/__about__.py +0 -0
  55. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/workflow/workflow/Snakefile +0 -0
  56. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/workflow/workflow/envs/wget.yml +0 -0
  57. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/workflow/workflow/profiles/base/config.yaml +0 -0
  58. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/workflow/workflow/profiles/slurm/config.yaml +0 -0
  59. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/data/workflow/workflow/scripts/hello.py +0 -0
  60. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/test_SnkConfig.py +0 -0
  61. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/test_cli/__init__.py +0 -0
  62. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/test_cli/test_dynamic_options.py +0 -0
  63. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/test_cli/test_profile.py +0 -0
  64. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/test_cli/test_run.py +0 -0
  65. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/test_cli/test_snk_config.py +0 -0
  66. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/test_cli/test_subcommands.py +0 -0
  67. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/test_cli/test_validate.py +0 -0
  68. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/test_cli/test_workflow_cli.py +0 -0
  69. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/test_conda_env.py +0 -0
  70. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/test_dynamic_typer.py +0 -0
  71. {snk_cli-0.7.1 → snk_cli-0.7.2}/tests/test_types.py +0 -0
  72. {snk_cli-0.7.1 → 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.3
1
+ Metadata-Version: 2.4
2
2
  Name: snk-cli
3
- Version: 0.7.1
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", ">8"]
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 = [
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2024-present Wytamma Wirth <wytamma.wirth@me.com>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "0.7.1"
4
+ __version__ = "0.7.2"
@@ -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 in `snk.yaml` file: {invalid_config_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
- types = {
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, str]": dict[str, str],
25
- "dict[str, int]": dict[str, int],
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
- types[f"pair[{t1.__name__}, {t2.__name__}]"] = Tuple[t1, t2]
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
@@ -68,10 +67,10 @@ def create_option_from_annotation(
68
67
  updated = True
69
68
  annotation_type = annotation_values.get(f"{annotation_key}:type", None)
70
69
  if annotation_type is not None:
71
- annotation_type = annotation_type.lower()
72
- assert annotation_type in types, f"Type '{annotation_type}' not supported."
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."
73
72
  annotation_type = (annotation_type or get_default_type(default)).lower()
74
- annotation_type = types.get(
73
+ annotation_type = allowed_option_types.get(
75
74
  annotation_type, List[str] if "list" in annotation_type else str
76
75
  )
77
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 types
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 = types.get(val_info["type"].lower(), None)
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
- assert len(value) == 2, f"Expected a list of length 2 for key '{key}'"
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}': {e}")
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)
@@ -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