Rockset Python Client
The Rockset Python client (`rockset`) provides an SDK for interacting with the Rockset API, a real-time analytics database. It enables users to create and manage resources, execute queries, and handle data. However, as of June 2024, Rockset's public services were shut down following its acquisition by OpenAI, with its technology integrated into OpenAI's infrastructure. Consequently, this client library is no longer functional for public use and is preserved for archival purposes.
Common errors
-
ModuleNotFoundError: No module named 'rockset'
cause The `rockset` library is not installed in the current Python environment.fixRun `pip install rockset` to install the library. -
NameError: name 'Client' is not defined
cause Attempting to use the old client class name `Client` after upgrading to v1.0.0 or later, where it was renamed.fixChange `Client` to `RocksetClient`. Ensure you import it with `from rockset import RocksetClient`. -
rockset.ApiException: (401) Reason: Unauthorized
cause The provided API key is invalid, missing, or lacks the necessary permissions, or the service is no longer available.fixVerify that your `ROCKSET_API_KEY` is correct and has appropriate permissions. Given the service shutdown, this error is now expected. -
TypeError: __init__() got an unexpected keyword argument 'api_server'
cause Attempting to use the old `api_server` parameter for host configuration with `RocksetClient` (v1.0.0+).fixReplace `api_server` with `host`. Example: `RocksetClient(host=Regions.use1a1, api_key=...)`.
Warnings
- breaking Rockset's public cloud service was shut down in June 2024 following its acquisition by OpenAI. The Python client library is no longer functional for connecting to a live Rockset service.
- breaking Migration from v0 to v1 of the client library introduced breaking changes. The main client class was renamed from `Client` to `RocksetClient`, the `api_server` parameter for specifying the API location was changed to `host`, and the query builder was deprecated. Some endpoints and parameters were also renamed.
- gotcha Users may encounter SSL errors when using the client, potentially due to Python installation issues.
- gotcha When making requests, certain parameters often expect instances of `rockset.models` classes (e.g., `rockset.models.QueryRequestSql`). For brevity, you can often pass a dictionary instead of instantiating the model object directly.
Install
-
pip install rockset
Imports
- rockset
import rockset
- RocksetClient
from rockset import Client
from rockset import RocksetClient
- Regions
from rockset import Regions
- Configuration
from rockset import Configuration
Quickstart
import os
from rockset import RocksetClient, Regions, ApiException
# Rockset services were shut down in June 2024. This code is for archival/demonstration only.
# Ensure ROCKSET_API_KEY is set in your environment variables if attempting to run against a hypothetical Rockset instance.
api_key = os.environ.get('ROCKSET_API_KEY', 'YOUR_ROCKSET_API_KEY')
if api_key == 'YOUR_ROCKSET_API_KEY':
print("WARNING: ROCKSET_API_KEY environment variable not set. Using placeholder.")
try:
# Initialize the Rockset client
# The host parameter replaced 'api_server' in v1.0.0
rs = RocksetClient(host=Regions.use1a1, api_key=api_key)
# Example: List workspaces
print("Attempting to list workspaces...")
workspaces = rs.Workspaces.list_all()
print(f"Found {len(workspaces)} workspaces:")
for ws in workspaces:
print(f"- {ws.name}")
# Example: Create an API key (demonstration, real usage should handle existing keys)
# This operation will likely fail as the service is offline.
try:
new_api_key_name = "my-test-api-key"
print(f"\nAttempting to create API key: {new_api_key_name}...")
created_key = rs.APIKeys.create(name=new_api_key_name, role="member")
print(f"Successfully created API key: {created_key.name}")
except ApiException as e:
print(f"Could not create API key (expected due to service shutdown): {e}")
except ApiException as e:
print(f"An API error occurred: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")