Metadata-Version: 2.4
Name: agnue-push
Version: 0.1.4
Summary: SDK and CLI for pushing data to the AgNUE platform
Project-URL: Homepage, https://github.com/teknologisk-institut/AgNUE
Project-URL: Source, https://github.com/teknologisk-institut/AgNUE/tree/main/sdk/python
Project-URL: Issues, https://github.com/teknologisk-institut/AgNUE/issues
Requires-Python: >=3.10
Requires-Dist: boto3>=1.34
Requires-Dist: httpx>=0.28
Requires-Dist: tomli>=2.0; python_version < '3.11'
Description-Content-Type: text/markdown

# agnue-push

CLI and Python SDK for uploading sensor data to the [AgNUE](https://github.com/teknologisk-institut/AgNUE) platform.

## Installation

```bash
pip install agnue-push
```

## Configuration

When your site is approved, you receive an `agnue.toml` file by email. Place it in your working directory — the SDK picks it up automatically.

You can also configure via environment variables: `AGNUE_PLATFORM_URL`, `AGNUE_API_TOKEN`, and optionally `AGNUE_S3_*`.

## CLI

```bash
# Upload a single file
agnue upload data.csv --data-source DK-Foo-SOIL-01

# Upload a directory
agnue upload ./sensor-exports/ --data-source DK-Foo-SOIL-01

# Upload with glob, excluding backups
agnue upload "*.csv" --data-source DK-Foo-SOIL-01 --exclude "*_backup*"
```

The `--data-source` ID follows the format `CC-SSS-DOMAIN-SEQ` (e.g. `DK-Foo-SOIL-01`).

**Fallback behaviour:** if the platform API is unreachable after 3 retries, files are uploaded directly to S3, if configured.

## Python API

```python
from agnue_push import AgNUEClient

client = AgNUEClient.from_config()  # reads agnue.toml or env vars

# Upload a file — returns ingestion_id, or None if staged locally
ingestion_id = client.upload("data.csv", data_source_id="DK-Foo-SOIL-01")

# Check an earlier S3 upload
exists = client.verify_upload("raw/DK-Foo/data.csv")

# List all uploads for this site
keys = client.list_uploads()
```

Pass explicit config instead of a file:

```python
client = AgNUEClient.from_config(
    platform_url="https://api.example.com",
    api_token="st_tok-...",
)
```
