grz-cli 0.2.0__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.3.0/LICENSE +21 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/MANIFEST.in +2 -1
- {grz_cli-0.2.0/src/grz_cli.egg-info → grz_cli-0.3.0}/PKG-INFO +3 -2
- {grz_cli-0.2.0 → grz_cli-0.3.0}/pyproject.toml +10 -1
- grz_cli-0.3.0/src/grz_cli/__init__.py +1 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli/cli.py +6 -1
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli/parser.py +55 -9
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli/progress_logging.py +2 -1
- {grz_cli-0.2.0 → grz_cli-0.3.0/src/grz_cli.egg-info}/PKG-INFO +3 -2
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli.egg-info/SOURCES.txt +1 -2
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli.egg-info/requires.txt +1 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/tests/test_file_progress_logging.py +1 -1
- grz_cli-0.2.0/src/grz_cli/models/__init__.py +0 -0
- grz_cli-0.2.0/src/grz_cli/models/v1_1_1/__init__.py +0 -0
- grz_cli-0.2.0/src/grz_cli/models/v1_1_1/metadata.py +0 -1071
- {grz_cli-0.2.0 → grz_cli-0.3.0}/README.md +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/setup.cfg +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/__init__.py +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli/constants.py +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli/download.py +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli/fastq_validation.py +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli/file_operations.py +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli/logging_setup.py +0 -0
- {grz_cli-0.2.0/src/grz_cli → grz_cli-0.3.0/src/grz_cli/models}/__init__.py +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli/models/config.py +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli/resources/thresholds.json +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli/states.py +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli/upload.py +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli.egg-info/dependency_links.txt +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli.egg-info/entry_points.txt +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/src/grz_cli.egg-info/top_level.txt +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/tests/test_cli.py +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/tests/test_download.py +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/tests/test_fastq_validation.py +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/tests/test_file_operations.py +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/tests/test_parser.py +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/tests/test_read_multiple_json.py +0 -0
- {grz_cli-0.2.0 → grz_cli-0.3.0}/tests/test_upload.py +0 -0
grz_cli-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 GRZ/GHGA
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -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.2.0"
|
|
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"
|
|
@@ -11,6 +11,7 @@ from pathlib import Path
|
|
|
11
11
|
from tempfile import NamedTemporaryFile
|
|
12
12
|
|
|
13
13
|
import click
|
|
14
|
+
import grz_pydantic_models
|
|
14
15
|
import platformdirs
|
|
15
16
|
import yaml
|
|
16
17
|
|
|
@@ -108,7 +109,11 @@ class OrderedGroup(click.Group):
|
|
|
108
109
|
cls=OrderedGroup,
|
|
109
110
|
help="Validate, encrypt, decrypt and upload submissions to a GRZ/GDC.",
|
|
110
111
|
)
|
|
111
|
-
@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
|
+
)
|
|
112
117
|
@click.option("--log-file", metavar="FILE", type=str, help="Path to log file")
|
|
113
118
|
@click.option(
|
|
114
119
|
"--log-level",
|
|
@@ -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_1_1.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_1_1.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_1_1.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"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
LICENSE
|
|
1
2
|
MANIFEST.in
|
|
2
3
|
README.md
|
|
3
4
|
pyproject.toml
|
|
@@ -21,8 +22,6 @@ src/grz_cli.egg-info/requires.txt
|
|
|
21
22
|
src/grz_cli.egg-info/top_level.txt
|
|
22
23
|
src/grz_cli/models/__init__.py
|
|
23
24
|
src/grz_cli/models/config.py
|
|
24
|
-
src/grz_cli/models/v1_1_1/__init__.py
|
|
25
|
-
src/grz_cli/models/v1_1_1/metadata.py
|
|
26
25
|
src/grz_cli/resources/thresholds.json
|
|
27
26
|
tests/test_cli.py
|
|
28
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_1_1.metadata import File as SubmissionFileMetadata
|
|
11
11
|
from grz_cli.progress_logging import FileProgressLogger
|
|
12
12
|
|
|
13
13
|
|
|
File without changes
|
|
File without changes
|