grz-common 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.
Files changed (32) hide show
  1. grz_common-0.1.0/.gitignore +195 -0
  2. grz_common-0.1.0/CHANGELOG.md +8 -0
  3. grz_common-0.1.0/PKG-INFO +30 -0
  4. grz_common-0.1.0/README.md +1 -0
  5. grz_common-0.1.0/pyproject.toml +51 -0
  6. grz_common-0.1.0/src/__init__.py +0 -0
  7. grz_common-0.1.0/src/grz_common/__init__.py +5 -0
  8. grz_common-0.1.0/src/grz_common/cli/__init__.py +79 -0
  9. grz_common-0.1.0/src/grz_common/constants.py +39 -0
  10. grz_common-0.1.0/src/grz_common/logging_setup.py +60 -0
  11. grz_common-0.1.0/src/grz_common/models/__init__.py +3 -0
  12. grz_common-0.1.0/src/grz_common/models/base.py +59 -0
  13. grz_common-0.1.0/src/grz_common/models/keys.py +45 -0
  14. grz_common-0.1.0/src/grz_common/models/s3.py +79 -0
  15. grz_common-0.1.0/src/grz_common/progress/__init__.py +21 -0
  16. grz_common-0.1.0/src/grz_common/progress/progress_logging.py +193 -0
  17. grz_common-0.1.0/src/grz_common/progress/states.py +53 -0
  18. grz_common-0.1.0/src/grz_common/py.typed +0 -0
  19. grz_common-0.1.0/src/grz_common/transfer.py +64 -0
  20. grz_common-0.1.0/src/grz_common/utils/__init__.py +3 -0
  21. grz_common-0.1.0/src/grz_common/utils/checksums.py +43 -0
  22. grz_common-0.1.0/src/grz_common/utils/crypt.py +143 -0
  23. grz_common-0.1.0/src/grz_common/utils/io.py +111 -0
  24. grz_common-0.1.0/src/grz_common/utils/paths.py +26 -0
  25. grz_common-0.1.0/src/grz_common/validation/__init__.py +1 -0
  26. grz_common-0.1.0/src/grz_common/validation/bam.py +39 -0
  27. grz_common-0.1.0/src/grz_common/validation/fastq.py +166 -0
  28. grz_common-0.1.0/src/grz_common/workers/__init__.py +1 -0
  29. grz_common-0.1.0/src/grz_common/workers/download.py +238 -0
  30. grz_common-0.1.0/src/grz_common/workers/submission.py +702 -0
  31. grz_common-0.1.0/src/grz_common/workers/upload.py +247 -0
  32. grz_common-0.1.0/src/grz_common/workers/worker.py +231 -0
