Python SDK

The disco package lets you run jobs on the Dis.co platform from a Python program.

Using the SDK, you can create computing jobs, run them on Dis.co, and get their results to your local machine. It is possible to offload any kind of Python program to be run on Dis.co.

Installation

To install the dis.co Python SDK, run:

$ pip install disco

Example

import disco
import pathlib
disco.set_credentials('john@example.com', 'my_password', save_to_dot_file=True)
my_file_id = disco.upload_file('my_file.py', pathlib.Path('/home/bob/my_file.py'))
job = disco.Job.add(my_file_id)
job.start()
(task_result,) = job.get_results(block=True)
task_result.write_files('/home/bob/my_result')

The code above uploads the file /home/bob/my_file.py, runs it on dis.co cloud, waits for the job to finish, and writes the results to /home/bob/my_result.

When the job has been created, you can see it listed in list_jobs():

>>> import disco
>>> disco.list_jobs())
[{'id': '5d650d25179854000d72b8cc', 'archived': False, 'name': 'd08e3e029bfc412ebc316e21f1a7dae0', 'status': 'Done', 'taskStates': ['Success']}]

Those functions return an instance of Job, which gives access to many useful operations on a job.

Environment variables

The disco package supports the following environment variables:

  • DISCO_BASE_URL: base URL of the Dis.co server. Default: https://app.dis.co

  • DISCO_EMAIL: user's email for authenticating with the Dis.co server.

  • DISCO_PASSWORD: password for authenticating with the Dis.co server.