Skip to main content

Python SDK for TitanRdm Upload and Download APIs

Project description

TitanRDM SDK for Python

Python SDK for TitanRDM Upload and Download APIs.

Installation

pip install titan-rdm-sdk

For development:

pip install titan-rdm-sdk[dev]

Quick Start

Initialize Client

from titan_rdm_sdk import TitanRDMClient

client = TitanRDMClient(
    url="https://<tenant_subdomain>.titanrdm.com",
    client_id="your_client_id",
    client_secret="your_client_secret"
)

Download Data (Full Export)

download = client.get_download(
    branch_id=174,
    table_definition_key=50,
    pattern='full',
    correlation_code='daily-export-2025-01-22'
)

download.wait_until_ready(poll_interval=2.0, max_wait=300.0)
df = download.receive()
print(f"Downloaded {len(df)} rows")

Download Data (Incremental Export)

download = client.get_download(
    branch_id=174,
    table_definition_key=50,
    pattern='incremental',
    high_water_mark="2025-01-21T00:00:00Z",
    correlation_code='incremental-sync'
)

download.wait_until_ready()
df = download.receive()

Upload Data

import pandas as pd

# Create upload batch
upload = client.get_upload(
    branch_id=174,
    description='Customer data update',
    correlation_code='batch-001'
)

# Prepare data
df = pd.DataFrame({
    'customer_id': [1, 2, 3],
    'name': ['Alice', 'Bob', 'Charlie'],
    'email': ['alice@example.com', 'bob@example.com', 'charlie@example.com']
})

# Upload to specific table
table_upload = upload.get_table_upload(
    table_definition_key=456,
    import_mapping_key=123,
    pattern='full'
)
table_upload.send(df)

# Complete the import batch
upload.complete()

Error Handling

from titan_rdm_sdk import (
    TitanRDMClient,
    AuthenticationError,
    APIError,
    ExportFailedError,
    ValidationError
)

try:
    client = TitanRDMClient(url, client_id, client_secret)
    download = client.get_download(branch_id=174, table_definition_key=50)
    download.wait_until_ready()
    df = download.receive()

except AuthenticationError as e:
    print(f"Authentication failed: {e}")

except ValidationError as e:
    print(f"Invalid input: {e}")

except ExportFailedError as e:
    print(f"Export failed: {e}")

except APIError as e:
    print(f"API error (HTTP {e.status_code}): {e}")

Development

Setup

# Clone the repository
git clone https://github.com/dimodelo/titan-rdm-sdk-python.git
cd titan-rdm-sdk-python

# Install in development mode
pip install -e ".[dev]"

Running Tests

# Run all tests
pytest

# Run with verbose output
pytest -v

# Run with coverage report
pytest --cov=titan_rdm_sdk --cov-report=term-missing

# Run specific test file
pytest tests/test_client.py

# Run specific test class or function
pytest tests/test_client.py::TestClientInitialization
pytest tests/test_client.py::TestClientInitialization::test_successful_initialization

Building the Package

pip install build
python -m build

This creates distribution files in the dist/ directory that can be uploaded to PyPI.

Testing in Databricks

For comprehensive testing of the SDK in a Databricks environment, use the provided system test notebook:

Databricks System Tests

The databricks/databricks_system_tests/ directory contains a ready-to-use Databricks notebook that tests all major SDK functionality:

Features:

  • Authentication testing
  • Full upload/download workflows
  • Incremental operations
  • Error handling scenarios
  • Integration with both DBFS and Unity Catalog volumes

Setup:

  1. Upload the notebook to your Databricks workspace
  2. Configure secrets for API credentials
  3. Upload test data to DBFS or Unity Catalog volumes
  4. Run the tests using configurable widgets

Quick Start:

# In Databricks notebook
%pip install titan-rdm-sdk

# Import the system test functions
%run /path/to/databricks/databricks_system_tests.py

# Configure test parameters
dbutils.widgets.text("branch_id", "174")
dbutils.widgets.text("table_definition_key", "50")
dbutils.widgets.text("test_csv_path", "/test_data/customers.csv")

# Run all tests
run_all_tests()

For detailed setup instructions, see the databricks/databricks_README.md file.

License

MIT

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

titan_rdm_sdk-1.0.0.tar.gz (31.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

titan_rdm_sdk-1.0.0-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file titan_rdm_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: titan_rdm_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 31.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for titan_rdm_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fc3596e35bc739e4eb1f8a3d17e6c0f2ba7850a2af968b52ce7e6d023cb3b9df
MD5 ac5b6959bb748e00ae8ce728e008afae
BLAKE2b-256 f3a5d7912e6b6485d1aedcc09ec3cb24dc4262ccb1c4dfaa7c316d800aee593c

See more details on using hashes here.

File details

Details for the file titan_rdm_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: titan_rdm_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for titan_rdm_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 556ecc31718d6e54d48de76418874e378616c0d62f5204ad74e981f556e2852b
MD5 04bf78556ec30d423fb533c15e5b3586
BLAKE2b-256 c8c41b44b8d440f5d38ae6b7b7a0d8da79d0db93e3e4646f0a876128baf347b5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page