Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ jobs:
- name: Verify package installation
run: |
echo "✅ Verifying package can be installed..."
uv pip install dist/*.whl
uv run python -c "import eoepca_client; print('Package installed successfully')"
WHEEL=$(ls -t dist/*.whl | head -1)
uv run --isolated --with "eoepca-client @ ${WHEEL}" python -c "import eoepca_client; print('Package installed successfully')"
uv run --isolated --with "eoepca-client @ ${WHEEL}" eoepca --help

- name: Upload build artifacts
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.15
rev: v0.15.22
hooks:
- id: ruff
args: [--fix]
Expand Down
128 changes: 113 additions & 15 deletions eoepca-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,143 @@ Client library and CLI for EOEPCA.

- Python 3.12 or higher

## Installation
## Quickstart

Install using `uv`:
Install with [uv](https://docs.astral.sh/uv/):

```bash
uv tool install eoepca-client
```

Or add to a project and use `uv run`:

```bash
uv add eoepca-client
uv run eoepca login
```

## Testing
Log in with your platform username and password:

```bash
uv run eoepca login --username USER --password PASS
```

From the repository root, install test dependencies and run tests:
Or interactively (prompts on a TTY):

```bash
cd eoepca-client
uv sync --extra test
uv run pytest
uv run eoepca login
```

## Development
Or via environment variables:

```bash
export EOEPCA_USERNAME=... EOEPCA_PASSWORD=...
uv run eoepca login
```

Device flow is used only when `EOEPCA_CLIENT_SECRET` is set (confidential clients).

Search STAC items:

```bash
eoepca stac search --collection <collection-id> --bbox -10,40,5,55 --limit 5
```

```bash
eoepca stac item add <collection-id> ./item.geojson
eoepca stac item rm <collection-id> <item-id>
```

Check who you are logged in as:

```bash
eoepca whoami
```

Use `--output json` on any command for machine-readable output.

## Platform discovery

`-p` / `--platform` accepts:

- a **named platform** from builtins or `~/.config/eoepca/config.toml` (e.g. `develop`)
- a **local API catalog** file (RFC 9727 linkset JSON)
- a **catalog URL** (`https://…/.well-known/api-catalog`, or a base URL that is completed with that path)
- a **domain** (fetches `https://<domain>/.well-known/api-catalog`)

```bash
eoepca stac collections -p ./api-catalog.json
eoepca login -p https://develop.eoepca.org/.well-known/api-catalog
eoepca whoami -p staging.example.org
```

The catalog supplies the OIDC issuer (`eoepca:default_client_id`, realm) and the STAC endpoint (preferring a `data` target with `eoepca:auth: oidc-write`). See [PR #16](https://github.com/EOEPCA/user-client/pull/16).

## Library usage

```python
from eoepca_client import Client

c = Client(platform="develop")
c.login()

# Read — returns a pre-configured pystac_client.Client
stac = c.eoapi.stac()
for col in stac.get_collections():
print(col.id, col.title)

search = stac.search(collections=["my-coll"], bbox=[-10, 40, 5, 55], limit=5)
for item in search.items():
print(item.id)

From the `eoepca-client` directory:
# Write — STAC Transactions helper
tx = c.eoapi.stac_transactions
created = tx.add_item("my-coll", "./item.geojson")
tx.delete_item("my-coll", created.id)
```

## Installation (development)

From the repository:

```bash
cd eoepca-client
uv sync --extra dev --extra test
```

Set up pre-commit hooks (config lives at the repository root):
Verify the CLI:

```bash
cd .. # repository root
uv run --project eoepca-client pre-commit install
uv run eoepca --help
```

## Testing

```bash
cd eoepca-client
uv sync --extra test
uv run pytest
```

Optional live test against develop (requires credentials and a writeable collection):

```bash
EOEPCA_E2E=1 \
EOEPCA_USERNAME=... \
EOEPCA_PASSWORD=... \
EOEPCA_COLLECTION=ws-... \
uv run pytest tests/test_e2e.py -v
```

Run pre-commit manually from the repository root:
## Development

Set up pre-commit hooks (config lives at the repository root):

```bash
uv run --project eoepca-client pre-commit run --all-files
cd .. # repository root
uv run --project eoepca-client pre-commit install
```

## License

This project is licensed under the Apache License 2.0 - see the [LICENSE](../LICENSE) file at the repository root.
This project is licensed under the Apache License 2.0 — see the [LICENSE](../LICENSE) file at the repository root.
14 changes: 2 additions & 12 deletions eoepca-client/eoepca_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,8 @@

from importlib.metadata import version as _version

from .logging import get_logger, logger, setup_logging
from .client import Client

__version__ = _version("eoepca-client")


__all__ = ["__version__", "version", "get_logger", "setup_logging", "logger"]


def version() -> None:
"""Print the current version."""
print(f"eoepca-client version: {__version__}")


if __name__ == "__main__":
version()
__all__ = ["Client", "__version__"]
Loading
Loading