Metadata-Version: 2.4
Name: amdp-python-sdk
Version: 1.0.0
Summary: SDK wrapper for AMD Platform API services.
License-Expression: MIT
License-File: LICENSE.txt
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: <3.14,>=3.10
Requires-Dist: pydantic-settings~=2.12.0
Requires-Dist: pydantic~=2.11.10
Requires-Dist: python-dateutil>=2.8.2
Requires-Dist: requests~=2.32.5
Requires-Dist: responses~=0.25.8
Requires-Dist: typing-extensions>=4.7.1
Requires-Dist: urllib3<3.0.0,>=2.1.0
Description-Content-Type: text/markdown

# amdp-python-sdk
**Current version:** `0.1.0a1` 

[![GitHub release](https://img.shields.io/github/v/release/<OWNER>/<REPO>?include_prereleases)](https://github.com/cdcent/oamd-api-python-sdk/releases) [![PyPI - Version](https://img.shields.io/pypi/v/amdp-python-sdk.svg)](https://pypi.org/project/amdp-python-sdk)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/amdp-python-sdk.svg)](https://pypi.org/project/amdp-python-sdk)

-----

Python SDK for the AMD Platform API Services.

## Table of Contents

- [Installation](#installation)
- [Getting Started](#using-sdk)
- [Development Setup](#development-setup)
- [License](#license)
- [Regenerate the OpenAPI libraries](#regenerate-the-openapi-libraries)
- [Testing](#testing)
- [Build](#build)
- [Changelog](#changelog)

## Installation

```bash
pip install amdp-python-sdk
```

## Quick Start

```python
from amdp_python_sdk import AMDP

# Connect with explicit credentials
sdk = AMDP.connect(
    client_id="your-client-id",
    client_secret="your-secret",
    user_service_hostname="https://amdp.cdc.gov/user-service",
    workflow_service_hostname="https://amdp.cdc.gov/workflow-service",
    sample_service_hostname="https://amdp.cdc.gov/sample-service"
)

# Upload samples with intuitive chaining
result = (
    sdk.workspace("My Workspace")
       .project("My Project")
       .upload_sample_sheet("samples.csv")
)

print(f"Uploaded {len(result.samples)} samples")
```

**Alternatively**, set environment variables and connect without parameters:

```bash
export AMDP_CLIENT_ID="your-client-id"
export AMDP_CLIENT_SECRET="your-secret"
export AMDP_USER_SERVICE_HOSTNAME="https://amdp.cdc.gov/user-service"
export AMDP_WORKFLOW_SERVICE_HOSTNAME="https://amdp.cdc.gov/workflow-service"
export AMDP_SAMPLE_SERVICE_HOSTNAME="https://amdp.cdc.gov/sample-service"
```

```python
from amdp_python_sdk import AMDP

sdk = AMDP.connect()  # Reads credentials from environment
```

## Getting Started

See [using-sdk.md](./docs/using-sdk.md) and [usage_examples.py](./docs/usage_examples.py) for comprehensive usage information.

## Development Setup

1. Install Python 3.12 (minimum 3.10) in WSL
    ```bash
    sudo apt install python3.12 python-is-python3 -y
    ```
2. Install Hatch in WSL
    ```bash
    ## Install pipx first
    sudo apt install pipx -y 
    pipx install hatch
    ```
3. Install Python and Pylance extensions in VS Code 
4. In VS Code settings, select 'Extensions' on the left hand side, and then select 'Pylance'. Look for 'Python › Analysis: Type Checking Mode' and set the dropdown value to 'Strict'

5. Create and start Hatch virtual environment 
    ```bash
    # will install all specified dependencies from the toml
    # Note the path given for the source command
    hatch shell local
    ```
6. In VS Code, set the "Python: Select Interpreter" setting and select "Enter interpreter path...", and use the path noted from step 4.

7. (Optional) Download VS Code extensions for Black Formatter, isort, and Flake8.

### Running Hatch-Static-Analysis scripts
```bash
# list report of black and isort formatting
hatch run hatch-static-analysis format-check

# fix formatting with black and isort
hatch run hatch-static-analysis format-fix

# run flake8 linter script
hatch run hatch-static-analysis lint-check
```

### Re-creating Hatch virtual environment from scratch
At the project root, run:
```bash
hatch env remove <envname>
```

then run:
```bash
hatch env create <envname>
```

## Regenerate the OpenAPI libraries

If the API source code has been updated you can regenerate the openAPI based python libraries.

With the API services running locally, first navigate to this repository then run:
```bash
podman-compose up
```
Each library will be regenerated in the `./generated` directory.

### Installation in Hatch Environments

The generated packages (`oamd_sample_openApi`, `oamd_user_openApi`, `oamd_workflow_openApi`) are **automatically installed** when you use Hatch environments:

- **Regular environments** (local, dev, test, etc.): The packages are installed automatically via the `{root:uri}` dependencies in `pyproject.toml`
- **Test environments** (hatch-test): The packages are installed automatically via `post-install-commands` in `pyproject.toml`

No manual installation is required when working with Hatch environments.

### Manual Installation (Outside Hatch)

If you need to test the generated packages individually outside of Hatch environments, install them manually:
```bash
pip install -e generated/samples
pip install -e generated/users
pip install -e generated/workflow
```

## Testing

For instructions on using the **test_sdk_functions.py** script to test functions,
please see [using-test-sdk-script.md](./docs/using-test-sdk-script.md).


To run unit tests use the following hatch test command:

```bash
hatch test
```

## Build
To build use the hatch build command and the build files will be generated in ./dist.

```bash
hatch build
```

## Changelog

See [CHANGELOG.md](./CHANGELOG.md) for full details.

## License

`amdp-python-sdk` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
