Python client
The Python client library for Orvanta provides a convenient way to interact with the Orvanta platform using Python. This client provides a set of functions and utilities to access Orvanta resources and perform various operations.
Installation
Section titled “Installation”To use the Python client library, you need to install the orvanta package via pip:
pip install orvantaThe Python client provides several functions that you can use to interact with the Orvanta platform. Here’s an example of how to use the client to get a resource from Orvanta:
import orvanta
def main(): # Get a resource db_config = orvanta.get_resource('u/user/db_config') # Get a variable api_key = orvanta.get_variable('u/user/api_key') # Run a script asynchronously job_id = orvanta.run_script_by_path_async('f/scripts/process_data', args={'input': 'value'}) # Run a script synchronously and get result result = orvanta.run_script_by_path('f/scripts/calculate', args={'x': 10, 'y': 20})Core functions
Section titled “Core functions”The client provides both module-level convenience functions and an Orvanta class for advanced usage.
Module-level functions
Section titled “Module-level functions”get_resource(path)- Get a resource from Orvantaget_variable(path)- Get a variable valueset_variable(path, value)- Set a variable valuerun_script_by_path(path, args)- Run a script synchronously by pathrun_script_by_hash(hash_, args)- Run a script synchronously by hashrun_script_by_path_async(path, args)- Run a script asynchronously by pathrun_flow_async(path, args)- Run a flow asynchronouslyget_result(job_id)- Get the result of a completed jobget_state()- Get the script’s stateset_state(value)- Set the script’s state
Orvanta class
Section titled “Orvanta class”For advanced usage, you can instantiate the Orvanta class directly:
from orvanta import Orvanta
client = Orvanta( base_url='http://localhost:8000', token='your_token', workspace='your_workspace')
# Use client methodsresult = client.get_resource('u/user/resource')S3 integration
Section titled “S3 integration”The client includes helpers for working with S3-compatible storage:
import orvantafrom orvanta import S3Object
# Load a file from S3s3_obj = S3Object(s3='/path/to/file.txt')content = orvanta.load_s3_file(s3_obj)
# Write a file to S3file_content = b'Hello Orvanta!'orvanta.write_s3_file(s3_obj, file_content)