From 4ee9b57649a9f53f7cbe5dbf2e9b1777f691c893 Mon Sep 17 00:00:00 2001 From: Jermiah Joseph <44614774+jjjermiah@users.noreply.github.com> Date: Fri, 13 Dec 2024 10:42:40 -0500 Subject: [PATCH] feat: Improve CLI help text and dataset naming conventions (#2) * feat: improve help + table naming * enhancement: enhance CLI help text and add epilog for issue reporting closes #1 --- pixi.lock | 34 ++------------------------- src/orcestradownloader/cli/cli.py | 26 ++++++++++++++++---- src/orcestradownloader/managers.py | 2 +- src/orcestradownloader/models/base.py | 4 ++-- 4 files changed, 27 insertions(+), 39 deletions(-) diff --git a/pixi.lock b/pixi.lock index 7b0cec5..bc06bfe 100644 --- a/pixi.lock +++ b/pixi.lock @@ -4590,8 +4590,6 @@ packages: depends: - __glibc >=2.17,<3.0.a0 - libgcc-ng >=12 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: [] @@ -4602,8 +4600,6 @@ packages: md5: fb72a2ef514c2df4ba035187945a6dcf depends: - __osx >=10.13 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: [] @@ -4614,8 +4610,6 @@ packages: md5: 4831302cd6badbdb87c0334163fb7d68 depends: - __osx >=11.0 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: [] @@ -5458,8 +5452,6 @@ packages: depends: - __glibc >=2.17,<3.0.a0 - libgcc >=13 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: [] @@ -5470,8 +5462,6 @@ packages: md5: ec36c2438046ca8d2b4368d62dd5c38c depends: - __osx >=11.0 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: [] @@ -5482,8 +5472,6 @@ packages: md5: 4bc348e3a1a74d20a3f9beb866d75e0a depends: - __osx >=11.0 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: [] @@ -5498,8 +5486,6 @@ packages: - libstdcxx-ng >=12 - libuv >=1.46.0,<2.0a0 - openssl >=3.1.4,<4.0a0 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: [] @@ -5512,8 +5498,6 @@ packages: - libcxx >=16 - libuv >=1.48.0,<2.0a0 - openssl >=3.2.1,<4.0a0 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: [] @@ -5526,8 +5510,6 @@ packages: - libcxx >=16 - libuv >=1.48.0,<2.0a0 - openssl >=3.2.1,<4.0a0 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: [] @@ -6240,8 +6222,8 @@ packages: timestamp: 1731379715927 - pypi: . name: orcestra-downloader - version: 0.9.0 - sha256: 122339276453de3f552078445f87fc54214796400a4f89902134e8b851875a96 + version: 0.10.0 + sha256: 82d77cacd72b3aec93e2e7db9a0bf57ac942d23990970378f55d39e79e875804 requires_dist: - rich - aiohttp>=3.11.4 @@ -8393,8 +8375,6 @@ packages: - libwebsockets >=4.3.3,<4.4.0a0 - libzlib >=1.2.13,<2.0.0a0 - openssl >=3.2.1,<4.0a0 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: [] @@ -8410,8 +8390,6 @@ packages: - libwebsockets >=4.3.3,<4.4.0a0 - libzlib >=1.2.13,<2.0.0a0 - openssl >=3.2.1,<4.0a0 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: [] @@ -8427,8 +8405,6 @@ packages: - libwebsockets >=4.3.3,<4.4.0a0 - libzlib >=1.2.13,<2.0.0a0 - openssl >=3.2.1,<4.0a0 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: [] @@ -8622,8 +8598,6 @@ packages: - conda: https://conda.anaconda.org/conda-forge/linux-64/vhs-0.7.2-ha770c72_0.conda sha256: 1e24c28aa0c73b4133bc55f5cbcc6cf35730361beb48ae3b19e086cf381e3fee md5: c5a1882b6bd21bc00efedd9aa7dd56a7 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: [] @@ -8634,8 +8608,6 @@ packages: md5: f9c8abf97e5ffb91de6df05e6f7e8035 constrains: - __osx>=10.12 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: [] @@ -8644,8 +8616,6 @@ packages: - conda: https://conda.anaconda.org/conda-forge/osx-arm64/vhs-0.7.2-hce30654_0.conda sha256: 309981f7b9b66e4308e64ae698b65302e26b28a1e7d912e6db6fc400b400a140 md5: bd079d19fb232578ed65369f42d6175d - arch: arm64 - platform: osx license: MIT license_family: MIT purls: [] diff --git a/src/orcestradownloader/cli/cli.py b/src/orcestradownloader/cli/cli.py index 91e43cc..9a46321 100644 --- a/src/orcestradownloader/cli/cli.py +++ b/src/orcestradownloader/cli/cli.py @@ -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() @@ -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() @@ -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: @@ -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: diff --git a/src/orcestradownloader/managers.py b/src/orcestradownloader/managers.py index 08458b7..35fde8a 100644 --- a/src/orcestradownloader/managers.py +++ b/src/orcestradownloader/managers.py @@ -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) diff --git a/src/orcestradownloader/models/base.py b/src/orcestradownloader/models/base.py index 720dcad..a0c3b27 100644 --- a/src/orcestradownloader/models/base.py +++ b/src/orcestradownloader/models/base.py @@ -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',