Skip to main content

The Agora Connector for Python

Project description

gtagora-connector Build Status

gtagora-connector is a python library to access GyroTools' Agora system.

Installation

Use the package manager pip to install gtagora-connector.

pip install gtagora-connector

Currently gtagora-connector supports python 3.6 and 3.7.

Basic usage

from gtagora import Agora
from gtagora.models.dataset import DatasetType

agora = Agora.create('https://your.agora.domain.com', user='test', password='test')

root_folder = agora.get_folders()
subfolders = root_folder.get_folders() 
for s in subfolders:
    print(f' - {s.name}')

new_folder = root_folder.get_or_create_folder('New Folder')

exam = agora.get_exam_list(filters={'name': 'Wrist'})[0]
for s in exam.get_series():
    print(f'Series: {s.name}')

    for dataset in s.get_datasets(filters={'type': DatasetType.PHILIPS_RAW}):
        for datafile in dataset.get_datafiles():
            print(f'{datafile.original_filename}')

agora.import_data('/path/to/directroy', new_folder)

Exmaples

Create an Agora instanace

from gtagora import Agora

agora = Agora.create('https://your.agora.domain.com', user='test', password='test')

Because it's not recommended to ever write down your password in plain text the API is a better alternative. Actiavte the API Key in your Agora profile. The API key is just a random UUID and it can withdrawn or recreated easily.

from gtagora import Agora

agora = Agora.create('https://your.agora.domain.com', api_key='<YOUR_API_KEY>')

Working with folders

Get the root folder of the current user:

root_folder = agora.get_root_folder()
print(f"Root folder ID: {root_folder.id}")

Get a folder by its ID

folder = agora.get_folder(45)
print(f"Folder with ID {folder.name}")

Get sub folders

subfolders = folder.get_folders()
for f in subfolders:
    print(f" - {f.name}")

Create a new folder in the root folder (the new folder object is returned)

new_folder = root_folder.create_folder('TestFolder')
print(f"New folder ID: {new_folder.id}")

Delete a folder. Delete a folder is recursive. It deletes all items. The delete operation does not follow links.

folder.delete()

Get all items of a folder. An item could be a exam, series or a dataset

items = folder.get_items()
for item in items:
    print(f" - {item}")

Get all exams of a folder. Use the recursive parameter to get all exams

exams = folder.get_exams(recursive=False)
for exam in exams:
    print(f" - {exam}")

Working with Agora objects

Get the list of exams

exams = agora.get_exam_list()

Get an exam by ID

exam = agora.get_exam(12)

Link the first Exam to the a folder

exam_item = exam.link_to_folder(folder.id)

Delete the link of an exam (doesn't delete the Exam itself)

exam_item.delete()

Download data

Download all data from a folder

from pathlib import Path

target = Path("c:/temp")
downloaded_files = folder.download(target, recursive=False)
for f in downloaded_files:
    print(str(f))

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

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

gtagora-connector-0.0.8.tar.gz (16.5 kB view hashes)

Uploaded Source

Built Distribution

gtagora_connector-0.0.8-py3-none-any.whl (25.1 kB view hashes)

Uploaded Python 3

Supported by

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