Official Python SDK for the Ocular AI Foundry Platform
Project description
Ocular AI Python SDK
Official Python SDK for interacting with the Ocular AI Platform.
Installation
pip install ocular
Quick Start
from ocular import Ocular
# Initialize the SDK with your API key
ocular = Ocular(api_key="your_api_key_here")
# Access a workspace
workspace = ocular.workspace("your_workspace_id")
# Get a project from the workspace
project = workspace.project("your_project_id")
# Get a version from the project
version = project.version("your_version_id")
# Get an export from the version
export = version.export("your_export_id")
# Download the export dataset
dataset_path = export.download()
print(f"Downloaded export to: {dataset_path}")
Configuration
The SDK can be configured using the following parameters:
ocular = Ocular(
api_key="your_api_key", # Required unless OCULAR_API_KEY env var is set
api_url="https://api.ocular.ai/v1", # Optional custom API URL
timeout=30, # Request timeout in seconds
max_retries=3, # Maximum number of retries for failed requests
backoff_factor=0.5, # Backoff factor for retries
debug=False, # Enable debug logging
)
You can also configure the SDK using environment variables:
OCULAR_API_KEY: Your Ocular API keyOCULAR_API_URL: The base URL for the Ocular APIOCULAR_TIMEOUT: Default request timeout in secondsOCULAR_MAX_RETRIES: Maximum number of retries for failed requestsOCULAR_BACKOFF_FACTOR: Backoff factor for retriesOCULAR_DEBUG: Enable debug mode (set to "true", "1", or "yes")OCULAR_LOG_LEVEL: Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
Error Handling
The SDK uses a structured error hierarchy for different types of errors:
from ocular.utils.errors import (
OcularError, # Base exception for all errors
AuthenticationError, # Authentication issues
ValidationError, # Invalid parameters
ResourceNotFoundError, # Resource not found
RateLimitError, # API rate limits exceeded
ServerError, # Server-side errors
NetworkError, # Network connectivity issues
TimeoutError, # Request timed out
)
try:
workspace = ocular.workspace("invalid_id")
except ResourceNotFoundError as e:
print(f"Workspace not found: {e}")
except AuthenticationError as e:
print(f"Authentication failed: {e}")
except OcularError as e:
print(f"An error occurred: {e}")
Logging
The SDK uses Python's standard logging library. You can configure logging using:
from ocular.utils.logging import setup_logging
# Setup logging with custom settings
logger = setup_logging(
level="DEBUG",
log_file="ocular.log", # Optional file to log to
)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ocular_ai-0.0.4.tar.gz.
File metadata
- Download URL: ocular_ai-0.0.4.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6576b8589ecc2aa66f96621a249502f96a78076f16767fa27a58eeedc9407288
|
|
| MD5 |
62ca15cf7a45167e4ed470758e0c16b7
|
|
| BLAKE2b-256 |
cb8467b6ad1e7e5fd898169c58c63387b00df93be0e2e92c2bf262fd94a5177b
|
Provenance
The following attestation bundles were made for ocular_ai-0.0.4.tar.gz:
Publisher:
publish.yml on OcularEngineering/ocular-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ocular_ai-0.0.4.tar.gz -
Subject digest:
6576b8589ecc2aa66f96621a249502f96a78076f16767fa27a58eeedc9407288 - Sigstore transparency entry: 183969377
- Sigstore integration time:
-
Permalink:
OcularEngineering/ocular-python-sdk@4abe4238a97c4a5ff4efe18aa611621c339f24d9 -
Branch / Tag:
refs/tags/0.0.4 - Owner: https://github.com/OcularEngineering
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4abe4238a97c4a5ff4efe18aa611621c339f24d9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ocular_ai-0.0.4-py3-none-any.whl.
File metadata
- Download URL: ocular_ai-0.0.4-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0842dc049c99501bf49e0020417c6074642dde49c6e207cc29966d932ae38e9b
|
|
| MD5 |
5ede3d4cb7fa2bef6314927dba939b2a
|
|
| BLAKE2b-256 |
a31345bd5ecf017af114538554406c4e8df73fdd657149c310c39f3a7e46e2ec
|
Provenance
The following attestation bundles were made for ocular_ai-0.0.4-py3-none-any.whl:
Publisher:
publish.yml on OcularEngineering/ocular-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ocular_ai-0.0.4-py3-none-any.whl -
Subject digest:
0842dc049c99501bf49e0020417c6074642dde49c6e207cc29966d932ae38e9b - Sigstore transparency entry: 183969378
- Sigstore integration time:
-
Permalink:
OcularEngineering/ocular-python-sdk@4abe4238a97c4a5ff4efe18aa611621c339f24d9 -
Branch / Tag:
refs/tags/0.0.4 - Owner: https://github.com/OcularEngineering
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4abe4238a97c4a5ff4efe18aa611621c339f24d9 -
Trigger Event:
push
-
Statement type: