grz-cli 0.1.4__tar.gz → 0.3.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.
- {grz_cli-0.1.4 → grz_cli-0.3.0}/MANIFEST.in +2 -1
- {grz_cli-0.1.4/src/grz_cli.egg-info → grz_cli-0.3.0}/PKG-INFO +3 -2
- {grz_cli-0.1.4 → grz_cli-0.3.0}/pyproject.toml +10 -1
- grz_cli-0.3.0/src/grz_cli/__init__.py +1 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli/cli.py +8 -2
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli/parser.py +55 -9
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli/progress_logging.py +2 -1
- {grz_cli-0.1.4 → grz_cli-0.3.0/src/grz_cli.egg-info}/PKG-INFO +3 -2
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli.egg-info/SOURCES.txt +0 -3
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli.egg-info/requires.txt +1 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/tests/test_file_progress_logging.py +1 -1
- {grz_cli-0.1.4 → grz_cli-0.3.0}/tests/test_parser.py +5 -1
- grz_cli-0.1.4/src/grz_cli/models/__init__.py +0 -0
- grz_cli-0.1.4/src/grz_cli/models/v1_0_0/__init__.py +0 -0
- grz_cli-0.1.4/src/grz_cli/models/v1_0_0/metadata.py +0 -979
- grz_cli-0.1.4/src/grz_cli/resources/grz-schema.json +0 -595
- {grz_cli-0.1.4 → grz_cli-0.3.0}/LICENSE +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/README.md +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/setup.cfg +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/__init__.py +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli/constants.py +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli/download.py +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli/fastq_validation.py +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli/file_operations.py +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli/logging_setup.py +0 -0
- {grz_cli-0.1.4/src/grz_cli → grz_cli-0.3.0/src/grz_cli/models}/__init__.py +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli/models/config.py +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli/resources/thresholds.json +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli/states.py +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli/upload.py +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli.egg-info/dependency_links.txt +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli.egg-info/entry_points.txt +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/src/grz_cli.egg-info/top_level.txt +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/tests/test_cli.py +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/tests/test_download.py +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/tests/test_fastq_validation.py +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/tests/test_file_operations.py +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/tests/test_read_multiple_json.py +0 -0
- {grz_cli-0.1.4 → grz_cli-0.3.0}/tests/test_upload.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: grz-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Tool for validation, encryption and upload of MV submissions to GDCs.
|
|
5
5
|
Author-email: Koray Kirli <koraykirli@gmail.com>, Mathias Lesche <mathias.lesche@tu-dresden.de>, "Florian R. Hölzlwimmer" <git.ich@frhoelzlwimmer.de>, Till Hartmann <till.hartmann@bih-charite.de>, Thomas Sell <thomas.sell@bih-charite.de>
|
|
6
6
|
License: MIT
|
|
@@ -19,6 +19,7 @@ Requires-Dist: pyyaml<7,>=6.0.2
|
|
|
19
19
|
Requires-Dist: tqdm<5,>=4.66.5
|
|
20
20
|
Requires-Dist: pydantic<2.10,>=2.9.2
|
|
21
21
|
Requires-Dist: platformdirs<5,>=4.3.6
|
|
22
|
+
Requires-Dist: grz-pydantic-models>=1.2.0
|
|
22
23
|
Provides-Extra: test
|
|
23
24
|
Requires-Dist: pytest<9,>=8.3.3; extra == "test"
|
|
24
25
|
Requires-Dist: pytest-cov<6,>=5.0.0; extra == "test"
|
|
@@ -4,7 +4,6 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "grz-cli"
|
|
7
|
-
version = "0.1.4"
|
|
8
7
|
description = "Tool for validation, encryption and upload of MV submissions to GDCs."
|
|
9
8
|
readme = "README.md"
|
|
10
9
|
license = { text = "MIT" }
|
|
@@ -15,6 +14,7 @@ authors = [
|
|
|
15
14
|
{ name = "Till Hartmann", email = "till.hartmann@bih-charite.de" },
|
|
16
15
|
{ name = "Thomas Sell", email = "thomas.sell@bih-charite.de" },
|
|
17
16
|
]
|
|
17
|
+
dynamic = ["version"]
|
|
18
18
|
dependencies = [
|
|
19
19
|
"boto3 >=1.35.39,<2",
|
|
20
20
|
"click >=8.1.7,<9",
|
|
@@ -24,6 +24,7 @@ dependencies = [
|
|
|
24
24
|
"tqdm >=4.66.5,<5",
|
|
25
25
|
"pydantic >=2.9.2,<2.10",
|
|
26
26
|
"platformdirs >=4.3.6,<5",
|
|
27
|
+
"grz-pydantic-models >=1.2.0"
|
|
27
28
|
]
|
|
28
29
|
classifiers = [
|
|
29
30
|
"Programming Language :: Python :: 3",
|
|
@@ -33,6 +34,10 @@ classifiers = [
|
|
|
33
34
|
requires-python = ">=3.12"
|
|
34
35
|
keywords = ["GRZ", "GDC", "S3"]
|
|
35
36
|
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.dynamic]
|
|
39
|
+
version = { attr = "grz_cli.__version__" }
|
|
40
|
+
|
|
36
41
|
[project.urls]
|
|
37
42
|
"Homepage" = "https://codebase.helmholtz.cloud/grz-mv-genomseq/grz-cli"
|
|
38
43
|
|
|
@@ -193,6 +198,10 @@ python_version = "3.12"
|
|
|
193
198
|
plugins = "pydantic.mypy"
|
|
194
199
|
packages = "src"
|
|
195
200
|
|
|
201
|
+
[[tool.mypy.overrides]]
|
|
202
|
+
module = ["grz_pydantic_models.*"]
|
|
203
|
+
follow_untyped_imports = true
|
|
204
|
+
|
|
196
205
|
[tool.pytest.ini_options]
|
|
197
206
|
addopts = [
|
|
198
207
|
"--import-mode=importlib",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.0"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
CLI module for handling command-line interface operations.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
import importlib
|
|
5
6
|
import logging
|
|
6
7
|
import logging.config
|
|
7
8
|
import sys
|
|
@@ -10,6 +11,7 @@ from pathlib import Path
|
|
|
10
11
|
from tempfile import NamedTemporaryFile
|
|
11
12
|
|
|
12
13
|
import click
|
|
14
|
+
import grz_pydantic_models
|
|
13
15
|
import platformdirs
|
|
14
16
|
import yaml
|
|
15
17
|
|
|
@@ -107,7 +109,11 @@ class OrderedGroup(click.Group):
|
|
|
107
109
|
cls=OrderedGroup,
|
|
108
110
|
help="Validate, encrypt, decrypt and upload submissions to a GRZ/GDC.",
|
|
109
111
|
)
|
|
110
|
-
@click.version_option(
|
|
112
|
+
@click.version_option(
|
|
113
|
+
version=importlib.metadata.version("grz-cli"),
|
|
114
|
+
prog_name="grz-cli",
|
|
115
|
+
message=f"%(prog)s v%(version)s (metadata schema versions: {', '.join(grz_pydantic_models.get_supported_versions())})",
|
|
116
|
+
)
|
|
111
117
|
@click.option("--log-file", metavar="FILE", type=str, help="Path to log file")
|
|
112
118
|
@click.option(
|
|
113
119
|
"--log-level",
|
|
@@ -229,7 +235,7 @@ def decrypt(
|
|
|
229
235
|
log.error("GRZ private key path is required for decryption.")
|
|
230
236
|
sys.exit(1)
|
|
231
237
|
|
|
232
|
-
log.info("Starting
|
|
238
|
+
log.info("Starting decryption...")
|
|
233
239
|
|
|
234
240
|
submission_dir = Path(submission_dir)
|
|
235
241
|
|
|
@@ -9,13 +9,8 @@ from itertools import groupby
|
|
|
9
9
|
from os import PathLike
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
|
|
12
|
-
from
|
|
13
|
-
|
|
14
|
-
from .download import S3BotoDownloadWorker
|
|
15
|
-
from .fastq_validation import validate_paired_end_reads, validate_single_end_reads
|
|
16
|
-
from .file_operations import Crypt4GH, calculate_sha256
|
|
17
|
-
from .models.config import ConfigModel
|
|
18
|
-
from .models.v1_0_0.metadata import (
|
|
12
|
+
from grz_pydantic_models.v1_1_1.metadata import (
|
|
13
|
+
ChecksumType,
|
|
19
14
|
File,
|
|
20
15
|
FileType,
|
|
21
16
|
GrzSubmissionMetadata,
|
|
@@ -23,7 +18,13 @@ from .models.v1_0_0.metadata import (
|
|
|
23
18
|
SequenceData,
|
|
24
19
|
SequencingLayout,
|
|
25
20
|
)
|
|
26
|
-
from .
|
|
21
|
+
from grz_pydantic_models.v1_1_1.metadata import File as SubmissionFileMetadata
|
|
22
|
+
from pydantic import ValidationError
|
|
23
|
+
|
|
24
|
+
from .download import S3BotoDownloadWorker
|
|
25
|
+
from .fastq_validation import validate_paired_end_reads, validate_single_end_reads
|
|
26
|
+
from .file_operations import Crypt4GH, calculate_sha256
|
|
27
|
+
from .models.config import ConfigModel
|
|
27
28
|
from .progress_logging import FileProgressLogger
|
|
28
29
|
from .states import DecryptionState, EncryptionState, ValidationState
|
|
29
30
|
from .upload import S3BotoUploadWorker
|
|
@@ -168,6 +169,51 @@ class Submission:
|
|
|
168
169
|
|
|
169
170
|
return retval
|
|
170
171
|
|
|
172
|
+
@staticmethod
|
|
173
|
+
def validate_file_data(metadata: File, local_file_path: Path) -> Generator[str]:
|
|
174
|
+
"""
|
|
175
|
+
Validates whether the provided file matches this metadata.
|
|
176
|
+
|
|
177
|
+
:param metadata: Metadata model object
|
|
178
|
+
:param local_file_path: Path to the actual file (resolved if symlinked)
|
|
179
|
+
:return: Generator of errors
|
|
180
|
+
"""
|
|
181
|
+
# Resolve file path
|
|
182
|
+
local_file_path = local_file_path.resolve()
|
|
183
|
+
|
|
184
|
+
# Check if path exists
|
|
185
|
+
if not local_file_path.exists():
|
|
186
|
+
yield f"{str(metadata.file_path)} does not exist!"
|
|
187
|
+
# Return here as following tests cannot work
|
|
188
|
+
return
|
|
189
|
+
|
|
190
|
+
# Check if path is a file
|
|
191
|
+
if not local_file_path.is_file():
|
|
192
|
+
yield f"{str(metadata.file_path)} is not a file!"
|
|
193
|
+
# Return here as following tests cannot work
|
|
194
|
+
return
|
|
195
|
+
|
|
196
|
+
# Check if the checksum is correct
|
|
197
|
+
if metadata.checksum_type == "sha256":
|
|
198
|
+
calculated_checksum = calculate_sha256(local_file_path)
|
|
199
|
+
if metadata.file_checksum != calculated_checksum:
|
|
200
|
+
yield (
|
|
201
|
+
f"{str(metadata.file_path)}: Checksum mismatch! "
|
|
202
|
+
f"Expected: '{metadata.file_checksum}', calculated: '{calculated_checksum}'."
|
|
203
|
+
)
|
|
204
|
+
else:
|
|
205
|
+
yield (
|
|
206
|
+
f"{str(metadata.file_path)}: Unsupported checksum type: {metadata.checksum_type}. "
|
|
207
|
+
f"Supported types: {[e.value for e in ChecksumType]}"
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
# Check file size
|
|
211
|
+
if metadata.file_size_in_bytes != local_file_path.stat().st_size:
|
|
212
|
+
yield (
|
|
213
|
+
f"{str(metadata.file_path)}: File size mismatch! "
|
|
214
|
+
f"Expected: '{metadata.file_size_in_bytes}', observed: '{local_file_path.stat().st_size}'."
|
|
215
|
+
)
|
|
216
|
+
|
|
171
217
|
def validate_checksums(self, progress_log_file: str | PathLike) -> Generator[str]:
|
|
172
218
|
"""
|
|
173
219
|
Validates the checksum of the files against the metadata and prints the errors.
|
|
@@ -185,7 +231,7 @@ class Submission:
|
|
|
185
231
|
self.__log.debug("Validating '%s'...", str(local_file_path))
|
|
186
232
|
|
|
187
233
|
# validate the file
|
|
188
|
-
errors = list(
|
|
234
|
+
errors = list(self.validate_file_data(file_metadata, local_file_path))
|
|
189
235
|
validation_passed = len(errors) == 0
|
|
190
236
|
|
|
191
237
|
# return log state
|
|
@@ -9,8 +9,9 @@ from collections.abc import Callable
|
|
|
9
9
|
from os import PathLike
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
|
|
12
|
+
from grz_pydantic_models.v1_1_1.metadata import File as SubmissionFileMetadata
|
|
13
|
+
|
|
12
14
|
from .file_operations import read_multiple_json
|
|
13
|
-
from .models.v1_0_0.metadata import File as SubmissionFileMetadata
|
|
14
15
|
from .states import State
|
|
15
16
|
|
|
16
17
|
Index = tuple[str, float, int]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: grz-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Tool for validation, encryption and upload of MV submissions to GDCs.
|
|
5
5
|
Author-email: Koray Kirli <koraykirli@gmail.com>, Mathias Lesche <mathias.lesche@tu-dresden.de>, "Florian R. Hölzlwimmer" <git.ich@frhoelzlwimmer.de>, Till Hartmann <till.hartmann@bih-charite.de>, Thomas Sell <thomas.sell@bih-charite.de>
|
|
6
6
|
License: MIT
|
|
@@ -19,6 +19,7 @@ Requires-Dist: pyyaml<7,>=6.0.2
|
|
|
19
19
|
Requires-Dist: tqdm<5,>=4.66.5
|
|
20
20
|
Requires-Dist: pydantic<2.10,>=2.9.2
|
|
21
21
|
Requires-Dist: platformdirs<5,>=4.3.6
|
|
22
|
+
Requires-Dist: grz-pydantic-models>=1.2.0
|
|
22
23
|
Provides-Extra: test
|
|
23
24
|
Requires-Dist: pytest<9,>=8.3.3; extra == "test"
|
|
24
25
|
Requires-Dist: pytest-cov<6,>=5.0.0; extra == "test"
|
|
@@ -22,9 +22,6 @@ src/grz_cli.egg-info/requires.txt
|
|
|
22
22
|
src/grz_cli.egg-info/top_level.txt
|
|
23
23
|
src/grz_cli/models/__init__.py
|
|
24
24
|
src/grz_cli/models/config.py
|
|
25
|
-
src/grz_cli/models/v1_0_0/__init__.py
|
|
26
|
-
src/grz_cli/models/v1_0_0/metadata.py
|
|
27
|
-
src/grz_cli/resources/grz-schema.json
|
|
28
25
|
src/grz_cli/resources/thresholds.json
|
|
29
26
|
tests/test_cli.py
|
|
30
27
|
tests/test_download.py
|
|
@@ -5,9 +5,9 @@ import json
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
|
|
7
7
|
import pytest
|
|
8
|
+
from grz_pydantic_models.v1_1_1.metadata import File as SubmissionFileMetadata
|
|
8
9
|
|
|
9
10
|
from grz_cli.file_operations import read_multiple_json
|
|
10
|
-
from grz_cli.models.v1_0_0.metadata import File as SubmissionFileMetadata
|
|
11
11
|
from grz_cli.progress_logging import FileProgressLogger
|
|
12
12
|
|
|
13
13
|
|
|
@@ -11,6 +11,7 @@ metadata_missing_read_order = "tests/mock_files/metadata_validation/missing-read
|
|
|
11
11
|
metadata_missing_vcf_file = "tests/mock_files/metadata_validation/missing-vcf-file.json"
|
|
12
12
|
metadata_missing_fastq_r2 = "tests/mock_files/metadata_validation/missing-fastq-r2.json"
|
|
13
13
|
metadata_no_target_regions = "tests/mock_files/metadata_validation/missing-target-regions.json"
|
|
14
|
+
metadata_incompatible_reference_genomes = "tests/mock_files/metadata_validation/incompatible-reference-genomes.json"
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
def test_submission_metadata(temp_metadata_file_path):
|
|
@@ -33,9 +34,12 @@ def test_submission_metadata_fails():
|
|
|
33
34
|
with pytest.raises(error_types, match="VCF file missing for lab datum"):
|
|
34
35
|
SubmissionMetadata(metadata_missing_vcf_file)
|
|
35
36
|
|
|
36
|
-
with pytest.raises(error_types, match="Paired end sequencing layout but
|
|
37
|
+
with pytest.raises(error_types, match="Paired end sequencing layout but missing R2 file for flowcell id"):
|
|
37
38
|
SubmissionMetadata(metadata_missing_fastq_r2)
|
|
38
39
|
|
|
40
|
+
with pytest.raises(error_types, match="Incompatible reference genomes found"):
|
|
41
|
+
SubmissionMetadata(metadata_incompatible_reference_genomes)
|
|
42
|
+
|
|
39
43
|
|
|
40
44
|
def test_encrypted_submission():
|
|
41
45
|
input_path = "/submission/files/a.fastq"
|
|
File without changes
|
|
File without changes
|