Skip to content

Commit

Permalink
feat(cli): consistent path options (#105)
Browse files Browse the repository at this point in the history
* feat(cli): can omit object_id in modos remove

* feat(cli): allow s3 path in modos stream

* docs(readme): update endpoint options

* docs(cli): drop obsolete example
  • Loading branch information
cmdoret authored Aug 30, 2024
1 parent 6f2f1ff commit f7542c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ pip install git+https://github.com/sdsc-ordes/modos-api.git@main
The CLI is convenient for quickly managing modos (creation, edition, deletion) and quick inspections:

```sh
$ modos show -s3 https://s3.example.org --zarr ex-bucket/ex-modo
$ # remote example
$ modos --endpoint http://localhost show --zarr s3://ex-bucket/ex-modo
/
├── assay
│ └── assay1
Expand All @@ -75,6 +76,7 @@ $ modos show -s3 https://s3.example.org --zarr ex-bucket/ex-modo
└── sample
└── sample1

$ # local example
$ modos show --files data/ex
data/ex/reference1.fa.fai
data/ex/demo1.cram
Expand Down
19 changes: 7 additions & 12 deletions modos/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ def remove(
ctx: typer.Context,
object_path: OBJECT_PATH_ARG,
element_id: Annotated[
str,
Optional[str],
typer.Argument(
...,
help="The identifier within the modo. Use modos show to check it.",
help="The identifier within the modo. Use modos show to check it. Leave empty to remove the whole object.",
),
],
] = None,
force: Annotated[
bool,
typer.Option(
Expand All @@ -197,7 +197,7 @@ def remove(
):
"""Removes an element and its files from the modo."""
modo = MODO(object_path, endpoint=ctx.obj.endpoint)
if element_id == modo.path.name:
if (element_id is None) or (element_id == modo.path.name):
if force:
modo.remove_object()
else:
Expand Down Expand Up @@ -349,7 +349,7 @@ def stream(
str,
typer.Argument(
...,
help="The path to the file to stream . Use modos show --files to check it.",
help="The s3 path of the file to stream . Use modos show --files to check it.",
),
],
region: Annotated[
Expand All @@ -361,16 +361,11 @@ def stream(
),
] = None,
):
"""Stream genomic file from a remote modo into stdout.
Example:
modos -e http://modos.example.org stream my-bucket/ex-modo/demo1.cram
"""
"""Stream genomic file from a remote modo into stdout."""
_region = Region.from_ucsc(region) if region else None

# NOTE: bucket is not included in htsget paths
source = Path(*Path(file_path).parts[1:])
source = Path(*Path(file_path.removeprefix("s3://")).parts[1:])
endpoint = ctx.obj.endpoint

if not endpoint:
Expand Down

0 comments on commit f7542c2

Please sign in to comment.