This is the client library for making requests to the GA4GH DRS compatible services. It provides a simple way to interact with a GA4GH DRS server and specifically DRS running on Indexd servers.
pip install drsclient
Install poetry with:
pip install poetry
Create a virtual environment:
poetry shell
Install all the dependencies:
poetry install
To start, initialize the drsclient. There are only two fields required to initialize the client:
baseurl(required): url of the server we're trying to connect with.auth(optional): auth info to access object bytes or POST/DELETE bundles in Gen3 DRS servers.token(optional): access token to access object bytes or POST/DELETE bundles in Gen3 DRS servers. If using bothauthandtokenthenauthtakes priority.
from drsclient.client import DrsClient
client = DrsClient(baseurl="somedrsserver.io", auth=(username, password))
# OR
client = DrsClient(baseurl="somedrsserver.io", token="some_token")client.create(
bundles=["object1", "bundle1", ...], # required list of bundles and objects to bundle
name="bundle_name", # optional
guid="bundleA", # optional
size=500, # optional
checksums=[{"checksum":"somehash1234", "type":"md5"}], # optional
description="description". # optional
version="abc123", # optional
aliases=["A", "B"] #optional
)loop = asyncio.get_event_loop()
loop.run_until_complete(client.async_create(
bundles=["object1", "bundle1", ...], # required list of bundles and objects to bundle
name="bundle_name", # optional
guid="bundleA", # optional
size=500, # optional
checksums=[{"checksum":"somehash1234", "type":"md5"}], # optional
description="description". # optional
version="abc123", # optional
aliases=["A", "B"] #optional
))client.get(guid="object1")
client.get(guid="bundle1", expand=True) # expand parameter for bundle expansionloop = asyncio.get_event_loop()
loop.run_until_complete(client.get(guid="object1"))
loop.run_until_complete(client.get(guid="bundle1", expand=True)) # expand parameter for bundle expansionclient.get_all()loop = asyncio.get_event_loop()
loop.run_until_complete(client.async_get_all())client.download(guid="object1", protocol="s3") # protocol parameter to specify cloud storage typeloop = asyncio.get_event_loop()
loop.run_until_complete(client.async_download(guid="object1", protocol="s3")) # protocol parameter to specify cloud storage typeclient.delete(guid="bundle")loop = asyncio.get_event_loop()
loop.run_until_complete(client.async_delete(guid="bundle"))