Quick Start
Installing Orion Client
First generate a Python 3 environment (here, myvirtualenv
) with Anaconda and activate it.
Then install Orion Platform from private PyPI server.
(myvirtualenv) > pip install openeye-orionplatform
Below are examples of how to quickly get started using Orion Client.
Authenticating with Orion
To get started you will need to use the command line interface to configure an Orion profile
(myvirtualenv) > ocli --profile=default config profile
Orion Url, ex: https://orion.eyesopen.us: <orion_url>
Orion Username: <orion_username>
Orion password: <password>
Note
The –profile flag will default to default, you can use it to define multiple profiles.
By default, profile configuration will prompt you for a password. However, you can also configure a profile using a token retrieved from the UI
(myvirtualenv) > ocli --profile=default config profile --with-token
Orion Url, ex: https://orion.eyesopen.us: <orion_url>
Orion Username: <orion_username>
Orion token: <orion_token>
To see the current settings that your profile contains you can run
(myvirtualenv) > ocli --profile=default config info
You can also list the different profiles that you have locally.
(myvirtualenv) > ocli config list
Interacting with Orion
The majority of the interaction that will be made with the Orion API is done through an OrionSession, which will provided you with the basic CRUD (Create, Read, Update, Delete) interface for Orion resources.
The example below demonstrates how to interact with resources using a session.
#!/usr/bin/env python3
from orionclient.types import Dataset
from orionclient.session import APISession
# APISession uses the default profile, or the profile name defined in
# the ORION_PROFILE environment variable.
session = APISession
# List a specific type of resource
for resource in session.list_resources(Dataset):
print(resource)
# Get a specific resource by specifying an id
resource = session.get_resource(Dataset, 814)
# Refresh the state of the local object from the Orion API
session.refresh_resource(resource)
# Delete a resource
session.delete_resource(resource)
Download code