@@ -0,0 +1,195 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ #pdm.lock
114
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
115
+ # in version control.
116
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
117
+ .pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
122
+ __pypackages__/
123
+
124
+ # Celery stuff
125
+ celerybeat-schedule
126
+ celerybeat.pid
127
+
128
+ # SageMath parsed files
129
+ *.sage.py
130
+
131
+ # Environments
132
+ .env
133
+ .venv
134
+ env/
135
+ venv/
136
+ ENV/
137
+ env.bak/
138
+ venv.bak/
139
+
140
+ # Spyder project settings
141
+ .spyderproject
142
+ .spyproject
143
+
144
+ # Rope project settings
145
+ .ropeproject
146
+
147
+ # mkdocs documentation
148
+ /site
149
+
150
+ # mypy
151
+ .mypy_cache/
152
+ .dmypy.json
153
+ dmypy.json
154
+
155
+ # Pyre type checker
156
+ .pyre/
157
+
158
+ # pytype static type analyzer
159
+ .pytype/
160
+
161
+ # Cython debug symbols
162
+ cython_debug/
163
+
164
+ # PyCharm
165
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
166
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
167
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
168
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
169
+ #.idea/
170
+
171
+ # Abstra
172
+ # Abstra is an AI-powered process automation framework.
173
+ # Ignore directories containing user credentials, local state, and settings.
174
+ # Learn more at https://abstra.io/docs
175
+ .abstra/
176
+
177
+ # Visual Studio Code
178
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
179
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
180
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
181
+ # you could uncomment the following to ignore the entire vscode folder
182
+ # .vscode/
183
+
184
+ # Ruff stuff:
185
+ .ruff_cache/
186
+
187
+ # PyPI configuration file
188
+ .pypirc
189
+
190
+ # Cursor
191
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
192
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
193
+ # refer to https://docs.cursor.com/context/ignore-files
194
+ .cursorignore
195
+ .cursorindexingignore
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2025-06-11)
4
+
5
+
6
+ ### Features
7
+
8
+ * migrate to monorepo configuration ([36c7360](https://github.com/BfArM-MVH/grz-tools/commit/36c736044ce09473cc664b4471117465c5cab9a3))
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: grz-common
3
+ Version: 0.1.0
4
+ Summary: Common library for grz applications
5
+ Project-URL: Homepage, https://github.com/BfArM-MVH/grz-tools
6
+ Project-URL: Repository, https://github.com/BfArM-MVH/grz-tools
7
+ Project-URL: Documentation, https://github.com/BfArM-MVH/grz-tools/tree/main/packages/grz-common
8
+ Project-URL: Issues, https://github.com/BfArM-MVH/grz-tools/issues
9
+ 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>, Travis Wrightsman <travis.wrightsman@uni-tuebingen.de>
10
+ License-Expression: MIT
11
+ Keywords: GDC,GRZ,S3
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Requires-Python: >=3.12
15
+ Requires-Dist: boto3<2,>=1.36
16
+ Requires-Dist: click<9,>=8.1.7
17
+ Requires-Dist: crypt4gh<2,>=1.7
18
+ Requires-Dist: grz-pydantic-models>=1.3.0
19
+ Requires-Dist: jsonschema<5,>=4.23.0
20
+ Requires-Dist: platformdirs<5,>=4.3.6
21
+ Requires-Dist: pydantic-settings<2.10,>=2.9.0
22
+ Requires-Dist: pydantic<2.10,>=2.9.2
23
+ Requires-Dist: pysam==0.23.*
24
+ Requires-Dist: pyyaml<7,>=6.0.2
25
+ Requires-Dist: requests<3,>=2.32.3
26
+ Requires-Dist: rich==13.*
27
+ Requires-Dist: tqdm<5,>=4.66.5
28
+ Description-Content-Type: text/markdown
29
+
30
+ Common code shared between packages in `grz-tools` (mainly `grz-cli` and `grzctl`).
@@ -0,0 +1 @@
1
+ Common code shared between packages in `grz-tools` (mainly `grz-cli` and `grzctl`).
@@ -0,0 +1,51 @@
1
+ [project]
2
+ name = "grz-common"
3
+ description = "Common library for grz applications"
4
+ readme = "README.md"
5
+ license = "MIT"
6
+ authors = [
7
+ { name = "Koray Kirli", email = "koraykirli@gmail.com" },
8
+ { name = "Mathias Lesche", email = "mathias.lesche@tu-dresden.de" },
9
+ { name = "Florian R. Hölzlwimmer", email = "git.ich@frhoelzlwimmer.de" },
10
+ { name = "Till Hartmann", email = "till.hartmann@bih-charite.de" },
11
+ { name = "Thomas Sell", email = "thomas.sell@bih-charite.de" },
12
+ { name = "Travis Wrightsman", email = "travis.wrightsman@uni-tuebingen.de" }
13
+ ]
14
+ dynamic = ["version"]
15
+ dependencies = [
16
+ "boto3 >=1.36,<2",
17
+ "click >=8.1.7,<9",
18
+ "crypt4gh >=1.7,<2",
19
+ "jsonschema >=4.23.0,<5",
20
+ "pyyaml >=6.0.2,<7",
21
+ "tqdm >=4.66.5,<5",
22
+ "pydantic >=2.9.2,<2.10",
23
+ "pydantic-settings >=2.9.0,<2.10",
24
+ "platformdirs >=4.3.6,<5",
25
+ "grz-pydantic-models >=1.3.0",
26
+ "pysam ==0.23.*",
27
+ "rich ==13.*",
28
+ "requests >=2.32.3,<3",
29
+ ]
30
+ classifiers = [
31
+ "Programming Language :: Python :: 3",
32
+ "Operating System :: OS Independent"
33
+ ]
34
+ requires-python = ">=3.12"
35
+ keywords = ["GRZ", "GDC", "S3"]
36
+
37
+ [project.urls]
38
+ Homepage = "https://github.com/BfArM-MVH/grz-tools"
39
+ Repository = "https://github.com/BfArM-MVH/grz-tools"
40
+ Documentation = "https://github.com/BfArM-MVH/grz-tools/tree/main/packages/grz-common"
41
+ Issues = "https://github.com/BfArM-MVH/grz-tools/issues"
42
+
43
+ [build-system]
44
+ requires = ["hatchling"]
45
+ build-backend = "hatchling.build"
46
+
47
+ [tool.hatch.build.targets.wheel]
48
+ packages = ["src/grz_common"]
49
+
50
+ [tool.hatch.version]
51
+ path = "src/grz_common/__init__.py"
File without changes
@@ -0,0 +1,5 @@
1
+ """
2
+ Common library for grz applications.
3
+ """
4
+
5
+ __version__ = "0.1.0"
@@ -0,0 +1,79 @@
1
+ """
2
+ Common click options for the CLI commands.
3
+ """
4
+
5
+ from os import sched_getaffinity
6
+ from pathlib import Path
7
+
8
+ import click
9
+ import platformdirs
10
+
11
+ DEFAULT_CONFIG_PATH = Path(platformdirs.user_config_dir("grz-cli")) / "config.yaml"
12
+
13
+ # Aliases for path types for click options
14
+ # Naming convention: {DIR,FILE}_{Read,Write}_{Exists,Create}
15
+ DIR_R_E = click.Path(
16
+ exists=True,
17
+ file_okay=False,
18
+ dir_okay=True,
19
+ readable=True,
20
+ writable=False,
21
+ resolve_path=True,
22
+ )
23
+ DIR_RW_C = click.Path(
24
+ exists=False,
25
+ file_okay=False,
26
+ dir_okay=True,
27
+ readable=True,
28
+ writable=True,
29
+ resolve_path=True,
30
+ )
31
+ FILE_R_E = click.Path(exists=True, file_okay=True, dir_okay=False, readable=True, resolve_path=True)
32
+
33
+ submission_dir = click.option(
34
+ "--submission-dir",
35
+ metavar="PATH",
36
+ type=DIR_R_E,
37
+ required=True,
38
+ help="Path to the submission directory containing 'metadata/', 'files/', 'encrypted_files/' and 'logs/' directories",
39
+ )
40
+
41
+ config_file = click.option(
42
+ "--config-file",
43
+ metavar="STRING",
44
+ type=FILE_R_E,
45
+ required=False,
46
+ default=DEFAULT_CONFIG_PATH,
47
+ help="Path to config file",
48
+ )
49
+
50
+ threads = click.option(
51
+ "--threads",
52
+ default=min(len(sched_getaffinity(0)), 4),
53
+ type=int,
54
+ show_default=True,
55
+ help="Number of threads to use for parallel operations",
56
+ )
57
+
58
+ submission_id = click.option(
59
+ "--submission-id",
60
+ required=True,
61
+ type=str,
62
+ metavar="STRING",
63
+ help="S3 submission ID",
64
+ )
65
+
66
+ output_dir = click.option(
67
+ "--output-dir",
68
+ metavar="PATH",
69
+ type=DIR_RW_C,
70
+ required=True,
71
+ default=None,
72
+ help="Path to the target submission output directory",
73
+ )
74
+
75
+ output_json = click.option("--json", "output_json", is_flag=True, help="Output JSON for machine-readability.")
76
+
77
+ show_details = click.option("--details", "show_details", is_flag=True, help="Show more detailed output.")
78
+
79
+ force = click.option("--force/--no-force", help="Overwrite files and ignore cached results (dangerous!)")
@@ -0,0 +1,39 @@
1
+ """Constants for logging configuration, JSON schema validation, and other settings."""
2
+
3
+ # This will be overridden by the package that imports it
4
+ PACKAGE_ROOT = "grz_common"
5
+
6
+ LOGGING_FORMAT = "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
7
+ LOGGING_DATEFMT = "%Y-%m-%d %I:%M %p"
8
+ LOGGING_CONFIG = {
9
+ "version": 1,
10
+ "disable_existing_loggers": True,
11
+ "formatters": {
12
+ "standard": {
13
+ "format": LOGGING_FORMAT,
14
+ "datefmt": LOGGING_DATEFMT,
15
+ },
16
+ },
17
+ "handlers": {
18
+ "default": {
19
+ "level": "INFO",
20
+ "formatter": "standard",
21
+ "class": "logging.StreamHandler",
22
+ },
23
+ },
24
+ "loggers": {
25
+ "": { # root logger
26
+ "handlers": ["default"],
27
+ "level": "WARNING",
28
+ "propagate": False,
29
+ },
30
+ PACKAGE_ROOT: {"handlers": ["default"], "level": "INFO", "propagate": False},
31
+ "__main__": { # if __name__ == '__main__'
32
+ "handlers": ["default"],
33
+ "level": "DEBUG",
34
+ "propagate": False,
35
+ },
36
+ },
37
+ }
38
+
39
+ TQDM_SMOOTHING: float = 0.0001
@@ -0,0 +1,60 @@
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 logger_name. 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: Optional; the name of the logger to add the file handler to.
36
+ Default is PACKAGE_ROOT.
37
+ """
38
+ logger = logging.getLogger(logger_name)
39
+
40
+ if file_path is None:
41
+ default_log_dir = Path.home() / "logs"
42
+ default_log_dir.mkdir(parents=True, exist_ok=True)
43
+ file_path = default_log_dir / f"{logger_name}.log"
44
+ log.warning("No log file path provided, using default: %s", file_path)
45
+ else:
46
+ file_path = Path(file_path)
47
+
48
+ try:
49
+ fh = logging.FileHandler(file_path)
50
+ fh.setLevel(level.upper())
51
+ fh.setFormatter(logging.Formatter(LOGGING_FORMAT, LOGGING_DATEFMT))
52
+ logger.addHandler(fh)
53
+ log.info(
54
+ "File logger added for %s at %s with level %s.",
55
+ logger.name,
56
+ file_path,
57
+ level.upper(),
58
+ )
59
+ except Exception as e:
60
+ log.error("Failed to add file logger: %s", e)
@@ -0,0 +1,3 @@
1
+ """
2
+ Model classes for grz applications.
3
+ """
@@ -0,0 +1,59 @@
1
+ from os import PathLike
2
+ from pathlib import Path
3
+ from typing import Annotated, Self
4
+
5
+ from pydantic import AfterValidator, BaseModel, ConfigDict
6
+ from pydantic.types import PathType
7
+ from pydantic_settings import BaseSettings, SettingsConfigDict
8
+
9
+ FilePath = Annotated[Path, AfterValidator(lambda v: v.expanduser()), PathType("file")]
10
+
11
+
12
+ class IgnoringBaseModel(BaseModel):
13
+ model_config = ConfigDict(
14
+ extra="ignore",
15
+ validate_assignment=True,
16
+ use_enum_values=True,
17
+ )
18
+
19
+ def to_yaml(self, fd):
20
+ """Reads the configuration file and validates it against the schema."""
21
+ import yaml
22
+
23
+ yaml.dump(self.model_dump(mode="json", exclude_none=True, exclude_unset=True, exclude_defaults=True))
24
+
25
+ @classmethod
26
+ def from_path(cls, path: str | PathLike) -> Self:
27
+ """Reads the configuration file and validates it against the schema."""
28
+ import yaml
29
+
30
+ with open(path, encoding="utf-8") as f:
31
+ config = cls(**yaml.safe_load(f)) # noqa:
32
+
33
+ return config
34
+
35
+
36
+ class IgnoringBaseSettings(BaseSettings):
37
+ model_config = SettingsConfigDict(
38
+ extra="ignore",
39
+ validate_assignment=True,
40
+ use_enum_values=True,
41
+ env_nested_delimiter="__",
42
+ env_prefix="grz_",
43
+ )
44
+
45
+ def to_yaml(self, fd):
46
+ """Reads the configuration file and validates it against the schema."""
47
+ import yaml
48
+
49
+ yaml.dump(self.model_dump(mode="json", exclude_none=True, exclude_unset=True, exclude_defaults=True), fd)
50
+
51
+ @classmethod
52
+ def from_path(cls, path: str | PathLike) -> Self:
53
+ """Reads the configuration file and validates it against the schema."""
54
+ import yaml
55
+
56
+ with open(path, encoding="utf-8") as f:
57
+ config = cls(**yaml.safe_load(f)) # noqa:
58
+
59
+ return config
@@ -0,0 +1,45 @@
1
+ from typing import Self
2
+
3
+ from grz_common.models.base import FilePath, IgnoringBaseSettings
4
+ from pydantic import field_validator, model_validator
5
+
6
+
7
+ class KeyModel(IgnoringBaseSettings):
8
+ grz_public_key: str | None = None
9
+ """
10
+ The public key of the recipient (the associated GRZ).
11
+ """
12
+
13
+ grz_public_key_path: FilePath | None = None
14
+ """
15
+ Path to the crypt4gh public key of the recipient (the associated GRZ).
16
+ """
17
+
18
+ grz_private_key_path: FilePath | None = None
19
+ """
20
+ Path to the crypt4gh private key of the recipient (optional).
21
+ """
22
+
23
+ submitter_private_key_path: FilePath | None = None
24
+ """
25
+ Path to the submitter's private key (optional).
26
+ """
27
+
28
+ @field_validator("grz_public_key")
29
+ @classmethod
30
+ def check_grz_public_key(cls, v):
31
+ if v is not None and "BEGIN CRYPT4GH PUBLIC KEY" not in v and "END CRYPT4GH PUBLIC KEY" not in v:
32
+ raise ValueError("Invalid public key format")
33
+ return v
34
+
35
+ @model_validator(mode="after")
36
+ def validate_grz_public_key(self) -> Self:
37
+ if self.grz_public_key is None and self.grz_public_key_path is None:
38
+ raise ValueError("Either grz_public_key or grz_public_key_path must be set.")
39
+ if self.grz_public_key is not None and self.grz_public_key_path is not None:
40
+ raise ValueError("Only one of grz_public_key or grz_public_key_path must be set.")
41
+ return self
42
+
43
+
44
+ class KeyConfigModel(IgnoringBaseSettings):
45
+ keys: KeyModel
@@ -0,0 +1,79 @@
1
+ from pydantic import AnyHttpUrl, AnyUrl
2
+
3
+ from .base import IgnoringBaseModel, IgnoringBaseSettings
4
+
5
+
6
+ class S3Options(IgnoringBaseModel):
7
+ endpoint_url: AnyHttpUrl
8
+ """
9
+ The URL for the S3 service.
10
+ """
11
+
12
+ bucket: str
13
+ """
14
+ The name of the S3 bucket.
15
+ """
16
+
17
+ access_key: str | None = None
18
+ """
19
+ The access key for the S3 bucket.
20
+ If undefined, it is read from the AWS_ACCESS_KEY_ID environment variable.
21
+ """
22
+
23
+ secret: str | None = None
24
+ """
25
+ The secret key for the S3 bucket.
26
+ If undefined, it is read from the AWS_SECRET_ACCESS_KEY environment variable.
27
+ """
28
+
29
+ session_token: str | None = None
30
+ """
31
+ The session token for temporary credentials (optional).
32
+ """
33
+
34
+ region_name: str | None = None
35
+ """
36
+ The region name for the S3 bucket.
37
+ """
38
+
39
+ api_version: str | None = None
40
+ """
41
+ The S3 API version.
42
+ """
43
+
44
+ use_ssl: bool = True
45
+ """
46
+ Whether to use SSL for S3 operations.
47
+ """
48
+
49
+ proxy_url: AnyUrl | None = None
50
+ """
51
+ The proxy URL for S3 operations (optional).
52
+ """
53
+
54
+ request_checksum_calculation: str | None = None
55
+ """
56
+ Whether to calculate checksums for S3 request payloads (optional).
57
+ Valid values are:
58
+
59
+ * ``when_supported`` -- When set, a checksum will be calculated for
60
+ all request payloads of operations modeled with the ``httpChecksum``
61
+ trait where ``requestChecksumRequired`` is ``true`` or a
62
+ ``requestAlgorithmMember`` is modeled.
63
+
64
+ * ``when_required`` -- When set, a checksum will only be calculated
65
+ for request payloads of operations modeled with the ``httpChecksum``
66
+ trait where ``requestChecksumRequired`` is ``true`` or where a
67
+ ``requestAlgorithmMember`` is modeled and supplied.
68
+
69
+ Defaults to None.
70
+ """
71
+
72
+ multipart_chunksize: int = 256 * 1024**2
73
+ """
74
+ The size of the chunks to use for multipart uploads in bytes.
75
+ """
76
+
77
+
78
+ class S3ConfigModel(IgnoringBaseSettings):
79
+ s3: S3Options
@@ -0,0 +1,21 @@
1
+ """Progress tracking and logging functionality."""
2
+
3
+ from .progress_logging import FileProgressLogger
4
+ from .states import (
5
+ DecryptionState,
6
+ DownloadState,
7
+ EncryptionState,
8
+ State,
9
+ UploadState,
10
+ ValidationState,
11
+ )
12
+
13
+ __all__ = [
14
+ "DecryptionState",
15
+ "DownloadState",
16
+ "EncryptionState",
17
+ "FileProgressLogger",
18
+ "State",
19
+ "UploadState",
20
+ "ValidationState",
21
+ ]