Closed cmdoret closed 3 months ago
TODO:
s3://
scheme is specified (otherwise localobject_path
in cli help, mentioning the format of remote pathsAdded this based on our discussion:
s3://
for remote paths
modos.storage.S3Storage
to support thisWith these changes, the examples above become:
CLI:
$ modos --version
modos 0.1.0
# create remote object on the s3 provided by the modos server at http://localhost
$ modos --endpoint http://localhost create s3://bucket/object
# read endpoint from env variable to avoid repetition
$ export MODOS_ENDPOINT='http://localhost'
$ modos create s3://bucket/object2
$ modos show s3://bucket/object2
$ modos delete s3://bucket/object2
# we can operate on local objects when MODOS_ENDPOINT is set!
$ modos create data/object2
API:
>>> from modos.api import MODO
>>> MODO('s3://bucket/object2', endpoint='http://localhost')
# This is also possible, e.g. user has an s3 server, but no modos server
>>> nostream = MODO('s3://bucket/ex-nostream', services={'s3': 'http://s3.example.org'})
>>> nostream.stream_genomics('demo1.cram')
ValueError: No htsget endpoint provided
Objective:
Allows users to always specify the same modos server endpoint. Underlying htsget/s3 endpoints are auto-detected internally by querying the modos server.
For testing / advanced usage, a
services
option is still exposed in the API to bypass this and explicitely provide service endpoints.Notes
s3_endpoint
option, this PR removes it in favor of a top-levelendpoint
flag that is inherited by all commands (through typer.Context).endpoint
option can also read from the environment variableMODOS_ENDPOINT
.pydantic.HttpUrl
was used in some places for more explicit type hints, this PR adds it throughout the package and decorates functions with@validate_call
, to validate url params at runtime.pyproject.toml
throughmodos.__version__
and in the cli throughmodos --version
using a typer callback.Limitations
pydantic.validate_call
) and dataclases (by replacingdataclasses.dataclass
withpydantic.dataclasses.dataclass
), but not on normal classes.Questions should we use a more explicit mechanism for remote/local paths to avoid confusion? (e.g.
--local
flag or explicitely requirings3://
paths for remote objects.). Should this be in this, or a separate PR?Examples
CLI:
API: