Skip to content

Commit

Permalink
feat: Scaffold download entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
jjjermiah committed Dec 10, 2024
1 parent b2a0ef1 commit 1a0b295
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 27 additions & 1 deletion src/orcestradownloader/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import click
from click import Group, MultiCommand


from pathlib import Path
from orcestradownloader.logging_config import set_log_verbosity
from orcestradownloader.managers import REGISTRY, DatasetManager, UnifiedDataManager
from orcestradownloader.models import ICBSet, PharmacoSet, RadioSet, ToxicoSet, XevaSet
Expand Down Expand Up @@ -92,10 +92,36 @@ def _table(ctx, force: bool = False, verbose: int = 1, quiet: bool = False):
manager = UnifiedDataManager(force=force)
manager.print_one_table(name)

@ds_group.command(name='download')
@click.option('--overwrite', '-o', is_flag=True, help='Overwrite existing file, if it exists.', default=False, show_default=True)
@click.option('--filename', '-f', help='Filename to save the file as. Defaults to the name of the dataset', default=None, type=str, required=False)
@click.option('--directory', '-d', help='Directory to save the file to', default=Path.cwd(), type=click.Path(exists=True, file_okay=False, dir_okay=True, writable=True, path_type=Path), required=True)
@click.argument(
'name',
type=str,
required=True,
nargs=-1,
metavar='[NAME OF DATASET]'
)
@click.option('--force', is_flag=True, help='Force fetch new data from the API. Useful if the data has been updated on the API.', default=False, show_default=True)
@set_log_verbosity()
@click.pass_context
def _download(
ctx,
directory: Path,
force: bool = False,
verbose: int = 1,
quiet: bool = False,
filename: str | None = None,
overwrite: bool = False
):
"""Download a file for this dataset."""
click.echo(f'Downloading {name} to {directory}')
return ds_group
return None

def format_usage(self, ctx, formatter):
"""Custom string for the Usage section of the help page."""
formatter.write_usage(
"orcestra",
"[DATASET_TYPE] [SUBCOMMAND] [ARGS]..."
Expand Down

0 comments on commit 1a0b295

Please sign in to comment.