Opal Python 
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.
- Read the documentation.
- Have a bug or a question? Please create a GitHub issue.
- Continuous integration is on GitHub actions.
Usage
Install with:
pip install obiba-opal
Development
This project uses uv for dependency management and packaging.
Setup Development Environment
- Install uv:
See uv installation.
- Install dependencies:
uv sync
- Run tests:
uv run pytest
- 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!
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)"
Metadata
Release files for obiba-opal 6.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| obiba_opal-6.2.0.tar.gz | 138.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| obiba_opal-6.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 217.5 kB
Release files / obiba_opal-6.2.0.tar.gz
| Download URL | obiba_opal-6.2.0.tar.gz |
|---|---|
| Size | 138.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec429c60d4cff3fe7f9d09f410bcab1afc1d94da15a6c6590f2c25ee43398a86
|
|
BLAKE2b-256 checksum How to use checksums |
22de1214cbc57c5fc07aec38e0ee9ba47e54cf9ea0f4b91a8bd0ff661f123594
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","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}
|
Release files / obiba_opal-6.2.0-py3-none-any.whl
| Download URL | obiba_opal-6.2.0-py3-none-any.whl |
|---|---|
| Size | 78.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
722f5842d8f47944a8c480cf435bb407e36ec26bac4a3624722827cd0c995f7c
|
|
BLAKE2b-256 checksum How to use checksums |
e158a4dac9a0b25fde96bb7d2962953062fb94aeef839c3546de0c6f680cc6b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","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}
|