Skip to main content

OBiBa/Opal python client.

Project description

Opal Python CI

This Python-based command line tool allows to access to a Opal server through its REST API. This is the perfect tool for automating tasks in Opal using shell scripts.

See also the Opal R Client which offers a comprehensive programming interface.

Usage

Install with:

pip install obiba-opal

Development

This project uses uv for dependency management and packaging.

Setup Development Environment

  1. Install uv:

See uv installation.

  1. Install dependencies:
uv sync
  1. Run tests:
uv run pytest
  1. Build the package:
uv build

Requirements

  • Python 3.10 or higher
  • uv (for development)

CLI

To get the options of the command line:

opal --help

This command will display which sub-commands are available. For each sub-command you can get the help message as well:

opal <subcommand> --help

The objective of having sub-command is to hide the complexity of applying some use cases to the Opal REST API. More sub-commands will be developed in the future.

API

Opal Python client can be easily extended by using the exposed classes. The classes *Command return an Opal task object, to be followed with the TaskService. The classes *Service perform immediate operations.

from obiba_opal import OpalClient, HTTPError, Formatter, ImportCSVCommand, TaskService, FileService, DictionaryService

# if 2-factor auth is enabled, user will be asked for the secret code
# Personal access token authentication is also supported (and recommended)
client = OpalClient.buildWithAuthentication(server='https://opal-demo.obiba.org', user='administrator', password='password')

try:
    # upload a local CSV data file into Opal file system
    fs = FileService(client)
    fs.upload_file('./data.csv', '/tmp')

    # import this CSV file into a project
    task = ImportCSVCommand(client).import_data('/tmp/data.csv', 'CNSIM')
    status = TaskService(client).wait_task(task['id'])
    
    # clean data file from Opal
    fs.delete_file('/tmp/data.csv')

    if status == 'SUCCEEDED':
        dico = DictionaryService(client)
        table = dico.get_table('CNSIM', 'data')
        # do something ...
        dico.delete_tables('CNSIM', ['data'])
    else:
        print('Import failed!')
        # do something ...
except HTTPError as e:
    Formatter.print_json(e.error, True)
finally:
    client.close()

Mailing list

Have a question? Ask on our mailing list!

obiba-users@googlegroups.com

http://groups.google.com/group/obiba-users

License

OBiBa software are open source and made available under the GPL3 licence. OBiBa software are free of charge.

OBiBa acknowledgments

If you are using OBiBa software, please cite our work in your code, websites, publications or reports.

"The work presented herein was made possible using the OBiBa suite (www.obiba.org), a software suite developed by Maelstrom Research (www.maelstrom-research.org)"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

obiba_opal-6.0.1.tar.gz (124.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

obiba_opal-6.0.1-py3-none-any.whl (73.5 kB view details)

Uploaded Python 3

File details

Details for the file obiba_opal-6.0.1.tar.gz.

File metadata

  • Download URL: obiba_opal-6.0.1.tar.gz
  • Upload date:
  • Size: 124.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for obiba_opal-6.0.1.tar.gz
Algorithm Hash digest
SHA256 bdd60cb7bf8e33be1b84765d45b095a93b81278e0f487571fd26229a08f211a3
MD5 ae8739fae4e4547fbef5794a93e36ca3
BLAKE2b-256 893a301c503119b29538e15bcf0bf1ea86fdeeb6d7f9eadf479109b7f058e8cf

See more details on using hashes here.

File details

Details for the file obiba_opal-6.0.1-py3-none-any.whl.

File metadata

  • Download URL: obiba_opal-6.0.1-py3-none-any.whl
  • Upload date:
  • Size: 73.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for obiba_opal-6.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a64dd6cc2df034caa55d219267e9ff09b6122f374803a31c2502ae4b30d0925
MD5 4a91ef16a01d039c95f43d8f47ee6b62
BLAKE2b-256 c686f10f727e432b4327086f57d16c267ac80469cf44e02d7dd2701f42e9e774

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page