Skip to content

Commit

Permalink
feat: Improve CLI help text and dataset naming conventions (#2)
Browse files Browse the repository at this point in the history
* feat: improve help + table naming

* enhancement: enhance CLI help text and add epilog for issue reporting

closes #1
  • Loading branch information
jjjermiah authored Dec 13, 2024
1 parent 44d2f59 commit 4ee9b57
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 39 deletions.
34 changes: 2 additions & 32 deletions pixi.lock

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

26 changes: 22 additions & 4 deletions src/orcestradownloader/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _table(ctx, force: bool = False, verbose: int = 1, quiet: bool = False, ds_n
type=str,
required=True,
nargs=-1,
metavar='[NAME OF DATASET]'
metavar='[ORCESTRA DATASET NAME]'
)
@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()
Expand Down Expand Up @@ -187,7 +187,17 @@ def format_options(self, ctx: Context, formatter: HelpFormatter) -> None:
self.format_commands(ctx, formatter)
super(MultiCommand, self).format_options(ctx, formatter)

@click.command(name='orcestra', cls=DatasetMultiCommand, registry=REGISTRY, context_settings=CONTEXT_SETTINGS, invoke_without_command=True)

################################################################################
# Main CLI
################################################################################

EPILOG = """
If you encounter any issues or have any questions, please raise an issue on the GitHub repository:
https://github.com/bhklab/orcestra-downloader
"""

@click.command(name='orcestra', cls=DatasetMultiCommand, registry=REGISTRY, context_settings=CONTEXT_SETTINGS, invoke_without_command=True, epilog=EPILOG)
@click.option('-r', '--refresh', is_flag=True, help='Fetch all datasets and hydrate the cache.', default=False, show_default=True)
@click.help_option("-h", "--help", help="Show this message and exit.")
@set_log_verbosity()
Expand All @@ -197,11 +207,19 @@ def cli(ctx, refresh: bool = False, verbose: int = 0, quiet: bool = False):
Interactive CLI for datasets on orcestra.ca
-------------------------------------------
Welcome to the Orcestra CLI!
This program provides an interface for the orcestra.ca API,
providing a convenient way to interact with the datasets available
on the platform.
\b
Each dataset currently supports the following subcommands:
\b
list: List all items in the dataset
table: Print a table of items in the dataset
download: Download a file for a dataset
download-all: Download all files for a dataset
\b
Example:
Expand All @@ -210,12 +228,12 @@ def cli(ctx, refresh: bool = False, verbose: int = 0, quiet: bool = False):
$ orcestra radiosets list
\b
print a table of all xevasets while refreshing the cache
print a table of all xevasets after refreshing the cache
$ orcestra xevasets table --force
\b
print a table of a specific dataset with more details
$ orcestra pharmacosets table 'GDSC_2020(v2-8.2)'
$ orcestra pharmacosets table GDSC_2020(v2-8.2)
To get help on a subcommand, use:
Expand Down
2 changes: 1 addition & 1 deletion src/orcestradownloader/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async def fetch_data(self, name: str, force: bool = False) -> None:
def print(self, title: str, row_generator: Callable) -> None:
"""Print datasets in a formatted table."""
printer = TablePrinter(
title, headers=['Name', 'Dataset Name', 'Date Created', 'Datatypes']
title, headers=['Orcestra Dataset Name', 'Original Dataset Name', 'Date Created', 'Datatypes']
)
printer.print_table(self.datasets, row_generator)

Expand Down
4 changes: 2 additions & 2 deletions src/orcestradownloader/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ def print_summary(self, title: str | None = None) -> None:
table.add_column('Field', style='bold cyan', no_wrap=True)
table.add_column('Value', style='magenta')

table.add_row('Name', self.name)
table.add_row('Orcestra Dataset Name', self.name)
table.add_row('DOI', self.doi)
table.add_row(
'Date Created',
self.date_created.isoformat() if self.date_created else 'N/A',
)
table.add_row('Download Link', self.download_link)
table.add_row('Dataset Name', self.dataset.name)
table.add_row('Original Dataset Name', self.dataset.name)
table.add_row('Dataset Version', self.dataset.version_info.version)
table.add_row(
'Dataset Type',
Expand Down

0 comments on commit 4ee9b57

Please sign in to comment.