Skip to content
uc-cdisPublic

About

This is the client library for making requests to the GA4GH DRS compatible services and returning an Indexd compatible document.

Resources

Stars

1 star

Watchers

15 watching

Forks

Repository files navigation

drsclient

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.

Installation

From PyPi:

pip install drsclient

From source code:

Install poetry with:

pip install poetry

Create a virtual environment:

poetry shell

Install all the dependencies:

poetry install

Usage

Initialization

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 both auth and token then auth takes priority.
from drsclient.client import DrsClient

client = DrsClient(baseurl="somedrsserver.io", auth=(username, password))
# OR
client = DrsClient(baseurl="somedrsserver.io", token="some_token")

Create a bundle

Method: create

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
)

Method: async_create

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
))

Get DRS object

Method: get

client.get(guid="object1")
client.get(guid="bundle1", expand=True) # expand parameter for bundle expansion

Method: async_get

loop = 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 expansion

Get all objects

Method: get_all

client.get_all()

Method: async_get_all

loop = asyncio.get_event_loop()

loop.run_until_complete(client.async_get_all())

Download object bytes

Method: download

client.download(guid="object1", protocol="s3") # protocol parameter to specify cloud storage type

Method: async_download

loop = asyncio.get_event_loop()

loop.run_until_complete(client.async_download(guid="object1", protocol="s3")) # protocol parameter to specify cloud storage type

Delete bundles

Method: delete

client.delete(guid="bundle")

Method: async_delete

loop = asyncio.get_event_loop()

loop.run_until_complete(client.async_delete(guid="bundle"))

About

This is the client library for making requests to the GA4GH DRS compatible services and returning an Indexd compatible document.

Resources

Stars

1 star

Watchers

15 watching

Forks

Releases

Packages

Used by

Contributors

Languages