grz-cli 0.1.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.0/LICENSE +21 -0
- grz_cli-0.1.0/MANIFEST.in +1 -0
- grz_cli-0.1.0/PKG-INFO +240 -0
- grz_cli-0.1.0/README.md +209 -0
- grz_cli-0.1.0/pyproject.toml +189 -0
- grz_cli-0.1.0/setup.cfg +4 -0
- grz_cli-0.1.0/src/__init__.py +0 -0
- grz_cli-0.1.0/src/grz_cli/__init__.py +0 -0
- grz_cli-0.1.0/src/grz_cli/cli.py +326 -0
- grz_cli-0.1.0/src/grz_cli/constants.py +37 -0
- grz_cli-0.1.0/src/grz_cli/download.py +236 -0
- grz_cli-0.1.0/src/grz_cli/fastq_validation.py +122 -0
- grz_cli-0.1.0/src/grz_cli/file_operations.py +364 -0
- grz_cli-0.1.0/src/grz_cli/logging_setup.py +59 -0
- grz_cli-0.1.0/src/grz_cli/models/__init__.py +0 -0
- grz_cli-0.1.0/src/grz_cli/models/config.py +118 -0
- grz_cli-0.1.0/src/grz_cli/models/v1_0_0/__init__.py +0 -0
- grz_cli-0.1.0/src/grz_cli/models/v1_0_0/metadata.py +845 -0
- grz_cli-0.1.0/src/grz_cli/parser.py +771 -0
- grz_cli-0.1.0/src/grz_cli/progress_logging.py +170 -0
- grz_cli-0.1.0/src/grz_cli/resources/grz-schema.json +560 -0
- grz_cli-0.1.0/src/grz_cli/upload.py +243 -0
- grz_cli-0.1.0/src/grz_cli.egg-info/PKG-INFO +240 -0
- grz_cli-0.1.0/src/grz_cli.egg-info/SOURCES.txt +34 -0
- grz_cli-0.1.0/src/grz_cli.egg-info/dependency_links.txt +1 -0
- grz_cli-0.1.0/src/grz_cli.egg-info/entry_points.txt +2 -0
- grz_cli-0.1.0/src/grz_cli.egg-info/requires.txt +17 -0
- grz_cli-0.1.0/src/grz_cli.egg-info/top_level.txt +2 -0
- grz_cli-0.1.0/tests/test_cli.py +257 -0
- grz_cli-0.1.0/tests/test_download.py +83 -0
- grz_cli-0.1.0/tests/test_fastq_validation.py +51 -0
- grz_cli-0.1.0/tests/test_file_operations.py +90 -0
- grz_cli-0.1.0/tests/test_file_progress_logging.py +195 -0
- grz_cli-0.1.0/tests/test_parser.py +53 -0
- grz_cli-0.1.0/tests/test_read_multiple_json.py +114 -0
- grz_cli-0.1.0/tests/test_upload.py +129 -0
grz_cli-0.1.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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include src/grz_cli/resources/grz-schema.json
|
grz_cli-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: grz-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Tool for validation, encryption and upload of MV submissions to GDCs.
|
|
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
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://codebase.helmholtz.cloud/grz-mv-genomseq/grz-cli
|
|
8
|
+
Keywords: GRZ,GDC,S3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.12
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: boto3~=1.35.39
|
|
16
|
+
Requires-Dist: click~=8.1.7
|
|
17
|
+
Requires-Dist: crypt4gh~=1.7
|
|
18
|
+
Requires-Dist: jsonschema~=4.23.0
|
|
19
|
+
Requires-Dist: pyyaml~=6.0.2
|
|
20
|
+
Requires-Dist: tqdm~=4.66.5
|
|
21
|
+
Requires-Dist: pydantic~=2.9.2
|
|
22
|
+
Requires-Dist: platformdirs~=4.3.6
|
|
23
|
+
Provides-Extra: test
|
|
24
|
+
Requires-Dist: pytest~=8.3.3; extra == "test"
|
|
25
|
+
Requires-Dist: pytest-cov~=5.0.0; extra == "test"
|
|
26
|
+
Requires-Dist: pytest-mock~=3.14.0; extra == "test"
|
|
27
|
+
Requires-Dist: moto[s3]~=5.0.16; extra == "test"
|
|
28
|
+
Requires-Dist: pytest-sugar~=1.0.0; extra == "test"
|
|
29
|
+
Requires-Dist: ruff~=0.7.0; extra == "test"
|
|
30
|
+
Requires-Dist: numpy~=2.1.2; extra == "test"
|
|
31
|
+
|
|
32
|
+
# GRZ CLI
|
|
33
|
+
|
|
34
|
+
A command-line tool for validating, encrypting, uploading and downloading submissions to/from a GDC/GRZ (Genomrechenzentrum).
|
|
35
|
+
|
|
36
|
+
## Table of Contents
|
|
37
|
+
|
|
38
|
+
- [Introduction](#introduction)
|
|
39
|
+
- [Features](#features)
|
|
40
|
+
- [Installation](#installation)
|
|
41
|
+
- [Usage](#usage)
|
|
42
|
+
- [Configuration](#configuration)
|
|
43
|
+
- [Exemplary submission procedure](#exemplary-submission-procedure)
|
|
44
|
+
- [Command-Line Interface](#command-line-interface)
|
|
45
|
+
- [Testing](#testing)
|
|
46
|
+
- [Contributing](#contributing)
|
|
47
|
+
- [License](#license)
|
|
48
|
+
- [Acknowledgements](#acknowledgements)
|
|
49
|
+
|
|
50
|
+
## Introduction
|
|
51
|
+
|
|
52
|
+
This tool provides a way to validate files, encrypt/decrypt files using the [crypt4gh](https://crypt4gh.readthedocs.io/en/latest/) library and upload/download the encrypted files to an S3 bucket of a GDC/GRZ. It also logs the progress and outcomes of these operations in a metadata file.
|
|
53
|
+
|
|
54
|
+
It is recommended to have the following folder structure for a single submission:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
EXAMPLE_SUBMISSION
|
|
58
|
+
├── files
|
|
59
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.read1.fastq.gz
|
|
60
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.read2.fastq.gz
|
|
61
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.vcf
|
|
62
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.read1.fastq.gz
|
|
63
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.read2.fastq.gz
|
|
64
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.vcf
|
|
65
|
+
│ ├── target_regions.bed
|
|
66
|
+
└── metadata
|
|
67
|
+
└── metadata.json
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The current version of the tool requires the `working_dir` to have at least as much free disk space as the total size of the data being submitted.
|
|
71
|
+
## Features
|
|
72
|
+
|
|
73
|
+
- **Validation**: Validate file checksums, basic file metadata and BfArM requirements.
|
|
74
|
+
- **Encryption**: Encrypt files using `crypt4gh`.
|
|
75
|
+
- **Decryption**: Encrypt files using `crypt4gh`.
|
|
76
|
+
- **Upload**: Upload encrypted files directly to a GRZ either (via built-in `boto3`).
|
|
77
|
+
- **Download**: Download encrypted files from a GRZ (via built-in `boto3`).
|
|
78
|
+
- **Logging**: Log progress and results of operations
|
|
79
|
+
|
|
80
|
+
## Installation
|
|
81
|
+
|
|
82
|
+
### End-user
|
|
83
|
+
This tool uses the `conda` package manager.
|
|
84
|
+
If `conda` is not yet available on your system, you can install the [Miniforge conda distribution](https://github.com/conda-forge/miniforge) by running the following commands:
|
|
85
|
+
```bash
|
|
86
|
+
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
|
|
87
|
+
bash Miniforge3-$(uname)-$(uname -m).sh
|
|
88
|
+
```
|
|
89
|
+
Next, install the `grz-cli` tool:
|
|
90
|
+
```bash
|
|
91
|
+
# TODO update: This requires membership in the repository
|
|
92
|
+
# download environment.yaml from the git repository:
|
|
93
|
+
git archive --remote=ssh://git@codebase.helmholtz.cloud/grz-mv-genomseq/grz-cli.git dev environment.yaml | tar -xv
|
|
94
|
+
# TODO update: This will work once the repository is publicly accessible:
|
|
95
|
+
# download environment.yaml from the git repository:
|
|
96
|
+
curl -L "https://codebase.helmholtz.cloud/grz-mv-genomseq/grz-cli/-/raw/v0.1.0/environment.yaml?ref_type=heads" > environment.yaml
|
|
97
|
+
|
|
98
|
+
# create conda environment and activate it
|
|
99
|
+
conda env create -f environment.yaml -n grz-tools
|
|
100
|
+
conda activate grz-tools
|
|
101
|
+
|
|
102
|
+
# install the grz-cli tool
|
|
103
|
+
# TODO update: This requires membership in the repository
|
|
104
|
+
pip install "git+ssh://git@codebase.helmholtz.cloud/grz-mv-genomseq/grz-cli.git@dev"
|
|
105
|
+
# TODO update: This will work once the repository is publicly accessible:
|
|
106
|
+
pip install "git+https://codebase.helmholtz.cloud/grz-mv-genomseq/grz-cli@v0.1.0"
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Development setup
|
|
110
|
+
For development purposes, you can clone the repository and install the package in editable mode:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
git clone https://codebase.helmholtz.cloud/grz-mv-genomseq/grz-cli
|
|
114
|
+
# create conda environment and activate it
|
|
115
|
+
conda env create -f grz-cli/environment-dev.yaml -n grz-tools-dev
|
|
116
|
+
conda activate grz-tools-dev
|
|
117
|
+
# install the grz-cli tool
|
|
118
|
+
pip install -e grz-cli/
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Usage
|
|
122
|
+
|
|
123
|
+
### Configuration
|
|
124
|
+
**The configuration file will be provided by your associated GRZ, please place it into `~/.config/grz-cli/config.yaml`.**
|
|
125
|
+
|
|
126
|
+
The tool requires a configuration file in YAML format to specify the S3 bucket and other options.
|
|
127
|
+
For an exemplary configuration, see [resources/config.yaml](resources/config.yaml).
|
|
128
|
+
|
|
129
|
+
S3 access and secret key can be listed either in the config file or as environment variable (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`).
|
|
130
|
+
|
|
131
|
+
### Exemplary submission procedure
|
|
132
|
+
After preparing your submission as outlined above, you can use the following commands to validate, encrypt and upload the submission:
|
|
133
|
+
```sh
|
|
134
|
+
# Validate the submission
|
|
135
|
+
grz-cli validate --submission-dir EXAMPLE_SUBMISSION
|
|
136
|
+
|
|
137
|
+
# Encrypt the submission
|
|
138
|
+
grz-cli encrypt --submission-dir EXAMPLE_SUBMISSION
|
|
139
|
+
|
|
140
|
+
# Upload the submission
|
|
141
|
+
grz-cli upload --submission-dir EXAMPLE_SUBMISSION
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Troubleshooting
|
|
145
|
+
**In case of issues, please re-run your commands with `grz-cli --log-level DEBUG --log-file <your-log-file.log> [...]` and submit the log file to the GRZ data steward!**
|
|
146
|
+
|
|
147
|
+
## Command-Line Interface
|
|
148
|
+
|
|
149
|
+
`grz-cli` provides a command-line interface with the following subcommands:
|
|
150
|
+
|
|
151
|
+
### validate
|
|
152
|
+
|
|
153
|
+
It is recommended to run this command before continuing with encryption and upload.
|
|
154
|
+
Progress files are stored relative to the submission directory.
|
|
155
|
+
|
|
156
|
+
- `--submission-dir`: Path to the submission directory containing both 'metadata/' and 'files/' directories [**Required**]
|
|
157
|
+
|
|
158
|
+
Example usage:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
grz_cli validate --submission-dir foo
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Option is for the usage at a hospital (Leistungserbringer) and GDC/GRZ.
|
|
165
|
+
|
|
166
|
+
### encrypt
|
|
167
|
+
|
|
168
|
+
If a working directory is not provided, then the current directory is used automatically. The log-files are going to be stored in the sub-folder of the working directory.
|
|
169
|
+
Files are stored in a folder named `encrypted_files` as a sub-folder of the working directory.
|
|
170
|
+
|
|
171
|
+
- `-s, --submission-dir`: Path to the submission directory containing both 'metadata/' and 'files/' directories [**Required**]
|
|
172
|
+
- `-c, --config-file`: Path to config file [_optional_]
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
grz-cli encrypt --submission-dir foo
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Option is for the usage at a hospital (Leistungserbringer). Please approach your GDC/GRZ for a valid config file.
|
|
179
|
+
|
|
180
|
+
### decrypt
|
|
181
|
+
|
|
182
|
+
Decrypt a submission using the GRZ private key.
|
|
183
|
+
|
|
184
|
+
- `-s, --submission-dir`: Path to the submission directory containing both 'metadata/' and 'encrypted_files/' directories [**Required**]
|
|
185
|
+
- `-c,--config-file`: Path to config file [_optional_]
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
grz-cli decrypt --submission-dir foo
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Option is for the usage at a GDC/GRZ.
|
|
192
|
+
|
|
193
|
+
### upload
|
|
194
|
+
|
|
195
|
+
Upload the submission into a S3 structure of a GRZ.
|
|
196
|
+
|
|
197
|
+
- `-s, --submission-dir`: Path to the submission directory containing both 'metadata/' and 'encrypted_files/' directories [**Required**]
|
|
198
|
+
- `-c, --config-file`: Path to config file [_optional_]
|
|
199
|
+
|
|
200
|
+
Example usage:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
grz-cli upload --submission-dir foo
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Option is for the usage at a hospital (Leistungserbringer). Please approach your GDC/GRZ for a valid config file.
|
|
207
|
+
|
|
208
|
+
### download
|
|
209
|
+
|
|
210
|
+
Download a submission from a GRZ
|
|
211
|
+
|
|
212
|
+
- `-s, --submission-id`: S3 submission prefix [**Required**]
|
|
213
|
+
- `-o, --output-dir`: Path to the target submission output directory [**Required**]
|
|
214
|
+
- `-c, --config-file`: Path to config file [_optional_]
|
|
215
|
+
|
|
216
|
+
Example usage:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
grz-cli download --submission-id foo --output-dir bar
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Option is for the usage at a GDC/GRZ.
|
|
223
|
+
|
|
224
|
+
## Testing
|
|
225
|
+
|
|
226
|
+
To run the tests, navigate to the root directory of your project and invoke `pytest`.
|
|
227
|
+
Alternatively, install `uv` and `tox` and run `uv run tox`.
|
|
228
|
+
|
|
229
|
+
## Contributing
|
|
230
|
+
|
|
231
|
+
<!-- Add details about how others can contribute to the project -->
|
|
232
|
+
|
|
233
|
+
## License
|
|
234
|
+
|
|
235
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
236
|
+
|
|
237
|
+
## Acknowledgements
|
|
238
|
+
|
|
239
|
+
Parts of `cryp4gh` code is used in modified form
|
|
240
|
+
|
grz_cli-0.1.0/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# GRZ CLI
|
|
2
|
+
|
|
3
|
+
A command-line tool for validating, encrypting, uploading and downloading submissions to/from a GDC/GRZ (Genomrechenzentrum).
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Introduction](#introduction)
|
|
8
|
+
- [Features](#features)
|
|
9
|
+
- [Installation](#installation)
|
|
10
|
+
- [Usage](#usage)
|
|
11
|
+
- [Configuration](#configuration)
|
|
12
|
+
- [Exemplary submission procedure](#exemplary-submission-procedure)
|
|
13
|
+
- [Command-Line Interface](#command-line-interface)
|
|
14
|
+
- [Testing](#testing)
|
|
15
|
+
- [Contributing](#contributing)
|
|
16
|
+
- [License](#license)
|
|
17
|
+
- [Acknowledgements](#acknowledgements)
|
|
18
|
+
|
|
19
|
+
## Introduction
|
|
20
|
+
|
|
21
|
+
This tool provides a way to validate files, encrypt/decrypt files using the [crypt4gh](https://crypt4gh.readthedocs.io/en/latest/) library and upload/download the encrypted files to an S3 bucket of a GDC/GRZ. It also logs the progress and outcomes of these operations in a metadata file.
|
|
22
|
+
|
|
23
|
+
It is recommended to have the following folder structure for a single submission:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
EXAMPLE_SUBMISSION
|
|
27
|
+
├── files
|
|
28
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.read1.fastq.gz
|
|
29
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.read2.fastq.gz
|
|
30
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.vcf
|
|
31
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.read1.fastq.gz
|
|
32
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.read2.fastq.gz
|
|
33
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.vcf
|
|
34
|
+
│ ├── target_regions.bed
|
|
35
|
+
└── metadata
|
|
36
|
+
└── metadata.json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The current version of the tool requires the `working_dir` to have at least as much free disk space as the total size of the data being submitted.
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- **Validation**: Validate file checksums, basic file metadata and BfArM requirements.
|
|
43
|
+
- **Encryption**: Encrypt files using `crypt4gh`.
|
|
44
|
+
- **Decryption**: Encrypt files using `crypt4gh`.
|
|
45
|
+
- **Upload**: Upload encrypted files directly to a GRZ either (via built-in `boto3`).
|
|
46
|
+
- **Download**: Download encrypted files from a GRZ (via built-in `boto3`).
|
|
47
|
+
- **Logging**: Log progress and results of operations
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
### End-user
|
|
52
|
+
This tool uses the `conda` package manager.
|
|
53
|
+
If `conda` is not yet available on your system, you can install the [Miniforge conda distribution](https://github.com/conda-forge/miniforge) by running the following commands:
|
|
54
|
+
```bash
|
|
55
|
+
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
|
|
56
|
+
bash Miniforge3-$(uname)-$(uname -m).sh
|
|
57
|
+
```
|
|
58
|
+
Next, install the `grz-cli` tool:
|
|
59
|
+
```bash
|
|
60
|
+
# TODO update: This requires membership in the repository
|
|
61
|
+
# download environment.yaml from the git repository:
|
|
62
|
+
git archive --remote=ssh://git@codebase.helmholtz.cloud/grz-mv-genomseq/grz-cli.git dev environment.yaml | tar -xv
|
|
63
|
+
# TODO update: This will work once the repository is publicly accessible:
|
|
64
|
+
# download environment.yaml from the git repository:
|
|
65
|
+
curl -L "https://codebase.helmholtz.cloud/grz-mv-genomseq/grz-cli/-/raw/v0.1.0/environment.yaml?ref_type=heads" > environment.yaml
|
|
66
|
+
|
|
67
|
+
# create conda environment and activate it
|
|
68
|
+
conda env create -f environment.yaml -n grz-tools
|
|
69
|
+
conda activate grz-tools
|
|
70
|
+
|
|
71
|
+
# install the grz-cli tool
|
|
72
|
+
# TODO update: This requires membership in the repository
|
|
73
|
+
pip install "git+ssh://git@codebase.helmholtz.cloud/grz-mv-genomseq/grz-cli.git@dev"
|
|
74
|
+
# TODO update: This will work once the repository is publicly accessible:
|
|
75
|
+
pip install "git+https://codebase.helmholtz.cloud/grz-mv-genomseq/grz-cli@v0.1.0"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Development setup
|
|
79
|
+
For development purposes, you can clone the repository and install the package in editable mode:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
git clone https://codebase.helmholtz.cloud/grz-mv-genomseq/grz-cli
|
|
83
|
+
# create conda environment and activate it
|
|
84
|
+
conda env create -f grz-cli/environment-dev.yaml -n grz-tools-dev
|
|
85
|
+
conda activate grz-tools-dev
|
|
86
|
+
# install the grz-cli tool
|
|
87
|
+
pip install -e grz-cli/
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Usage
|
|
91
|
+
|
|
92
|
+
### Configuration
|
|
93
|
+
**The configuration file will be provided by your associated GRZ, please place it into `~/.config/grz-cli/config.yaml`.**
|
|
94
|
+
|
|
95
|
+
The tool requires a configuration file in YAML format to specify the S3 bucket and other options.
|
|
96
|
+
For an exemplary configuration, see [resources/config.yaml](resources/config.yaml).
|
|
97
|
+
|
|
98
|
+
S3 access and secret key can be listed either in the config file or as environment variable (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`).
|
|
99
|
+
|
|
100
|
+
### Exemplary submission procedure
|
|
101
|
+
After preparing your submission as outlined above, you can use the following commands to validate, encrypt and upload the submission:
|
|
102
|
+
```sh
|
|
103
|
+
# Validate the submission
|
|
104
|
+
grz-cli validate --submission-dir EXAMPLE_SUBMISSION
|
|
105
|
+
|
|
106
|
+
# Encrypt the submission
|
|
107
|
+
grz-cli encrypt --submission-dir EXAMPLE_SUBMISSION
|
|
108
|
+
|
|
109
|
+
# Upload the submission
|
|
110
|
+
grz-cli upload --submission-dir EXAMPLE_SUBMISSION
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Troubleshooting
|
|
114
|
+
**In case of issues, please re-run your commands with `grz-cli --log-level DEBUG --log-file <your-log-file.log> [...]` and submit the log file to the GRZ data steward!**
|
|
115
|
+
|
|
116
|
+
## Command-Line Interface
|
|
117
|
+
|
|
118
|
+
`grz-cli` provides a command-line interface with the following subcommands:
|
|
119
|
+
|
|
120
|
+
### validate
|
|
121
|
+
|
|
122
|
+
It is recommended to run this command before continuing with encryption and upload.
|
|
123
|
+
Progress files are stored relative to the submission directory.
|
|
124
|
+
|
|
125
|
+
- `--submission-dir`: Path to the submission directory containing both 'metadata/' and 'files/' directories [**Required**]
|
|
126
|
+
|
|
127
|
+
Example usage:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
grz_cli validate --submission-dir foo
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Option is for the usage at a hospital (Leistungserbringer) and GDC/GRZ.
|
|
134
|
+
|
|
135
|
+
### encrypt
|
|
136
|
+
|
|
137
|
+
If a working directory is not provided, then the current directory is used automatically. The log-files are going to be stored in the sub-folder of the working directory.
|
|
138
|
+
Files are stored in a folder named `encrypted_files` as a sub-folder of the working directory.
|
|
139
|
+
|
|
140
|
+
- `-s, --submission-dir`: Path to the submission directory containing both 'metadata/' and 'files/' directories [**Required**]
|
|
141
|
+
- `-c, --config-file`: Path to config file [_optional_]
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
grz-cli encrypt --submission-dir foo
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Option is for the usage at a hospital (Leistungserbringer). Please approach your GDC/GRZ for a valid config file.
|
|
148
|
+
|
|
149
|
+
### decrypt
|
|
150
|
+
|
|
151
|
+
Decrypt a submission using the GRZ private key.
|
|
152
|
+
|
|
153
|
+
- `-s, --submission-dir`: Path to the submission directory containing both 'metadata/' and 'encrypted_files/' directories [**Required**]
|
|
154
|
+
- `-c,--config-file`: Path to config file [_optional_]
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
grz-cli decrypt --submission-dir foo
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Option is for the usage at a GDC/GRZ.
|
|
161
|
+
|
|
162
|
+
### upload
|
|
163
|
+
|
|
164
|
+
Upload the submission into a S3 structure of a GRZ.
|
|
165
|
+
|
|
166
|
+
- `-s, --submission-dir`: Path to the submission directory containing both 'metadata/' and 'encrypted_files/' directories [**Required**]
|
|
167
|
+
- `-c, --config-file`: Path to config file [_optional_]
|
|
168
|
+
|
|
169
|
+
Example usage:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
grz-cli upload --submission-dir foo
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Option is for the usage at a hospital (Leistungserbringer). Please approach your GDC/GRZ for a valid config file.
|
|
176
|
+
|
|
177
|
+
### download
|
|
178
|
+
|
|
179
|
+
Download a submission from a GRZ
|
|
180
|
+
|
|
181
|
+
- `-s, --submission-id`: S3 submission prefix [**Required**]
|
|
182
|
+
- `-o, --output-dir`: Path to the target submission output directory [**Required**]
|
|
183
|
+
- `-c, --config-file`: Path to config file [_optional_]
|
|
184
|
+
|
|
185
|
+
Example usage:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
grz-cli download --submission-id foo --output-dir bar
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Option is for the usage at a GDC/GRZ.
|
|
192
|
+
|
|
193
|
+
## Testing
|
|
194
|
+
|
|
195
|
+
To run the tests, navigate to the root directory of your project and invoke `pytest`.
|
|
196
|
+
Alternatively, install `uv` and `tox` and run `uv run tox`.
|
|
197
|
+
|
|
198
|
+
## Contributing
|
|
199
|
+
|
|
200
|
+
<!-- Add details about how others can contribute to the project -->
|
|
201
|
+
|
|
202
|
+
## License
|
|
203
|
+
|
|
204
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
205
|
+
|
|
206
|
+
## Acknowledgements
|
|
207
|
+
|
|
208
|
+
Parts of `cryp4gh` code is used in modified form
|
|
209
|
+
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "grz-cli"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Tool for validation, encryption and upload of MV submissions to GDCs."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Koray Kirli", email = "koraykirli@gmail.com" },
|
|
13
|
+
{ name = "Mathias Lesche", email = "mathias.lesche@tu-dresden.de" },
|
|
14
|
+
{ name = "Florian R. Hölzlwimmer", email = "git.ich@frhoelzlwimmer.de" },
|
|
15
|
+
{ name = "Till Hartmann", email = "till.hartmann@bih-charite.de" },
|
|
16
|
+
{ name = "Thomas Sell", email = "thomas.sell@bih-charite.de" },
|
|
17
|
+
]
|
|
18
|
+
dependencies = [
|
|
19
|
+
"boto3 ~=1.35.39",
|
|
20
|
+
"click ~=8.1.7",
|
|
21
|
+
"crypt4gh ~=1.7",
|
|
22
|
+
"jsonschema ~=4.23.0",
|
|
23
|
+
"pyyaml ~=6.0.2",
|
|
24
|
+
"tqdm ~=4.66.5",
|
|
25
|
+
"pydantic ~=2.9.2",
|
|
26
|
+
"platformdirs ~=4.3.6",
|
|
27
|
+
]
|
|
28
|
+
classifiers = [
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"License :: OSI Approved :: MIT License",
|
|
31
|
+
"Operating System :: OS Independent"
|
|
32
|
+
]
|
|
33
|
+
requires-python = ">=3.12"
|
|
34
|
+
keywords = ["GRZ", "GDC", "S3"]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
"Homepage" = "https://codebase.helmholtz.cloud/grz-mv-genomseq/grz-cli"
|
|
38
|
+
|
|
39
|
+
[project.scripts]
|
|
40
|
+
grz-cli = "grz_cli.cli:cli"
|
|
41
|
+
|
|
42
|
+
[project.optional-dependencies]
|
|
43
|
+
test = [
|
|
44
|
+
"pytest ~=8.3.3",
|
|
45
|
+
"pytest-cov ~=5.0.0",
|
|
46
|
+
"pytest-mock ~=3.14.0",
|
|
47
|
+
"moto[s3] ~=5.0.16",
|
|
48
|
+
"pytest-sugar ~=1.0.0",
|
|
49
|
+
"ruff ~=0.7.0",
|
|
50
|
+
"numpy ~=2.1.2"
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[dependency-groups]
|
|
54
|
+
test = [
|
|
55
|
+
"pytest",
|
|
56
|
+
"pytest-mock",
|
|
57
|
+
"pytest-cov",
|
|
58
|
+
"pytest-sugar",
|
|
59
|
+
"moto[s3]",
|
|
60
|
+
"numpy"
|
|
61
|
+
]
|
|
62
|
+
lint = [
|
|
63
|
+
"ruff",
|
|
64
|
+
"mypy",
|
|
65
|
+
"types-pyyaml",
|
|
66
|
+
"types-tqdm",
|
|
67
|
+
"pydantic",
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
[tool.ruff]
|
|
71
|
+
exclude = [
|
|
72
|
+
".git",
|
|
73
|
+
".devcontainer",
|
|
74
|
+
"__pycache__",
|
|
75
|
+
"build",
|
|
76
|
+
"dist",
|
|
77
|
+
"out"
|
|
78
|
+
]
|
|
79
|
+
line-length = 88
|
|
80
|
+
src = [
|
|
81
|
+
"src",
|
|
82
|
+
"tests"
|
|
83
|
+
]
|
|
84
|
+
target-version = "py310"
|
|
85
|
+
|
|
86
|
+
[tool.ruff.lint]
|
|
87
|
+
fixable = [
|
|
88
|
+
"UP",
|
|
89
|
+
"I",
|
|
90
|
+
"D",
|
|
91
|
+
]
|
|
92
|
+
ignore = [
|
|
93
|
+
"E111",
|
|
94
|
+
"E114",
|
|
95
|
+
"E116",
|
|
96
|
+
"PLW",
|
|
97
|
+
"RUF001",
|
|
98
|
+
"RUF010",
|
|
99
|
+
"RUF012",
|
|
100
|
+
"N818",
|
|
101
|
+
"B008",
|
|
102
|
+
"PLR2004",
|
|
103
|
+
"D200",
|
|
104
|
+
"D205",
|
|
105
|
+
"D400",
|
|
106
|
+
"D401",
|
|
107
|
+
"D107",
|
|
108
|
+
"D206",
|
|
109
|
+
"D300",
|
|
110
|
+
"UP040",
|
|
111
|
+
]
|
|
112
|
+
select = [
|
|
113
|
+
"C90",
|
|
114
|
+
"F",
|
|
115
|
+
"I",
|
|
116
|
+
"S",
|
|
117
|
+
"B",
|
|
118
|
+
"N",
|
|
119
|
+
"UP",
|
|
120
|
+
"PL",
|
|
121
|
+
"RUF",
|
|
122
|
+
"SIM",
|
|
123
|
+
"D",
|
|
124
|
+
]
|
|
125
|
+
|
|
126
|
+
[tool.ruff.lint.mccabe]
|
|
127
|
+
max-complexity = 10
|
|
128
|
+
|
|
129
|
+
[tool.ruff.lint.per-file-ignores]
|
|
130
|
+
"tests/*" = [
|
|
131
|
+
"S",
|
|
132
|
+
"SIM",
|
|
133
|
+
"PLR",
|
|
134
|
+
"B011",
|
|
135
|
+
"D103"
|
|
136
|
+
]
|
|
137
|
+
"__init__.py" = [
|
|
138
|
+
"D",
|
|
139
|
+
]
|
|
140
|
+
"src/grz_cli/models/**.py" = [
|
|
141
|
+
"D100",
|
|
142
|
+
"D101",
|
|
143
|
+
"D102",
|
|
144
|
+
"N805"
|
|
145
|
+
]
|
|
146
|
+
|
|
147
|
+
[tool.ruff.lint.pydocstyle]
|
|
148
|
+
convention = "pep257"
|
|
149
|
+
|
|
150
|
+
[tool.tox]
|
|
151
|
+
requires = ["tox>=4.23"]
|
|
152
|
+
env_list = ["format-check", "lints", "mypy", "3.12"]
|
|
153
|
+
allowlist_externals = ["pytest", "ruff"]
|
|
154
|
+
isolated_build = true
|
|
155
|
+
|
|
156
|
+
[tool.tox.env_run_base]
|
|
157
|
+
description = "run unit tests"
|
|
158
|
+
dependency_groups = ["test"]
|
|
159
|
+
commands = [["pytest", { replace = "posargs", default = ["tests"], extend = true }]]
|
|
160
|
+
|
|
161
|
+
[tool.tox.env."format-check"]
|
|
162
|
+
skip_install = true
|
|
163
|
+
dependency_groups = ["lint"]
|
|
164
|
+
commands = [["ruff", "format", "--check"]]
|
|
165
|
+
|
|
166
|
+
[tool.tox.env."lints"]
|
|
167
|
+
skip_install = true
|
|
168
|
+
dependency_groups = ["lint"]
|
|
169
|
+
commands = [["ruff", "check"]]
|
|
170
|
+
|
|
171
|
+
[tool.tox.env."mypy"]
|
|
172
|
+
skip_install = false
|
|
173
|
+
dependency_groups = ["lint"]
|
|
174
|
+
commands = [["mypy"]]
|
|
175
|
+
|
|
176
|
+
[tool.uv]
|
|
177
|
+
dev-dependencies = [
|
|
178
|
+
"datamodel-code-generator>=0.26.2",
|
|
179
|
+
"mypy>=1.13.0",
|
|
180
|
+
"tox>=4.23.2",
|
|
181
|
+
"types-pyyaml>=6.0.12.20240917",
|
|
182
|
+
"types-tqdm>=4.66.0.20240417",
|
|
183
|
+
]
|
|
184
|
+
|
|
185
|
+
[tool.mypy]
|
|
186
|
+
python_version = "3.12"
|
|
187
|
+
plugins = "pydantic.mypy"
|
|
188
|
+
packages = "src"
|
|
189
|
+
|
grz_cli-0.1.0/setup.cfg
ADDED
|
File without changes
|
|
File without changes
|