Onepanel SDK

Installation

Onepanel SDK is available as soon as you install Onepanel CLI

Note

SDK is pre-installed if you are using Onepanel Workspaces or Jobs.

Authentication

The recommended way to authenticate in Onepanel's SDK is to use an access token, you can create an access token and authenticate in the SDK as follows:

from onepanel.sdk import Client

# with username/access_token
client = Client(username='<username>', access_token='<access token>')

# or with email/access_token
client = Client(email='<email>', access_token='<access token>')

Example: create a job

Example

See the SDK notebook for a complete example

from onepanel.models import Job

from onepanel.sdk import Client

# login with email/access_token
client = Client(email='<email>', access_token='<access token>')

# create a job
job = Job()

job.name = '<job-name>'
job.project.uid = '<your-project-uid>'
job.command = '<command>'
job.machine_type.uid = '<machine-type-uid>'
job.environment.uid = '<environment-uid>'
job.volume_type.uid = '<volume-type-uid>'

# create a job by uploading code from current directory
job_uid = client.jobs.create(job)