# TAO SDK Module

Python SDK for interacting with TAO (Train, Adapt, Optimize) REST API.

## Core Components

### `client.py` - TAO API Client
Main `TaoClient` class for API interactions:
- Authentication
- Workspace management
- Dataset operations
- Job creation and monitoring
- Model inference

### `schemas.py` - Request/Response Schemas
Dataclass-based request schemas for API v2:
- `WorkspaceReq`, `DatasetReq`, `ExperimentJobReq`
- Cloud-specific configurations
- Helper functions for creating requests

### `tao_core_compat.py` - TAO Core Compatibility Layer
**NEW**: Imports enums from tao-core without triggering Marshmallow issues:
- Uses AST parsing to extract `CloudPullTypesEnum` from tao-core
- Provides automatic synchronization with tao-core definitions
- Falls back to local definitions if tao-core is inaccessible

**How it works:**
1. Locates tao-core installation using `pip show` (no imports)
2. Parses `schemas.py` with Python AST (avoids initialization)
3. Dynamically creates enum from extracted values

**Benefits:**
- ✅ No segmentation faults
- ✅ Automatic sync with tao-core
- ✅ No manual maintenance required
- ✅ Falls back gracefully if tao-core missing

### `constants.py` - HTTP Constants
Status codes and other constants.

### `exceptions.py` - Custom Exceptions
- `TaoError` - Base exception
- `TaoAPIError` - API errors
- `TaoAuthenticationError` - Auth failures
- `TaoNotFoundError` - 404 errors
- `TaoValidationError` - Validation errors

## Usage

```python
from tao_sdk import TaoClient

# Create client
client = TaoClient(base_url="https://api.example.com")

# Authenticate
client.login(ngc_key="...", ngc_org_name="...")

# Create workspace
workspace_id = client.create_workspace(
    name="my-workspace",
    cloud_type="aws",
    cloud_specific_details={...}
)

# Create dataset
dataset_id = client.create_dataset(
    dataset_type="image_classification",
    dataset_format="classification_pyt",
    name="my-dataset"
)

# Create job
job_id = client.create_job(
    kind="experiment",
    name="train-job",
    network_arch="classification_pyt",
    action="train",
    ...
)
```

## Synchronization with TAO Core

The SDK automatically imports `CloudPullTypesEnum` from tao-core:

```python
from tao_sdk.schemas import CloudPullTypesEnum, get_cloud_types

# All cloud types from tao-core
cloud_types = get_cloud_types()
# ['aws', 'azure', 'seaweedfs', 'huggingface', 'self_hosted', 'lepton', 'slurm']
```

## Development

Run tests:
```bash
pytest tests/tao_sdk/
```
