Metadata-Version: 2.4
Name: parallelworks-client
Version: 7.12.2
Summary: Official Python SDK for Parallel Works ACTIVATE
Project-URL: Homepage, https://github.com/parallelworks/sdk
Project-URL: Documentation, https://parallelworks.com/docs
Project-URL: Repository, https://github.com/parallelworks/sdk
Project-URL: Issues, https://github.com/parallelworks/sdk/issues
Author-email: Parallel Works <support@parallelworks.com>
License-Expression: MIT
Keywords: activate,api,client,hpc,parallelworks,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: attrs>=21.3.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-dateutil>=2.8.0
Description-Content-Type: text/markdown

# parallelworks-client

Official Python client for the Parallel Works ACTIVATE platform API.

## Installation

```bash
pip install parallelworks-client
```

## Quick Start

The simplest way to create a client - just pass your credential:

```python
import os
from parallelworks_client import Client

# The platform host is automatically extracted from your credential
with Client.from_credential(os.environ["PW_API_KEY"]).sync() as client:
    response = client.get("/api/buckets")
    for bucket in response.json():
        print(f"Bucket: {bucket['name']}")
```

See the [examples](./examples) directory for complete runnable examples.

## Authentication

### Automatic Host Detection

API keys (`pwt_...`) and JWT tokens contain the platform host encoded within them. Use `from_credential` to automatically extract it:

```python
# API key - host decoded from first segment after pwt_
client = Client.from_credential("pwt_Y2xvdWQucGFyYWxsZWwud29ya3M.xxxxx")
# Connects to: https://cloud.parallel.works

# JWT token - host read from platform_host claim
client = Client.from_credential("eyJhbGci...")
# Connects to the host in the token's platform_host claim
```

### Explicit Host

If you prefer to specify the host explicitly:

```python
# API Key (Basic Auth) - best for long-running integrations
client = Client.with_api_key(
    "https://cloud.parallel.works",
    "pwt_..."
)

# JWT Token (Bearer) - best for scripts, expires in 24h
client = Client.with_token(
    "https://cloud.parallel.works",
    "eyJhbGci..."
)

# Auto-detect credential type
client = Client.with_credential(
    "https://cloud.parallel.works",
    os.environ["PW_CREDENTIAL"]
)
```

### Credential Helpers

```python
from parallelworks_client import is_api_key, is_token, extract_platform_host

is_api_key("pwt_abc.xyz")           # True
is_token("eyJ.abc.def")             # True
extract_platform_host("pwt_...")    # "cloud.parallel.works"
```

## Async Support

```python
import asyncio
from parallelworks_client import Client

async def main():
    async with Client.from_credential(os.environ["PW_API_KEY"]) as client:
        response = await client.get("/api/buckets")
        print(response.json())

asyncio.run(main())
```

## Documentation

For full API documentation, visit [https://parallelworks.com/docs](https://parallelworks.com/docs).

## License

MIT
