Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the s3_upload module to run as script #24

Merged
merged 2 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ghga_datasteward_kit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

"""A utils package for GHGA data stewards."""

__version__ = "0.4.6"
__version__ = "0.4.7"
12 changes: 11 additions & 1 deletion ghga_datasteward_kit/s3_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import crypt4gh.keys # type: ignore
import crypt4gh.lib # type: ignore
import httpx
import typer
from hexkit.providers.s3 import S3Config, S3ObjectStorage # type: ignore
from nacl.bindings import crypto_aead_chacha20poly1305_ietf_encrypt
from pydantic import BaseSettings, Field, SecretStr, validator
Expand Down Expand Up @@ -612,11 +613,20 @@ async def async_main(input_path: Path, alias: str, config: Config):
metadata.serialize(output_path)


def main(input_path, alias: str, config_path: Path):
def main(
input_path: Path = typer.Option(..., help="Local path of the input file"),
alias: str = typer.Option(..., help="A human readable file alias"),
config_path: Path = typer.Option(..., help="Path to a config YAML."),
):
"""
Custom script to encrypt data using Crypt4GH and directly uploading it to S3
objectstorage.
"""

config = load_config_yaml(config_path, Config)
asyncio.run(async_main(input_path=input_path, alias=alias, config=config))


if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
typer.run(main)