grz-cli 1.1.1__tar.gz → 1.2.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-1.1.1 → grz_cli-1.2.0}/CHANGELOG.md +25 -0
- {grz_cli-1.1.1 → grz_cli-1.2.0}/PKG-INFO +114 -86
- grz_cli-1.2.0/README.md +229 -0
- {grz_cli-1.1.1 → grz_cli-1.2.0}/pyproject.toml +2 -2
- grz_cli-1.2.0/src/grz_cli/__init__.py +1 -0
- {grz_cli-1.1.1 → grz_cli-1.2.0}/src/grz_cli/cli.py +21 -18
- grz_cli-1.2.0/src/grz_cli/commands/get_id.py +18 -0
- {grz_cli-1.1.1 → grz_cli-1.2.0}/src/grz_cli/commands/upload.py +3 -1
- grz_cli-1.1.1/README.md +0 -201
- grz_cli-1.1.1/src/grz_cli/__init__.py +0 -1
- grz_cli-1.1.1/src/grz_cli/constants.py +0 -38
- grz_cli-1.1.1/src/grz_cli/logging_setup.py +0 -59
- {grz_cli-1.1.1 → grz_cli-1.2.0}/.gitignore +0 -0
- {grz_cli-1.1.1 → grz_cli-1.2.0}/LICENSE +0 -0
- {grz_cli-1.1.1 → grz_cli-1.2.0}/MANIFEST.in +0 -0
- {grz_cli-1.1.1 → grz_cli-1.2.0}/src/__init__.py +0 -0
- {grz_cli-1.1.1 → grz_cli-1.2.0}/src/grz_cli/commands/__init__.py +0 -0
- {grz_cli-1.1.1 → grz_cli-1.2.0}/src/grz_cli/commands/encrypt.py +0 -0
- {grz_cli-1.1.1 → grz_cli-1.2.0}/src/grz_cli/commands/submit.py +0 -0
- {grz_cli-1.1.1 → grz_cli-1.2.0}/src/grz_cli/commands/validate.py +0 -0
- {grz_cli-1.1.1 → grz_cli-1.2.0}/src/grz_cli/models/__init__.py +0 -0
- {grz_cli-1.1.1 → grz_cli-1.2.0}/src/grz_cli/models/config.py +0 -0
- {grz_cli-1.1.1 → grz_cli-1.2.0}/src/grz_cli/py.typed +0 -0
- {grz_cli-1.1.1 → grz_cli-1.2.0}/uv.lock +0 -0
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.2.0](https://github.com/BfArM-MVH/grz-tools/compare/grz-cli-v1.1.2...grz-cli-v1.2.0) (2025-08-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **grz-cli,grzctl:** bump grz dependencies to latest ([#359](https://github.com/BfArM-MVH/grz-tools/issues/359)) ([b31c88b](https://github.com/BfArM-MVH/grz-tools/commit/b31c88bfa32cf257e6db9b2bb80d302493dbd469))
|
|
9
|
+
* **grz-cli:** add command to compute submission ID from metadata ([#348](https://github.com/BfArM-MVH/grz-tools/issues/348)) ([674d0f1](https://github.com/BfArM-MVH/grz-tools/commit/674d0f1acb3b048cdbde2eb10056faf74033c309))
|
|
10
|
+
* **grz-cli:** also report grz library versions ([#355](https://github.com/BfArM-MVH/grz-tools/issues/355)) ([58d047e](https://github.com/BfArM-MVH/grz-tools/commit/58d047ec3492df172067312203da49c8af83a1a8))
|
|
11
|
+
* **grz-cli:** also write submission ID to logs on upload ([#347](https://github.com/BfArM-MVH/grz-tools/issues/347)) ([1de43aa](https://github.com/BfArM-MVH/grz-tools/commit/1de43aa5807f22bff47683c2da356f607180ef51))
|
|
12
|
+
* **grz-cli:** write command line to logs ([#354](https://github.com/BfArM-MVH/grz-tools/issues/354)) ([bc28b23](https://github.com/BfArM-MVH/grz-tools/commit/bc28b23ae617d7c8837e872c24858b50d35bf25a))
|
|
13
|
+
* **grzctl:** also report grz library versions ([58d047e](https://github.com/BfArM-MVH/grz-tools/commit/58d047ec3492df172067312203da49c8af83a1a8))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Documentation
|
|
17
|
+
|
|
18
|
+
* **grz-cli:** add docs for submit command to README ([#351](https://github.com/BfArM-MVH/grz-tools/issues/351)) ([8d4b138](https://github.com/BfArM-MVH/grz-tools/commit/8d4b13850da435dfee60060caf4a47ddbe59a4d4))
|
|
19
|
+
* **grz-cli:** clean and update README ([#352](https://github.com/BfArM-MVH/grz-tools/issues/352)) ([5c037b7](https://github.com/BfArM-MVH/grz-tools/commit/5c037b749b5cd97b44a53c61618e35787ab11f2a))
|
|
20
|
+
|
|
21
|
+
## [1.1.2](https://github.com/BfArM-MVH/grz-tools/compare/grz-cli-v1.1.1...grz-cli-v1.1.2) (2025-08-05)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* **grz-cli,grz-common,grzctl:** fix logging and migrate to grz-common ([#319](https://github.com/BfArM-MVH/grz-tools/issues/319)) ([51ada07](https://github.com/BfArM-MVH/grz-tools/commit/51ada073a2af93ba1a1c48f069b4546ce9bd2975))
|
|
27
|
+
|
|
3
28
|
## [1.1.1](https://github.com/BfArM-MVH/grz-tools/compare/grz-cli-v1.1.0...grz-cli-v1.1.1) (2025-07-23)
|
|
4
29
|
|
|
5
30
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: grz-cli
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: Tool for validation, encryption and upload of MV submissions to GDCs.
|
|
5
5
|
Project-URL: Homepage, https://github.com/BfArM-MVH/grz-tools
|
|
6
6
|
Project-URL: Repository, https://github.com/BfArM-MVH/grz-tools
|
|
@@ -16,8 +16,8 @@ Requires-Python: >=3.12
|
|
|
16
16
|
Requires-Dist: boto3<2,>=1.36
|
|
17
17
|
Requires-Dist: click<9,>=8.2
|
|
18
18
|
Requires-Dist: crypt4gh<2,>=1.7
|
|
19
|
-
Requires-Dist: grz-common<2,>=1.
|
|
20
|
-
Requires-Dist: grz-pydantic-models<3,>=2.1
|
|
19
|
+
Requires-Dist: grz-common<2,>=1.3.0
|
|
20
|
+
Requires-Dist: grz-pydantic-models<3,>=2.2.1
|
|
21
21
|
Requires-Dist: jsonschema<5,>=4.23.0
|
|
22
22
|
Requires-Dist: platformdirs<5,>=4.3.6
|
|
23
23
|
Requires-Dist: pydantic-settings<2.10,>=2.9.0
|
|
@@ -29,93 +29,61 @@ Requires-Dist: rich==13.*
|
|
|
29
29
|
Requires-Dist: tqdm<5,>=4.66.5
|
|
30
30
|
Description-Content-Type: text/markdown
|
|
31
31
|
|
|
32
|
-
#
|
|
32
|
+
# `grz-cli`
|
|
33
|
+
|
|
34
|
+
A command-line tool for validating, encrypting, and uploading submissions to a genomDE Model Project GDC (Genome Data Center).
|
|
33
35
|
|
|
34
|
-
A command-line tool for validating, encrypting, uploading and downloading submissions to/from a GDC/GRZ (Genomrechenzentrum).
|
|
35
36
|
|
|
36
37
|
## Table of Contents
|
|
37
38
|
|
|
38
|
-
- [Introduction](#introduction)
|
|
39
|
-
- [Features](#features)
|
|
40
39
|
- [Installation](#installation)
|
|
41
40
|
- [Requirements](#requirements)
|
|
42
|
-
- [
|
|
43
|
-
|
|
44
|
-
- [Installation via `pip` (not recommended)](#installation-via-pip-not-recommended)
|
|
41
|
+
- [Using Conda (recommended)](#using-conda-recommended)
|
|
42
|
+
- [Using Docker](#using-docker)
|
|
45
43
|
- [Usage](#usage)
|
|
46
44
|
- [Configuration](#configuration)
|
|
47
|
-
- [
|
|
45
|
+
- [Submission Layout](#submission-layout)
|
|
46
|
+
- [Example submission procedure](#example-submission-procedure)
|
|
47
|
+
- [Troubleshooting](#troubleshooting)
|
|
48
48
|
- [Command-Line Interface](#command-line-interface)
|
|
49
|
-
- [Testing](#testing)
|
|
50
49
|
- [Contributing](#contributing)
|
|
51
50
|
- [License](#license)
|
|
52
51
|
- [Acknowledgements](#acknowledgements)
|
|
53
52
|
|
|
54
|
-
## Introduction
|
|
55
|
-
|
|
56
|
-
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.
|
|
57
|
-
|
|
58
|
-
It is recommended to have the following folder structure for a single submission:
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
EXAMPLE_SUBMISSION
|
|
62
|
-
├── files
|
|
63
|
-
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.read1.fastq.gz
|
|
64
|
-
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.read2.fastq.gz
|
|
65
|
-
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.vcf
|
|
66
|
-
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.read1.fastq.gz
|
|
67
|
-
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.read2.fastq.gz
|
|
68
|
-
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.vcf
|
|
69
|
-
│ ├── target_regions.bed
|
|
70
|
-
└── metadata
|
|
71
|
-
└── metadata.json
|
|
72
|
-
```
|
|
73
53
|
|
|
74
|
-
|
|
75
|
-
## Features
|
|
54
|
+
## Installation
|
|
76
55
|
|
|
77
|
-
|
|
78
|
-
- **Encryption**: Encrypt files using `crypt4gh`.
|
|
79
|
-
- **Decryption**: Encrypt files using `crypt4gh`.
|
|
80
|
-
- **Upload**: Upload encrypted files directly to a GRZ either (via built-in `boto3`).
|
|
81
|
-
- **Download**: Download encrypted files from a GRZ (via built-in `boto3`).
|
|
82
|
-
- **Logging**: Log progress and results of operations
|
|
56
|
+
### Requirements
|
|
83
57
|
|
|
58
|
+
The current version of the tool requires the working directory to have at least as much free disk space as the total size of the data being submitted.
|
|
84
59
|
|
|
85
|
-
|
|
60
|
+
Beside of the disk space requirements for the submission data, this tool also requires a Linux environment.
|
|
61
|
+
For example:
|
|
86
62
|
|
|
87
|
-
### Requirements
|
|
88
|
-
Beside of the disk space requirements for the submission data, this tool also requires a linux environment, e.g.:
|
|
89
63
|
- Linux server
|
|
90
|
-
- Virtual machine running
|
|
64
|
+
- Virtual machine running Linux
|
|
91
65
|
- Docker container
|
|
92
|
-
- Windows
|
|
93
|
-
- ...
|
|
94
|
-
|
|
66
|
+
- Windows Subsystem for Linux
|
|
95
67
|
|
|
96
|
-
### End-user setup
|
|
97
|
-
The recommended method to install this tool is using the conda package manager.
|
|
98
68
|
|
|
69
|
+
### Using [Conda](https://conda.io) (recommended)
|
|
99
70
|
|
|
100
|
-
|
|
71
|
+
If Conda is not yet available on your system, we recommend to install it through the [Miniforge Conda installer](https://github.com/conda-forge/miniforge) by running the following commands:
|
|
101
72
|
|
|
102
|
-
If `conda` is not yet available on your system, we recommend to install the [Miniforge conda distribution](https://github.com/conda-forge/miniforge) by running the following commands:
|
|
103
73
|
```bash
|
|
104
74
|
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
|
|
105
75
|
bash Miniforge3-$(uname)-$(uname -m).sh
|
|
106
76
|
```
|
|
107
|
-
There are also alternative ways to install conda:
|
|
108
|
-
- [Micromamba, a single executable that does not require a base environment](https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html)
|
|
109
|
-
- [Official installation instructions](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html)
|
|
110
77
|
|
|
111
78
|
Next, install the `grz-cli` tool:
|
|
79
|
+
|
|
112
80
|
```bash
|
|
113
|
-
|
|
114
|
-
conda create -n grz-tools -c conda-forge -c bioconda "grz-cli"
|
|
81
|
+
conda create -n grz-tools -c conda-forge -c bioconda grz-cli
|
|
115
82
|
conda activate grz-tools
|
|
83
|
+
grz-cli --help
|
|
116
84
|
```
|
|
117
85
|
|
|
118
|
-
|
|
86
|
+
#### Updating
|
|
119
87
|
|
|
120
88
|
Use the following command to update the tool:
|
|
121
89
|
|
|
@@ -124,59 +92,97 @@ conda update -n grz-tools -c conda-forge -c bioconda grz-cli
|
|
|
124
92
|
```
|
|
125
93
|
|
|
126
94
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
95
|
+
### Using pip (not recommended)
|
|
96
|
+
|
|
97
|
+
While installation via `pip` is possible, it is not recommended because users should create/manage a Python virtual environment and must ensure that the correct Python version is being used.
|
|
130
98
|
|
|
131
99
|
```bash
|
|
132
100
|
pip install grz-cli
|
|
133
101
|
```
|
|
134
|
-
|
|
102
|
+
|
|
103
|
+
#### Updating
|
|
104
|
+
|
|
135
105
|
Use the following command to update the tool:
|
|
106
|
+
|
|
136
107
|
```bash
|
|
137
108
|
pip upgrade grz-cli
|
|
138
109
|
```
|
|
139
110
|
|
|
140
111
|
|
|
141
|
-
|
|
112
|
+
### Using Docker
|
|
113
|
+
|
|
142
114
|
Docker images are available via biocontainers at [https://biocontainers.pro/tools/grz-cli](https://biocontainers.pro/tools/grz-cli).
|
|
143
115
|
|
|
144
|
-
The build process can take at least a few days after the Bioconda release, so double-check that the latest version in Bioconda is also the latest Docker image version.
|
|
116
|
+
The build process can take at least a few days after the Bioconda release, so double-check that the [latest version in Bioconda](https://anaconda.org/bioconda/grz-cli) is also the latest Docker image version.
|
|
145
117
|
|
|
146
118
|
## Usage
|
|
147
119
|
|
|
148
120
|
### Configuration
|
|
149
|
-
**The configuration file will be provided by your associated GRZ, please place it into `~/.config/grz-cli/config.yaml`.**
|
|
150
121
|
|
|
151
|
-
The
|
|
152
|
-
|
|
122
|
+
**The configuration file will be provided by your associated GRZ.**
|
|
123
|
+
**Do not create this file as an LE.**
|
|
124
|
+
|
|
125
|
+
The tool requires a configuration file in YAML format to specify the S3 API parameters and other validation options.
|
|
126
|
+
|
|
127
|
+
This file may be placed at `~/.config/grz-cli/config.yaml` or provided each time to `grz-cli` using the `--config-file` option on the command line.
|
|
128
|
+
|
|
129
|
+
The S3 secrets can either be directly within the config file or as defined with the usual AWS environment variables: `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`.
|
|
130
|
+
|
|
131
|
+
### Submission Layout
|
|
132
|
+
|
|
133
|
+
It is recommended to have the following folder structure for a single submission:
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
EXAMPLE_SUBMISSION
|
|
137
|
+
├── files
|
|
138
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.read1.fastq.gz
|
|
139
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.read2.fastq.gz
|
|
140
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.vcf
|
|
141
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.read1.fastq.gz
|
|
142
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.read2.fastq.gz
|
|
143
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.vcf
|
|
144
|
+
│ └─── target_regions.bed
|
|
145
|
+
└── metadata
|
|
146
|
+
└── metadata.json
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The only requirements are that `metadata/metadata.json` exists and the `files/` directory contains all of the other files.
|
|
150
|
+
Data files may be nested under subfolders inside `files/` for better organization.
|
|
151
|
+
For example, each donor could have their own folder for files.
|
|
153
152
|
|
|
154
|
-
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`).
|
|
155
153
|
|
|
156
|
-
###
|
|
157
|
-
After preparing your submission as outlined above, you can use the following commands to validate, encrypt and upload the submission:
|
|
158
|
-
```sh
|
|
159
|
-
# Validate the submission
|
|
160
|
-
grz-cli validate --submission-dir EXAMPLE_SUBMISSION
|
|
154
|
+
### Example submission procedure
|
|
161
155
|
|
|
162
|
-
|
|
163
|
-
grz-cli encrypt --submission-dir EXAMPLE_SUBMISSION
|
|
156
|
+
After preparing your submission as outlined above, you can use the following command to validate, encrypt and upload the submission:
|
|
164
157
|
|
|
165
|
-
|
|
166
|
-
grz-cli
|
|
158
|
+
```bash
|
|
159
|
+
grz-cli submit --submission-dir EXAMPLE_SUBMISSION
|
|
167
160
|
```
|
|
168
161
|
|
|
169
162
|
### Troubleshooting
|
|
170
|
-
|
|
163
|
+
|
|
164
|
+
In case of issues, please re-run your commands with `grz-cli --log-level DEBUG --log-file path/to/write/file.log [...]` and submit the log file to the GDC data steward.
|
|
171
165
|
|
|
172
166
|
## Command-Line Interface
|
|
173
167
|
|
|
174
168
|
`grz-cli` provides a command-line interface with the following subcommands:
|
|
175
169
|
|
|
170
|
+
### submit
|
|
171
|
+
|
|
172
|
+
The `submit` command is the recommended command for submitting data to genome data centers.
|
|
173
|
+
It combines the `validate`, `encrypt`, and `upload` commands (see below).
|
|
174
|
+
|
|
175
|
+
- `-s, --submission-dir`: Path to the submission directory containing both 'metadata/' and 'files/' directories [**Required**]
|
|
176
|
+
- `-c, --config-file`: Path to config file [_optional_]
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
grz-cli submit --submission-dir foo
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
|
|
176
183
|
### validate
|
|
177
184
|
|
|
178
185
|
It is recommended to run this command before continuing with encryption and upload.
|
|
179
|
-
Progress files are stored relative to the submission directory.
|
|
180
186
|
|
|
181
187
|
- `--submission-dir`: Path to the submission directory containing both 'metadata/' and 'files/' directories [**Required**]
|
|
182
188
|
|
|
@@ -188,7 +194,7 @@ grz_cli validate --submission-dir foo
|
|
|
188
194
|
|
|
189
195
|
### encrypt
|
|
190
196
|
|
|
191
|
-
If a working directory is not provided, then the current directory is used automatically.
|
|
197
|
+
If a working directory is not provided, then the current directory is used automatically.
|
|
192
198
|
Files are stored in a folder named `encrypted_files` as a sub-folder of the working directory.
|
|
193
199
|
|
|
194
200
|
- `-s, --submission-dir`: Path to the submission directory containing both 'metadata/' and 'files/' directories [**Required**]
|
|
@@ -202,7 +208,7 @@ grz-cli encrypt --submission-dir foo
|
|
|
202
208
|
|
|
203
209
|
Upload the submission into a S3 structure of a GRZ.
|
|
204
210
|
|
|
205
|
-
- `-s, --submission-dir`: Path to the submission directory containing both
|
|
211
|
+
- `-s, --submission-dir`: Path to the submission directory containing both `metadata/` and `encrypted_files/` directories [**Required**]
|
|
206
212
|
- `-c, --config-file`: Path to config file [_optional_]
|
|
207
213
|
|
|
208
214
|
Example usage:
|
|
@@ -211,16 +217,39 @@ Example usage:
|
|
|
211
217
|
grz-cli upload --submission-dir foo
|
|
212
218
|
```
|
|
213
219
|
|
|
214
|
-
|
|
220
|
+
### get-id
|
|
215
221
|
|
|
216
|
-
|
|
222
|
+
*Available in grz-cli v1.2.0 or higher.*
|
|
217
223
|
|
|
218
|
-
|
|
219
|
-
|
|
224
|
+
Compute and print the submission ID from a submission's JSON metadata.
|
|
225
|
+
|
|
226
|
+
This is useful in case you forget to store the ID printed during upload.
|
|
227
|
+
|
|
228
|
+
Example usage:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
grz-cli get-id path/to/metadata.json
|
|
232
|
+
```
|
|
220
233
|
|
|
221
234
|
## Contributing
|
|
222
235
|
|
|
223
|
-
|
|
236
|
+
### Running unreleased/development versions
|
|
237
|
+
|
|
238
|
+
First, install `uv`.
|
|
239
|
+
We recommend using Conda or [Pixi](https://pixi.sh/latest).
|
|
240
|
+
|
|
241
|
+
After cloning the desired branch of the `grz-tools` repo locally, you can run `grz-cli` directly from the repo using:
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
uv run --project path/to/cloned/grz-tools grz-cli --help
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Testing
|
|
248
|
+
|
|
249
|
+
Please note that binary files used for testing are managed with [Git LFS](https://git-lfs.com), which will be needed to clone them locally with the git repository.
|
|
250
|
+
|
|
251
|
+
To run the tests, navigate to the root directory of your project and invoke `pytest`.
|
|
252
|
+
Alternatively, install `uv` and `tox` and run `uv run tox`.
|
|
224
253
|
|
|
225
254
|
## License
|
|
226
255
|
|
|
@@ -228,5 +257,4 @@ This project is licensed under the MIT License — see the [LICENSE](LICENSE) fi
|
|
|
228
257
|
|
|
229
258
|
## Acknowledgements
|
|
230
259
|
|
|
231
|
-
Parts of
|
|
232
|
-
|
|
260
|
+
Parts of [Crypt4GH](https://github.com/EGA-archive/crypt4gh) are used in modified form.
|
grz_cli-1.2.0/README.md
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# `grz-cli`
|
|
2
|
+
|
|
3
|
+
A command-line tool for validating, encrypting, and uploading submissions to a genomDE Model Project GDC (Genome Data Center).
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Table of Contents
|
|
7
|
+
|
|
8
|
+
- [Installation](#installation)
|
|
9
|
+
- [Requirements](#requirements)
|
|
10
|
+
- [Using Conda (recommended)](#using-conda-recommended)
|
|
11
|
+
- [Using Docker](#using-docker)
|
|
12
|
+
- [Usage](#usage)
|
|
13
|
+
- [Configuration](#configuration)
|
|
14
|
+
- [Submission Layout](#submission-layout)
|
|
15
|
+
- [Example submission procedure](#example-submission-procedure)
|
|
16
|
+
- [Troubleshooting](#troubleshooting)
|
|
17
|
+
- [Command-Line Interface](#command-line-interface)
|
|
18
|
+
- [Contributing](#contributing)
|
|
19
|
+
- [License](#license)
|
|
20
|
+
- [Acknowledgements](#acknowledgements)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
### Requirements
|
|
26
|
+
|
|
27
|
+
The current version of the tool requires the working directory to have at least as much free disk space as the total size of the data being submitted.
|
|
28
|
+
|
|
29
|
+
Beside of the disk space requirements for the submission data, this tool also requires a Linux environment.
|
|
30
|
+
For example:
|
|
31
|
+
|
|
32
|
+
- Linux server
|
|
33
|
+
- Virtual machine running Linux
|
|
34
|
+
- Docker container
|
|
35
|
+
- Windows Subsystem for Linux
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Using [Conda](https://conda.io) (recommended)
|
|
39
|
+
|
|
40
|
+
If Conda is not yet available on your system, we recommend to install it through the [Miniforge Conda installer](https://github.com/conda-forge/miniforge) by running the following commands:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
|
|
44
|
+
bash Miniforge3-$(uname)-$(uname -m).sh
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Next, install the `grz-cli` tool:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
conda create -n grz-tools -c conda-forge -c bioconda grz-cli
|
|
51
|
+
conda activate grz-tools
|
|
52
|
+
grz-cli --help
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### Updating
|
|
56
|
+
|
|
57
|
+
Use the following command to update the tool:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
conda update -n grz-tools -c conda-forge -c bioconda grz-cli
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
### Using pip (not recommended)
|
|
65
|
+
|
|
66
|
+
While installation via `pip` is possible, it is not recommended because users should create/manage a Python virtual environment and must ensure that the correct Python version is being used.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install grz-cli
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### Updating
|
|
73
|
+
|
|
74
|
+
Use the following command to update the tool:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pip upgrade grz-cli
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### Using Docker
|
|
82
|
+
|
|
83
|
+
Docker images are available via biocontainers at [https://biocontainers.pro/tools/grz-cli](https://biocontainers.pro/tools/grz-cli).
|
|
84
|
+
|
|
85
|
+
The build process can take at least a few days after the Bioconda release, so double-check that the [latest version in Bioconda](https://anaconda.org/bioconda/grz-cli) is also the latest Docker image version.
|
|
86
|
+
|
|
87
|
+
## Usage
|
|
88
|
+
|
|
89
|
+
### Configuration
|
|
90
|
+
|
|
91
|
+
**The configuration file will be provided by your associated GRZ.**
|
|
92
|
+
**Do not create this file as an LE.**
|
|
93
|
+
|
|
94
|
+
The tool requires a configuration file in YAML format to specify the S3 API parameters and other validation options.
|
|
95
|
+
|
|
96
|
+
This file may be placed at `~/.config/grz-cli/config.yaml` or provided each time to `grz-cli` using the `--config-file` option on the command line.
|
|
97
|
+
|
|
98
|
+
The S3 secrets can either be directly within the config file or as defined with the usual AWS environment variables: `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`.
|
|
99
|
+
|
|
100
|
+
### Submission Layout
|
|
101
|
+
|
|
102
|
+
It is recommended to have the following folder structure for a single submission:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
EXAMPLE_SUBMISSION
|
|
106
|
+
├── files
|
|
107
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.read1.fastq.gz
|
|
108
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.read2.fastq.gz
|
|
109
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.vcf
|
|
110
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.read1.fastq.gz
|
|
111
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.read2.fastq.gz
|
|
112
|
+
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.vcf
|
|
113
|
+
│ └─── target_regions.bed
|
|
114
|
+
└── metadata
|
|
115
|
+
└── metadata.json
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The only requirements are that `metadata/metadata.json` exists and the `files/` directory contains all of the other files.
|
|
119
|
+
Data files may be nested under subfolders inside `files/` for better organization.
|
|
120
|
+
For example, each donor could have their own folder for files.
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
### Example submission procedure
|
|
124
|
+
|
|
125
|
+
After preparing your submission as outlined above, you can use the following command to validate, encrypt and upload the submission:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
grz-cli submit --submission-dir EXAMPLE_SUBMISSION
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Troubleshooting
|
|
132
|
+
|
|
133
|
+
In case of issues, please re-run your commands with `grz-cli --log-level DEBUG --log-file path/to/write/file.log [...]` and submit the log file to the GDC data steward.
|
|
134
|
+
|
|
135
|
+
## Command-Line Interface
|
|
136
|
+
|
|
137
|
+
`grz-cli` provides a command-line interface with the following subcommands:
|
|
138
|
+
|
|
139
|
+
### submit
|
|
140
|
+
|
|
141
|
+
The `submit` command is the recommended command for submitting data to genome data centers.
|
|
142
|
+
It combines the `validate`, `encrypt`, and `upload` commands (see below).
|
|
143
|
+
|
|
144
|
+
- `-s, --submission-dir`: Path to the submission directory containing both 'metadata/' and 'files/' directories [**Required**]
|
|
145
|
+
- `-c, --config-file`: Path to config file [_optional_]
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
grz-cli submit --submission-dir foo
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
### validate
|
|
153
|
+
|
|
154
|
+
It is recommended to run this command before continuing with encryption and upload.
|
|
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
|
+
### encrypt
|
|
165
|
+
|
|
166
|
+
If a working directory is not provided, then the current directory is used automatically.
|
|
167
|
+
Files are stored in a folder named `encrypted_files` as a sub-folder of the working directory.
|
|
168
|
+
|
|
169
|
+
- `-s, --submission-dir`: Path to the submission directory containing both 'metadata/' and 'files/' directories [**Required**]
|
|
170
|
+
- `-c, --config-file`: Path to config file [_optional_]
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
grz-cli encrypt --submission-dir foo
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### upload
|
|
177
|
+
|
|
178
|
+
Upload the submission into a S3 structure of a GRZ.
|
|
179
|
+
|
|
180
|
+
- `-s, --submission-dir`: Path to the submission directory containing both `metadata/` and `encrypted_files/` directories [**Required**]
|
|
181
|
+
- `-c, --config-file`: Path to config file [_optional_]
|
|
182
|
+
|
|
183
|
+
Example usage:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
grz-cli upload --submission-dir foo
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### get-id
|
|
190
|
+
|
|
191
|
+
*Available in grz-cli v1.2.0 or higher.*
|
|
192
|
+
|
|
193
|
+
Compute and print the submission ID from a submission's JSON metadata.
|
|
194
|
+
|
|
195
|
+
This is useful in case you forget to store the ID printed during upload.
|
|
196
|
+
|
|
197
|
+
Example usage:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
grz-cli get-id path/to/metadata.json
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Contributing
|
|
204
|
+
|
|
205
|
+
### Running unreleased/development versions
|
|
206
|
+
|
|
207
|
+
First, install `uv`.
|
|
208
|
+
We recommend using Conda or [Pixi](https://pixi.sh/latest).
|
|
209
|
+
|
|
210
|
+
After cloning the desired branch of the `grz-tools` repo locally, you can run `grz-cli` directly from the repo using:
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
uv run --project path/to/cloned/grz-tools grz-cli --help
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Testing
|
|
217
|
+
|
|
218
|
+
Please note that binary files used for testing are managed with [Git LFS](https://git-lfs.com), which will be needed to clone them locally with the git repository.
|
|
219
|
+
|
|
220
|
+
To run the tests, navigate to the root directory of your project and invoke `pytest`.
|
|
221
|
+
Alternatively, install `uv` and `tox` and run `uv run tox`.
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.
|
|
226
|
+
|
|
227
|
+
## Acknowledgements
|
|
228
|
+
|
|
229
|
+
Parts of [Crypt4GH](https://github.com/EGA-archive/crypt4gh) are used in modified form.
|
|
@@ -22,11 +22,11 @@ dependencies = [
|
|
|
22
22
|
"pydantic >=2.9.2,<2.10",
|
|
23
23
|
"pydantic-settings >=2.9.0,<2.10",
|
|
24
24
|
"platformdirs >=4.3.6,<5",
|
|
25
|
-
"grz-pydantic-models >=2.1
|
|
25
|
+
"grz-pydantic-models >=2.2.1,<3",
|
|
26
26
|
"pysam ==0.23.*",
|
|
27
27
|
"rich ==13.*",
|
|
28
28
|
"requests >=2.32.3,<3",
|
|
29
|
-
"grz-common >=1.
|
|
29
|
+
"grz-common >=1.3.0,<2",
|
|
30
30
|
]
|
|
31
31
|
classifiers = [
|
|
32
32
|
"Programming Language :: Python :: 3",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.2.0"
|
|
@@ -4,19 +4,23 @@ CLI module for handling command-line interface operations.
|
|
|
4
4
|
|
|
5
5
|
import logging
|
|
6
6
|
import logging.config
|
|
7
|
+
import shutil
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
7
10
|
from importlib.metadata import version
|
|
11
|
+
from textwrap import dedent
|
|
8
12
|
|
|
9
13
|
import click
|
|
10
14
|
import grz_pydantic_models.submission.metadata
|
|
15
|
+
from grz_common.logging import setup_cli_logging
|
|
11
16
|
|
|
12
17
|
from .commands.encrypt import encrypt
|
|
18
|
+
from .commands.get_id import get_id
|
|
13
19
|
from .commands.submit import submit
|
|
14
20
|
from .commands.upload import upload
|
|
15
21
|
from .commands.validate import validate
|
|
16
|
-
from .constants import PACKAGE_ROOT
|
|
17
|
-
from .logging_setup import add_filelogger
|
|
18
22
|
|
|
19
|
-
log = logging.getLogger(
|
|
23
|
+
log = logging.getLogger(__name__)
|
|
20
24
|
|
|
21
25
|
|
|
22
26
|
class OrderedGroup(click.Group):
|
|
@@ -41,7 +45,17 @@ def build_cli():
|
|
|
41
45
|
@click.version_option(
|
|
42
46
|
version=version("grz-cli"),
|
|
43
47
|
prog_name="grz-cli",
|
|
44
|
-
message=f"
|
|
48
|
+
message=dedent(f"""\
|
|
49
|
+
%(prog)s v%(version)s
|
|
50
|
+
Currently accepted metadata schema versions: {", ".join(grz_pydantic_models.submission.metadata.get_accepted_versions())}
|
|
51
|
+
grz-common v{version("grz-common")}
|
|
52
|
+
grz-pydantic-models v{version("grz-pydantic-models")}
|
|
53
|
+
""")
|
|
54
|
+
+ (
|
|
55
|
+
subprocess.run(["grz-check", "--version"], capture_output=True, text=True).stdout.strip() # noqa: S603, S607
|
|
56
|
+
if shutil.which("grz-check") is not None
|
|
57
|
+
else ""
|
|
58
|
+
),
|
|
45
59
|
)
|
|
46
60
|
@click.option("--log-file", metavar="FILE", type=str, help="Path to log file")
|
|
47
61
|
@click.option(
|
|
@@ -58,26 +72,15 @@ def build_cli():
|
|
|
58
72
|
:param log_level: Log level for the logger. It should be one of the following:
|
|
59
73
|
DEBUG, INFO, WARNING, ERROR, CRITICAL.
|
|
60
74
|
"""
|
|
61
|
-
|
|
62
|
-
add_filelogger(
|
|
63
|
-
log_file,
|
|
64
|
-
log_level.upper(),
|
|
65
|
-
) # Add file logger
|
|
75
|
+
setup_cli_logging(log_file, log_level)
|
|
66
76
|
|
|
67
|
-
|
|
68
|
-
logging.basicConfig(
|
|
69
|
-
format="%(asctime)s - %(levelname)s - %(message)s",
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
# set the log level for this package
|
|
73
|
-
logging.getLogger(PACKAGE_ROOT).setLevel(log_level.upper())
|
|
74
|
-
|
|
75
|
-
log.debug("Logging setup complete.")
|
|
77
|
+
log.info(f"Running command: {' '.join(sys.argv)}")
|
|
76
78
|
|
|
77
79
|
cli.add_command(validate)
|
|
78
80
|
cli.add_command(encrypt)
|
|
79
81
|
cli.add_command(upload)
|
|
80
82
|
cli.add_command(submit)
|
|
83
|
+
cli.add_command(get_id)
|
|
81
84
|
|
|
82
85
|
return cli
|
|
83
86
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Command for computing the submission ID from the submission metadata."""
|
|
2
|
+
|
|
3
|
+
import io
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
import click
|
|
7
|
+
from grz_pydantic_models.submission.metadata import GrzSubmissionMetadata
|
|
8
|
+
|
|
9
|
+
log = logging.getLogger(__name__)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@click.command("get-id")
|
|
13
|
+
@click.argument("metadata", type=click.File("r"))
|
|
14
|
+
def get_id(metadata: io.TextIOWrapper):
|
|
15
|
+
"""
|
|
16
|
+
Compute the submission ID for a given metadata JSON file.
|
|
17
|
+
"""
|
|
18
|
+
click.echo(GrzSubmissionMetadata.model_validate_json(metadata.read()).submission_id)
|
|
@@ -39,6 +39,8 @@ def upload(
|
|
|
39
39
|
threads=threads,
|
|
40
40
|
)
|
|
41
41
|
# output the generated submission ID
|
|
42
|
-
|
|
42
|
+
submission_id = worker_inst.upload(config.s3)
|
|
43
|
+
log.info(f"Generated submission ID for upload: {submission_id}")
|
|
44
|
+
click.echo(submission_id)
|
|
43
45
|
|
|
44
46
|
log.info("Upload finished!")
|
grz_cli-1.1.1/README.md
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
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
|
-
- [Requirements](#requirements)
|
|
11
|
-
- [End-user setup](#end-user-setup)
|
|
12
|
-
- [Installation via `conda` (recommended)](#installation-via-conda-recommended)
|
|
13
|
-
- [Installation via `pip` (not recommended)](#installation-via-pip-not-recommended)
|
|
14
|
-
- [Usage](#usage)
|
|
15
|
-
- [Configuration](#configuration)
|
|
16
|
-
- [Exemplary submission procedure](#exemplary-submission-procedure)
|
|
17
|
-
- [Command-Line Interface](#command-line-interface)
|
|
18
|
-
- [Testing](#testing)
|
|
19
|
-
- [Contributing](#contributing)
|
|
20
|
-
- [License](#license)
|
|
21
|
-
- [Acknowledgements](#acknowledgements)
|
|
22
|
-
|
|
23
|
-
## Introduction
|
|
24
|
-
|
|
25
|
-
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.
|
|
26
|
-
|
|
27
|
-
It is recommended to have the following folder structure for a single submission:
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
EXAMPLE_SUBMISSION
|
|
31
|
-
├── files
|
|
32
|
-
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.read1.fastq.gz
|
|
33
|
-
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.read2.fastq.gz
|
|
34
|
-
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_normal.vcf
|
|
35
|
-
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.read1.fastq.gz
|
|
36
|
-
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.read2.fastq.gz
|
|
37
|
-
│ ├── aaaaaaaa00000000aaaaaaaa00000000_blood_tumor.vcf
|
|
38
|
-
│ ├── target_regions.bed
|
|
39
|
-
└── metadata
|
|
40
|
-
└── metadata.json
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
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.
|
|
44
|
-
## Features
|
|
45
|
-
|
|
46
|
-
- **Validation**: Validate file checksums, basic file metadata and BfArM requirements.
|
|
47
|
-
- **Encryption**: Encrypt files using `crypt4gh`.
|
|
48
|
-
- **Decryption**: Encrypt files using `crypt4gh`.
|
|
49
|
-
- **Upload**: Upload encrypted files directly to a GRZ either (via built-in `boto3`).
|
|
50
|
-
- **Download**: Download encrypted files from a GRZ (via built-in `boto3`).
|
|
51
|
-
- **Logging**: Log progress and results of operations
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
## Installation
|
|
55
|
-
|
|
56
|
-
### Requirements
|
|
57
|
-
Beside of the disk space requirements for the submission data, this tool also requires a linux environment, e.g.:
|
|
58
|
-
- Linux server
|
|
59
|
-
- Virtual machine running linux
|
|
60
|
-
- Docker container
|
|
61
|
-
- Windows subsystem for linux
|
|
62
|
-
- ...
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
### End-user setup
|
|
66
|
-
The recommended method to install this tool is using the conda package manager.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
#### Installation via `conda` (recommended)
|
|
70
|
-
|
|
71
|
-
If `conda` is not yet available on your system, we recommend to install the [Miniforge conda distribution](https://github.com/conda-forge/miniforge) by running the following commands:
|
|
72
|
-
```bash
|
|
73
|
-
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
|
|
74
|
-
bash Miniforge3-$(uname)-$(uname -m).sh
|
|
75
|
-
```
|
|
76
|
-
There are also alternative ways to install conda:
|
|
77
|
-
- [Micromamba, a single executable that does not require a base environment](https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html)
|
|
78
|
-
- [Official installation instructions](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html)
|
|
79
|
-
|
|
80
|
-
Next, install the `grz-cli` tool:
|
|
81
|
-
```bash
|
|
82
|
-
# create conda environment and activate it
|
|
83
|
-
conda create -n grz-tools -c conda-forge -c bioconda "grz-cli"
|
|
84
|
-
conda activate grz-tools
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
##### Update instructions
|
|
88
|
-
|
|
89
|
-
Use the following command to update the tool:
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
conda update -n grz-tools -c conda-forge -c bioconda grz-cli
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
#### Installation via `pip` (not recommended)
|
|
97
|
-
While installation via `pip` is possible, it is not recommended because users must ensure
|
|
98
|
-
that the correct Python version is already installed and that they are using a virtual python environment.
|
|
99
|
-
|
|
100
|
-
```bash
|
|
101
|
-
pip install grz-cli
|
|
102
|
-
```
|
|
103
|
-
##### Update instructions:
|
|
104
|
-
Use the following command to update the tool:
|
|
105
|
-
```bash
|
|
106
|
-
pip upgrade grz-cli
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
#### Docker
|
|
111
|
-
Docker images are available via biocontainers at [https://biocontainers.pro/tools/grz-cli](https://biocontainers.pro/tools/grz-cli).
|
|
112
|
-
|
|
113
|
-
The build process can take at least a few days after the Bioconda release, so double-check that the latest version in Bioconda is also the latest Docker image version.
|
|
114
|
-
|
|
115
|
-
## Usage
|
|
116
|
-
|
|
117
|
-
### Configuration
|
|
118
|
-
**The configuration file will be provided by your associated GRZ, please place it into `~/.config/grz-cli/config.yaml`.**
|
|
119
|
-
|
|
120
|
-
The tool requires a configuration file in YAML format to specify the S3 bucket and other options.
|
|
121
|
-
For an exemplary configuration, see [resources/config.yaml](resources/config.yaml).
|
|
122
|
-
|
|
123
|
-
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`).
|
|
124
|
-
|
|
125
|
-
### Exemplary submission procedure
|
|
126
|
-
After preparing your submission as outlined above, you can use the following commands to validate, encrypt and upload the submission:
|
|
127
|
-
```sh
|
|
128
|
-
# Validate the submission
|
|
129
|
-
grz-cli validate --submission-dir EXAMPLE_SUBMISSION
|
|
130
|
-
|
|
131
|
-
# Encrypt the submission
|
|
132
|
-
grz-cli encrypt --submission-dir EXAMPLE_SUBMISSION
|
|
133
|
-
|
|
134
|
-
# Upload the submission
|
|
135
|
-
grz-cli upload --submission-dir EXAMPLE_SUBMISSION
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Troubleshooting
|
|
139
|
-
**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!**
|
|
140
|
-
|
|
141
|
-
## Command-Line Interface
|
|
142
|
-
|
|
143
|
-
`grz-cli` provides a command-line interface with the following subcommands:
|
|
144
|
-
|
|
145
|
-
### validate
|
|
146
|
-
|
|
147
|
-
It is recommended to run this command before continuing with encryption and upload.
|
|
148
|
-
Progress files are stored relative to the submission directory.
|
|
149
|
-
|
|
150
|
-
- `--submission-dir`: Path to the submission directory containing both 'metadata/' and 'files/' directories [**Required**]
|
|
151
|
-
|
|
152
|
-
Example usage:
|
|
153
|
-
|
|
154
|
-
```bash
|
|
155
|
-
grz_cli validate --submission-dir foo
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### encrypt
|
|
159
|
-
|
|
160
|
-
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.
|
|
161
|
-
Files are stored in a folder named `encrypted_files` as a sub-folder of the working directory.
|
|
162
|
-
|
|
163
|
-
- `-s, --submission-dir`: Path to the submission directory containing both 'metadata/' and 'files/' directories [**Required**]
|
|
164
|
-
- `-c, --config-file`: Path to config file [_optional_]
|
|
165
|
-
|
|
166
|
-
```bash
|
|
167
|
-
grz-cli encrypt --submission-dir foo
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### upload
|
|
171
|
-
|
|
172
|
-
Upload the submission into a S3 structure of a GRZ.
|
|
173
|
-
|
|
174
|
-
- `-s, --submission-dir`: Path to the submission directory containing both 'metadata/' and 'encrypted_files/' directories [**Required**]
|
|
175
|
-
- `-c, --config-file`: Path to config file [_optional_]
|
|
176
|
-
|
|
177
|
-
Example usage:
|
|
178
|
-
|
|
179
|
-
```bash
|
|
180
|
-
grz-cli upload --submission-dir foo
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
## Testing
|
|
184
|
-
|
|
185
|
-
Please note that binary files used for testing are managed with [Git LFS](https://git-lfs.com), which will be needed to clone them locally with the git repository.
|
|
186
|
-
|
|
187
|
-
To run the tests, navigate to the root directory of your project and invoke `pytest`.
|
|
188
|
-
Alternatively, install `uv` and `tox` and run `uv run tox`.
|
|
189
|
-
|
|
190
|
-
## Contributing
|
|
191
|
-
|
|
192
|
-
<!-- Add details about how others can contribute to the project -->
|
|
193
|
-
|
|
194
|
-
## License
|
|
195
|
-
|
|
196
|
-
This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.
|
|
197
|
-
|
|
198
|
-
## Acknowledgements
|
|
199
|
-
|
|
200
|
-
Parts of `crypt4gh` code is used in modified form
|
|
201
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.1.1"
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"""Constants for logging configuration, JSON schema validation, and other settings."""
|
|
2
|
-
|
|
3
|
-
PACKAGE_ROOT = "grz_cli"
|
|
4
|
-
|
|
5
|
-
LOGGING_FORMAT = "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
|
|
6
|
-
LOGGING_DATEFMT = "%Y-%m-%d %I:%M %p"
|
|
7
|
-
LOGGING_CONFIG = {
|
|
8
|
-
"version": 1,
|
|
9
|
-
"disable_existing_loggers": True,
|
|
10
|
-
"formatters": {
|
|
11
|
-
"standard": {
|
|
12
|
-
"format": LOGGING_FORMAT,
|
|
13
|
-
"datefmt": LOGGING_DATEFMT,
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
"handlers": {
|
|
17
|
-
"default": {
|
|
18
|
-
"level": "INFO",
|
|
19
|
-
"formatter": "standard",
|
|
20
|
-
"class": "logging.StreamHandler",
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
"loggers": {
|
|
24
|
-
"": { # root logger
|
|
25
|
-
"handlers": ["default"],
|
|
26
|
-
"level": "WARNING",
|
|
27
|
-
"propagate": False,
|
|
28
|
-
},
|
|
29
|
-
PACKAGE_ROOT: {"handlers": ["default"], "level": "INFO", "propagate": False},
|
|
30
|
-
"__main__": { # if __name__ == '__main__'
|
|
31
|
-
"handlers": ["default"],
|
|
32
|
-
"level": "DEBUG",
|
|
33
|
-
"propagate": False,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
TQDM_SMOOTHING: float = 0.0001
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Module: logging_setup
|
|
3
|
-
|
|
4
|
-
This module provides functions for setting up logging configuration.
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
from __future__ import annotations
|
|
8
|
-
|
|
9
|
-
import logging
|
|
10
|
-
from os import PathLike
|
|
11
|
-
from pathlib import Path
|
|
12
|
-
|
|
13
|
-
from .constants import LOGGING_DATEFMT, LOGGING_FORMAT, PACKAGE_ROOT
|
|
14
|
-
|
|
15
|
-
log = logging.getLogger(__name__)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def add_filelogger(
|
|
19
|
-
file_path: str | PathLike | None = None,
|
|
20
|
-
level: str = "INFO",
|
|
21
|
-
logger_name: str = PACKAGE_ROOT,
|
|
22
|
-
) -> None:
|
|
23
|
-
"""
|
|
24
|
-
Add file logging for the specified package.
|
|
25
|
-
|
|
26
|
-
This function configures a file logger to capture log messages
|
|
27
|
-
for the package specified by _PACKAGE_ROOT. If no file path
|
|
28
|
-
is provided, a default log file will be created in the user's
|
|
29
|
-
home directory.
|
|
30
|
-
|
|
31
|
-
:param file_path: Optional; the path to the log file. If None,
|
|
32
|
-
a default path will be used.
|
|
33
|
-
:param level: Optional; the logging level. Default is 'INFO'.
|
|
34
|
-
Must be a valid logging level name (e.g., 'DEBUG', 'INFO').
|
|
35
|
-
:param logger_name:
|
|
36
|
-
"""
|
|
37
|
-
logger = logging.getLogger(logger_name)
|
|
38
|
-
|
|
39
|
-
if file_path is None:
|
|
40
|
-
default_log_dir = Path.home() / "logs"
|
|
41
|
-
default_log_dir.mkdir(parents=True, exist_ok=True)
|
|
42
|
-
file_path = default_log_dir / f"{PACKAGE_ROOT}.log"
|
|
43
|
-
log.warning("No log file path provided, using default: %s", file_path)
|
|
44
|
-
else:
|
|
45
|
-
file_path = Path(file_path)
|
|
46
|
-
|
|
47
|
-
try:
|
|
48
|
-
fh = logging.FileHandler(file_path)
|
|
49
|
-
fh.setLevel(level.upper())
|
|
50
|
-
fh.setFormatter(logging.Formatter(LOGGING_FORMAT, LOGGING_DATEFMT))
|
|
51
|
-
logger.addHandler(fh)
|
|
52
|
-
log.info(
|
|
53
|
-
"File logger added for %s at %s with level %s.",
|
|
54
|
-
logger.name,
|
|
55
|
-
file_path,
|
|
56
|
-
level.upper(),
|
|
57
|
-
)
|
|
58
|
-
except Exception as e:
|
|
59
|
-
log.error("Failed to add file logger: %s", e)
|
|
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
|