er-smart-sync 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- er_smart_sync-0.2.0/.github/workflows/docs.yml +53 -0
- er_smart_sync-0.2.0/.github/workflows/release.yml +87 -0
- er_smart_sync-0.2.0/.gitignore +31 -0
- er_smart_sync-0.2.0/.python-version +1 -0
- er_smart_sync-0.2.0/.vscode/launch.json +55 -0
- er_smart_sync-0.2.0/.vscode/settings.json +16 -0
- er_smart_sync-0.2.0/AGENTS.md +62 -0
- er_smart_sync-0.2.0/CLAUDE.md +62 -0
- er_smart_sync-0.2.0/LICENSE +200 -0
- er_smart_sync-0.2.0/PKG-INFO +85 -0
- er_smart_sync-0.2.0/README.md +54 -0
- er_smart_sync-0.2.0/USAGE.md +410 -0
- er_smart_sync-0.2.0/docs/changelog.md +7 -0
- er_smart_sync-0.2.0/docs/cli-reference/choices.md +67 -0
- er_smart_sync-0.2.0/docs/cli-reference/config-template.md +41 -0
- er_smart_sync-0.2.0/docs/cli-reference/datamodel.md +100 -0
- er_smart_sync-0.2.0/docs/cli-reference/events.md +7 -0
- er_smart_sync-0.2.0/docs/cli-reference/inspect-datamodel.md +64 -0
- er_smart_sync-0.2.0/docs/cli-reference/list-cas.md +7 -0
- er_smart_sync-0.2.0/docs/cli-reference/overview.md +62 -0
- er_smart_sync-0.2.0/docs/cli-reference/patrols.md +7 -0
- er_smart_sync-0.2.0/docs/cli-reference/validate-config.md +7 -0
- er_smart_sync-0.2.0/docs/concepts/ca-identifier.md +112 -0
- er_smart_sync-0.2.0/docs/concepts/choices.md +133 -0
- er_smart_sync-0.2.0/docs/concepts/event-type-version.md +129 -0
- er_smart_sync-0.2.0/docs/getting-started/config.md +92 -0
- er_smart_sync-0.2.0/docs/getting-started/first-run.md +106 -0
- er_smart_sync-0.2.0/docs/getting-started/install.md +74 -0
- er_smart_sync-0.2.0/docs/images/.gitkeep +0 -0
- er_smart_sync-0.2.0/docs/images/README.md +26 -0
- er_smart_sync-0.2.0/docs/images/er-event-category-list.png +0 -0
- er_smart_sync-0.2.0/docs/images/er-event-type-form-v2.png +0 -0
- er_smart_sync-0.2.0/docs/images/er-event-type-with-choices.png +0 -0
- er_smart_sync-0.2.0/docs/images/smart-ca-label-bracketed.png +0 -0
- er_smart_sync-0.2.0/docs/index.md +45 -0
- er_smart_sync-0.2.0/docs/superpowers/plans/2026-05-13-er-v2-builder-rewrite.md +1305 -0
- er_smart_sync-0.2.0/docs/superpowers/plans/2026-05-13-er-v2-choices-population.md +2583 -0
- er_smart_sync-0.2.0/docs/superpowers/plans/2026-05-15-mkdocs-docs-site.md +2538 -0
- er_smart_sync-0.2.0/docs/superpowers/plans/archive/2026-05-12-er-v2-event-types-INCORRECT.md +2201 -0
- er_smart_sync-0.2.0/docs/superpowers/specs/2026-05-12-er-v2-event-types-design.md +240 -0
- er_smart_sync-0.2.0/docs/superpowers/specs/2026-05-13-er-v2-choices-population-design.md +361 -0
- er_smart_sync-0.2.0/docs/superpowers/specs/archive/2026-05-12-er-v2-event-types-design-INCORRECT.md +259 -0
- er_smart_sync-0.2.0/docs/troubleshooting.md +188 -0
- er_smart_sync-0.2.0/docs/workflows/inspect-datamodel.md +99 -0
- er_smart_sync-0.2.0/docs/workflows/populate-choices.md +145 -0
- er_smart_sync-0.2.0/docs/workflows/push-datamodel.md +170 -0
- er_smart_sync-0.2.0/docs/workflows/sync-events.md +7 -0
- er_smart_sync-0.2.0/docs/workflows/sync-patrols.md +7 -0
- er_smart_sync-0.2.0/mkdocs.yml +96 -0
- er_smart_sync-0.2.0/pyproject.toml +60 -0
- er_smart_sync-0.2.0/setup.cfg +4 -0
- er_smart_sync-0.2.0/src/cdip_connector/__init__.py +2 -0
- er_smart_sync-0.2.0/src/cdip_connector/core/__init__.py +1 -0
- er_smart_sync-0.2.0/src/cdip_connector/core/schemas.py +3 -0
- er_smart_sync-0.2.0/src/er_smart_sync/__init__.py +9 -0
- er_smart_sync-0.2.0/src/er_smart_sync/_version.py +24 -0
- er_smart_sync-0.2.0/src/er_smart_sync/choices.py +497 -0
- er_smart_sync-0.2.0/src/er_smart_sync/cli.py +1227 -0
- er_smart_sync-0.2.0/src/er_smart_sync/config.py +71 -0
- er_smart_sync-0.2.0/src/er_smart_sync/defaults.py +154 -0
- er_smart_sync-0.2.0/src/er_smart_sync/protocols.py +41 -0
- er_smart_sync-0.2.0/src/er_smart_sync/smart_to_er.py +334 -0
- er_smart_sync-0.2.0/src/er_smart_sync/smart_to_er_v2.py +357 -0
- er_smart_sync-0.2.0/src/er_smart_sync/state.py +10 -0
- er_smart_sync-0.2.0/src/er_smart_sync/synchronizer.py +1314 -0
- er_smart_sync-0.2.0/src/er_smart_sync/utils.py +19 -0
- er_smart_sync-0.2.0/src/er_smart_sync.egg-info/PKG-INFO +85 -0
- er_smart_sync-0.2.0/src/er_smart_sync.egg-info/SOURCES.txt +80 -0
- er_smart_sync-0.2.0/src/er_smart_sync.egg-info/dependency_links.txt +1 -0
- er_smart_sync-0.2.0/src/er_smart_sync.egg-info/entry_points.txt +2 -0
- er_smart_sync-0.2.0/src/er_smart_sync.egg-info/requires.txt +25 -0
- er_smart_sync-0.2.0/src/er_smart_sync.egg-info/top_level.txt +2 -0
- er_smart_sync-0.2.0/tests/__init__.py +0 -0
- er_smart_sync-0.2.0/tests/conftest.py +137 -0
- er_smart_sync-0.2.0/tests/test_choices.py +929 -0
- er_smart_sync-0.2.0/tests/test_cli.py +1435 -0
- er_smart_sync-0.2.0/tests/test_config.py +99 -0
- er_smart_sync-0.2.0/tests/test_smart_to_er.py +382 -0
- er_smart_sync-0.2.0/tests/test_smart_to_er_v2.py +733 -0
- er_smart_sync-0.2.0/tests/test_synchronizer.py +1455 -0
- er_smart_sync-0.2.0/tests/test_utils.py +18 -0
- er_smart_sync-0.2.0/uv.lock +1879 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
name: docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
paths:
|
|
7
|
+
- docs/**
|
|
8
|
+
- mkdocs.yml
|
|
9
|
+
- pyproject.toml
|
|
10
|
+
- .github/workflows/docs.yml
|
|
11
|
+
# Allow manual triggers from the Actions UI.
|
|
12
|
+
workflow_dispatch:
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: write
|
|
16
|
+
|
|
17
|
+
# Serialize deploys so two pushes to main in quick succession don't race
|
|
18
|
+
# on gh-deploy --force and clobber each other (or fail mid-push to gh-pages).
|
|
19
|
+
concurrency:
|
|
20
|
+
group: docs-deploy
|
|
21
|
+
cancel-in-progress: false
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
build-and-deploy:
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
steps:
|
|
27
|
+
- name: Checkout
|
|
28
|
+
uses: actions/checkout@v4
|
|
29
|
+
with:
|
|
30
|
+
# gh-deploy needs full history to commit to gh-pages.
|
|
31
|
+
fetch-depth: 0
|
|
32
|
+
|
|
33
|
+
- name: Set up Python
|
|
34
|
+
uses: actions/setup-python@v5
|
|
35
|
+
with:
|
|
36
|
+
python-version: "3.12"
|
|
37
|
+
|
|
38
|
+
- name: Install docs dependencies
|
|
39
|
+
# Use the [docs] extras declared in pyproject.toml so CI and local
|
|
40
|
+
# installs stay in sync.
|
|
41
|
+
run: |
|
|
42
|
+
python -m pip install --upgrade pip
|
|
43
|
+
pip install -e ".[docs]"
|
|
44
|
+
|
|
45
|
+
# --strict catches broken internal links, missing nav targets, and
|
|
46
|
+
# missing image files. The screenshot placeholders under docs/images/
|
|
47
|
+
# ship as 1×1 transparent PNGs so --strict passes; replace them with
|
|
48
|
+
# real screenshots when ready (docs/images/README.md tracks the slots).
|
|
49
|
+
- name: Build site
|
|
50
|
+
run: mkdocs build --strict
|
|
51
|
+
|
|
52
|
+
- name: Deploy to gh-pages
|
|
53
|
+
run: mkdocs gh-deploy --force
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*.*.*"
|
|
7
|
+
|
|
8
|
+
# `id-token: write` is required for PyPI Trusted Publishing (OIDC).
|
|
9
|
+
# `contents: write` is required for the GitHub Release upload step.
|
|
10
|
+
permissions:
|
|
11
|
+
contents: write
|
|
12
|
+
id-token: write
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
build-and-release:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
# Pin to a named environment so the PyPI Trusted Publisher config
|
|
18
|
+
# can be scoped to `pypi` and PRs from forks cannot trigger a
|
|
19
|
+
# release.
|
|
20
|
+
environment:
|
|
21
|
+
name: pypi
|
|
22
|
+
url: https://pypi.org/p/er-smart-sync
|
|
23
|
+
steps:
|
|
24
|
+
- name: Checkout
|
|
25
|
+
uses: actions/checkout@v4
|
|
26
|
+
with:
|
|
27
|
+
# setuptools-scm derives the version from `git describe`, so it
|
|
28
|
+
# needs the tag history. fetch-depth: 0 grabs the full history.
|
|
29
|
+
fetch-depth: 0
|
|
30
|
+
|
|
31
|
+
- name: Set up Python
|
|
32
|
+
uses: actions/setup-python@v5
|
|
33
|
+
with:
|
|
34
|
+
python-version: "3.12"
|
|
35
|
+
|
|
36
|
+
- name: Install package + build + test tooling
|
|
37
|
+
# Install the package with the [dev] extras so we can run the test
|
|
38
|
+
# suite as a gate before the release is published.
|
|
39
|
+
run: |
|
|
40
|
+
python -m pip install --upgrade pip
|
|
41
|
+
pip install -e ".[dev]"
|
|
42
|
+
pip install build
|
|
43
|
+
|
|
44
|
+
- name: Run tests
|
|
45
|
+
# Gate the release on the test suite: a tagged commit must pass
|
|
46
|
+
# tests before its wheel is uploaded to a GitHub Release. Without
|
|
47
|
+
# this gate, a broken tag would still ship artifacts.
|
|
48
|
+
run: pytest -q
|
|
49
|
+
|
|
50
|
+
- name: Build wheel and sdist
|
|
51
|
+
run: python -m build
|
|
52
|
+
|
|
53
|
+
- name: Show built artifacts
|
|
54
|
+
run: ls -la dist/
|
|
55
|
+
|
|
56
|
+
- name: Verify version matches tag
|
|
57
|
+
# Sanity check: the wheel's version (derived by setuptools-scm) must
|
|
58
|
+
# match the pushed tag's version. If git describe ever drifts from
|
|
59
|
+
# the tag (dirty tree, missing tag in shallow clone), fail loudly
|
|
60
|
+
# instead of shipping a mislabelled wheel.
|
|
61
|
+
run: |
|
|
62
|
+
tag_version="${GITHUB_REF_NAME#v}"
|
|
63
|
+
wheel_version=$(ls dist/*.whl | sed -E 's/.*er_smart_sync-([^-]+)-.*/\1/' | head -1)
|
|
64
|
+
if [ "$tag_version" != "$wheel_version" ]; then
|
|
65
|
+
echo "::error::Tag ($tag_version) and wheel ($wheel_version) versions differ"
|
|
66
|
+
exit 1
|
|
67
|
+
fi
|
|
68
|
+
echo "Tag and wheel both at $wheel_version"
|
|
69
|
+
|
|
70
|
+
- name: Publish to PyPI
|
|
71
|
+
# Trusted Publisher (OIDC) — no API token. Requires a one-time
|
|
72
|
+
# config on pypi.org: pypi.org/manage/account/publishing/ →
|
|
73
|
+
# add a trusted publisher for `er-smart-sync` pointing at this
|
|
74
|
+
# repo, workflow `release.yml`, environment `pypi`.
|
|
75
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
76
|
+
|
|
77
|
+
- name: Create GitHub Release
|
|
78
|
+
# Also attach the artifacts to a GitHub Release. Keeps the
|
|
79
|
+
# existing "install from a release wheel URL" path working
|
|
80
|
+
# alongside `pip install er-smart-sync`.
|
|
81
|
+
env:
|
|
82
|
+
GH_TOKEN: ${{ github.token }}
|
|
83
|
+
run: |
|
|
84
|
+
gh release create "$GITHUB_REF_NAME" \
|
|
85
|
+
--title "$GITHUB_REF_NAME" \
|
|
86
|
+
--generate-notes \
|
|
87
|
+
dist/*
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Virtualenvs
|
|
2
|
+
.venv/
|
|
3
|
+
venv/
|
|
4
|
+
env/
|
|
5
|
+
|
|
6
|
+
# Python bytecode and packaging
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.py[cod]
|
|
9
|
+
*.egg-info/
|
|
10
|
+
*.egg
|
|
11
|
+
build/
|
|
12
|
+
dist/
|
|
13
|
+
|
|
14
|
+
# setuptools-scm generated version file
|
|
15
|
+
src/er_smart_sync/_version.py
|
|
16
|
+
|
|
17
|
+
# Tooling caches
|
|
18
|
+
.pytest_cache/
|
|
19
|
+
.ruff_cache/
|
|
20
|
+
.mypy_cache/
|
|
21
|
+
.ty_cache/
|
|
22
|
+
|
|
23
|
+
# OS / editor
|
|
24
|
+
.DS_Store
|
|
25
|
+
*.swp
|
|
26
|
+
|
|
27
|
+
# Local secrets / state
|
|
28
|
+
.env
|
|
29
|
+
state.json
|
|
30
|
+
/tmp/
|
|
31
|
+
site/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.10
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"name": "sync junglekeepers-peru.pamdas.org",
|
|
9
|
+
"type": "debugpy",
|
|
10
|
+
"request": "launch",
|
|
11
|
+
"program": "${workspaceFolder}/.venv/bin/er-smart-sync",
|
|
12
|
+
"args": [
|
|
13
|
+
"datamodel",
|
|
14
|
+
"--smart-language",
|
|
15
|
+
"es",
|
|
16
|
+
"--er-token",
|
|
17
|
+
"98ILsqkxMA0R9MSK7Kl6nZLBQ9SKAI",
|
|
18
|
+
"--er-endpoint",
|
|
19
|
+
"https://junglekeepers-peru.pamdas.org",
|
|
20
|
+
"--smart-ca-uuid",
|
|
21
|
+
"SMART-IMPORT",
|
|
22
|
+
"--from-file",
|
|
23
|
+
"/Users/chrisdo/junglekeepers-peru.datamodel.xml",
|
|
24
|
+
"--ca-label",
|
|
25
|
+
"[SMART]",
|
|
26
|
+
"--cm-from-file",
|
|
27
|
+
"/Users/chrisdo/junglekeepers-peru.cm.xml"
|
|
28
|
+
],
|
|
29
|
+
"console": "integratedTerminal"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "sync ujugkulan-np.pamdas.org",
|
|
33
|
+
"type": "debugpy",
|
|
34
|
+
"request": "launch",
|
|
35
|
+
"program": "${workspaceFolder}/.venv/bin/er-smart-sync",
|
|
36
|
+
"args": [
|
|
37
|
+
"datamodel",
|
|
38
|
+
"--smart-language",
|
|
39
|
+
"in",
|
|
40
|
+
"--er-token",
|
|
41
|
+
"df7cddebb00c8e509ba820022b6c730d3c3414c6",
|
|
42
|
+
"--er-endpoint",
|
|
43
|
+
"https://ujungkulon-np.pamdas.org",
|
|
44
|
+
"--smart-ca-uuid",
|
|
45
|
+
"SMART-IMPORT",
|
|
46
|
+
"--from-file",
|
|
47
|
+
"/Users/chrisdo/uknp-datamodel.xml",
|
|
48
|
+
"--ca-label",
|
|
49
|
+
"SMART-IMPORT"
|
|
50
|
+
],
|
|
51
|
+
"console": "integratedTerminal"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
]
|
|
55
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"python.analysis.extraPaths": ["src"],
|
|
3
|
+
"python.testing.pytestEnabled": true,
|
|
4
|
+
"python.testing.pytestArgs": ["tests"],
|
|
5
|
+
"[python]": {
|
|
6
|
+
"editor.defaultFormatter": "charliermarsh.ruff",
|
|
7
|
+
"editor.formatOnSave": true,
|
|
8
|
+
"editor.codeActionsOnSave": {
|
|
9
|
+
"source.fixAll.ruff": "explicit",
|
|
10
|
+
"source.organizeImports.ruff": "explicit"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"ruff.configuration": "pyproject.toml",
|
|
14
|
+
"ty.configurationFile": "pyproject.toml",
|
|
15
|
+
"python.venvPath": ".venv/bin/python"
|
|
16
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Codex (Codex.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## What This Project Does
|
|
6
|
+
|
|
7
|
+
er-smart-sync synchronizes data between **SMART Connect** (wildlife conservation monitoring) and **EarthRanger** (real-time data visualization for protected areas). It supports three sync flows:
|
|
8
|
+
|
|
9
|
+
1. **Datamodel sync** (SMART → ER): Push event categories and event types from SMART conservation areas to EarthRanger
|
|
10
|
+
2. **Event sync** (ER → SMART): Poll EarthRanger events and publish them via message broker (Pub/Sub) for routing to SMART
|
|
11
|
+
3. **Patrol sync** (ER → SMART): Poll EarthRanger patrols (with track points, segment events, files) and publish them
|
|
12
|
+
|
|
13
|
+
## Commands
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Install (editable, with dev dependencies)
|
|
17
|
+
uv pip install -e ".[dev]"
|
|
18
|
+
|
|
19
|
+
# Run all tests
|
|
20
|
+
pytest
|
|
21
|
+
|
|
22
|
+
# Run a single test
|
|
23
|
+
pytest tests/test_synchronizer.py::test_synchronize_er_events
|
|
24
|
+
|
|
25
|
+
# Lint
|
|
26
|
+
ruff check src tests
|
|
27
|
+
|
|
28
|
+
# Format
|
|
29
|
+
ruff format src tests
|
|
30
|
+
|
|
31
|
+
# Type check
|
|
32
|
+
ty check
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Architecture
|
|
36
|
+
|
|
37
|
+
The codebase uses a **protocol-based dependency injection** pattern. `ERSmartSynchronizer` is the core class that accepts pluggable implementations of four protocols (`protocols.py`):
|
|
38
|
+
|
|
39
|
+
- `MessagePublisher` — publishes events/patrols to a message broker (e.g. Google Pub/Sub)
|
|
40
|
+
- `FileStorage` — stores downloaded attachment files (e.g. Google Cloud Storage)
|
|
41
|
+
- `StateStore` — persists last-poll timestamps for incremental sync
|
|
42
|
+
- `TracingProvider` — distributed tracing spans
|
|
43
|
+
|
|
44
|
+
Default (null/local) implementations live in `defaults.py` and are used by the CLI. Production implementations (GCP Pub/Sub, GCS, etc.) are injected when running in the Gundi platform.
|
|
45
|
+
|
|
46
|
+
### Key External Dependencies
|
|
47
|
+
|
|
48
|
+
- **dasclient** (`DasClient`) — EarthRanger REST API client
|
|
49
|
+
- **smartconnect** (`SmartClient`) — SMART Connect API client; also provides `er_sync_utils` for building ER event types from SMART data models
|
|
50
|
+
- **gundi-core** — shared Pydantic schemas (`EREvent`, `ERPatrol`, `ERObservation`, `ERSubject`)
|
|
51
|
+
|
|
52
|
+
All three are pinned to specific wheel releases or minimum versions. Uses Pydantic v1 (`<2.0`).
|
|
53
|
+
|
|
54
|
+
### CLI
|
|
55
|
+
|
|
56
|
+
The Click CLI (`cli.py`) has three subcommands: `datamodel`, `events`, `patrols`. Each accepts either a `--config` YAML file or individual `--smart-*` / `--er-*` flags.
|
|
57
|
+
|
|
58
|
+
## Key Conventions
|
|
59
|
+
|
|
60
|
+
- Pydantic v1 API (`parse_obj_as`, `.json()`, `.dict()`) — do not use v2 patterns
|
|
61
|
+
- SMART versions below 7.5.3 require patching events with `smart_observation_uuid`; this is version-gated
|
|
62
|
+
- Conservation area labels are expected to contain a bracketed identifier like `"Name [CODE]"` — the `[CODE]` is extracted and used as the event category value
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## What This Project Does
|
|
6
|
+
|
|
7
|
+
er-smart-sync synchronizes data between **SMART Connect** (wildlife conservation monitoring) and **EarthRanger** (real-time data visualization for protected areas). It supports three sync flows:
|
|
8
|
+
|
|
9
|
+
1. **Datamodel sync** (SMART → ER): Push event categories and event types from SMART conservation areas to EarthRanger
|
|
10
|
+
2. **Event sync** (ER → SMART): Poll EarthRanger events and publish them via message broker (Pub/Sub) for routing to SMART
|
|
11
|
+
3. **Patrol sync** (ER → SMART): Poll EarthRanger patrols (with track points, segment events, files) and publish them
|
|
12
|
+
|
|
13
|
+
## Commands
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Install (editable, with dev dependencies)
|
|
17
|
+
uv pip install -e ".[dev]"
|
|
18
|
+
|
|
19
|
+
# Run all tests
|
|
20
|
+
pytest
|
|
21
|
+
|
|
22
|
+
# Run a single test
|
|
23
|
+
pytest tests/test_synchronizer.py::test_synchronize_er_events
|
|
24
|
+
|
|
25
|
+
# Lint
|
|
26
|
+
ruff check src tests
|
|
27
|
+
|
|
28
|
+
# Format
|
|
29
|
+
ruff format src tests
|
|
30
|
+
|
|
31
|
+
# Type check
|
|
32
|
+
ty check
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Architecture
|
|
36
|
+
|
|
37
|
+
The codebase uses a **protocol-based dependency injection** pattern. `ERSmartSynchronizer` is the core class that accepts pluggable implementations of four protocols (`protocols.py`):
|
|
38
|
+
|
|
39
|
+
- `MessagePublisher` — publishes events/patrols to a message broker (e.g. Google Pub/Sub)
|
|
40
|
+
- `FileStorage` — stores downloaded attachment files (e.g. Google Cloud Storage)
|
|
41
|
+
- `StateStore` — persists last-poll timestamps for incremental sync
|
|
42
|
+
- `TracingProvider` — distributed tracing spans
|
|
43
|
+
|
|
44
|
+
Default (null/local) implementations live in `defaults.py` and are used by the CLI. Production implementations (GCP Pub/Sub, GCS, etc.) are injected when running in the Gundi platform.
|
|
45
|
+
|
|
46
|
+
### Key External Dependencies
|
|
47
|
+
|
|
48
|
+
- **dasclient** (`DasClient`) — EarthRanger REST API client
|
|
49
|
+
- **smartconnect** (`SmartClient`) — SMART Connect API client; also provides `er_sync_utils` for building ER event types from SMART data models
|
|
50
|
+
- **gundi-core** — shared Pydantic schemas (`EREvent`, `ERPatrol`, `ERObservation`, `ERSubject`)
|
|
51
|
+
|
|
52
|
+
All three are pinned to specific wheel releases or minimum versions. Uses Pydantic v1 (`<2.0`).
|
|
53
|
+
|
|
54
|
+
### CLI
|
|
55
|
+
|
|
56
|
+
The Click CLI (`cli.py`) has three subcommands: `datamodel`, `events`, `patrols`. Each accepts either a `--config` YAML file or individual `--smart-*` / `--er-*` flags.
|
|
57
|
+
|
|
58
|
+
## Key Conventions
|
|
59
|
+
|
|
60
|
+
- Pydantic v1 API (`parse_obj_as`, `.json()`, `.dict()`) — do not use v2 patterns
|
|
61
|
+
- SMART versions below 7.5.3 require patching events with `smart_observation_uuid`; this is version-gated
|
|
62
|
+
- Conservation area labels are expected to contain a bracketed identifier like `"Name [CODE]"` — the `[CODE]` is extracted and used as the event category value
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may accept and charge a
|
|
167
|
+
fee for, or grant rights consistent with this License. However, in
|
|
168
|
+
accepting such obligations, You may act only on Your own behalf
|
|
169
|
+
and on Your sole responsibility, not on behalf of any other
|
|
170
|
+
Contributor, and only if You agree to indemnify, defend, and hold
|
|
171
|
+
each Contributor harmless for any liability incurred by, or claims
|
|
172
|
+
asserted against, such Contributor by reason of your accepting any
|
|
173
|
+
such warranty or additional liability.
|
|
174
|
+
|
|
175
|
+
END OF TERMS AND CONDITIONS
|
|
176
|
+
|
|
177
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
178
|
+
|
|
179
|
+
To apply the Apache License to your work, attach the following
|
|
180
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
181
|
+
replaced with your own identifying information. (Don't include
|
|
182
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
183
|
+
comment syntax for the file format. We also recommend that a
|
|
184
|
+
file or class name and description of purpose be included on the
|
|
185
|
+
same "printed page" as the copyright notice for easier
|
|
186
|
+
identification within third-party archives.
|
|
187
|
+
|
|
188
|
+
Copyright 2026 PADAS
|
|
189
|
+
|
|
190
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
191
|
+
you may not use this file except in compliance with the License.
|
|
192
|
+
You may obtain a copy of the License at
|
|
193
|
+
|
|
194
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
195
|
+
|
|
196
|
+
Unless required by applicable law or agreed to in writing, software
|
|
197
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
198
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
199
|
+
See the License for the specific language governing permissions and
|
|
200
|
+
limitations under the License.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: er-smart-sync
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Synchronize SMART Connect data models, events, and patrols with EarthRanger
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: earthranger-client
|
|
10
|
+
Requires-Dist: smartconnect-client<2.0,>=1.11.0
|
|
11
|
+
Requires-Dist: gundi-core>=1.11.0
|
|
12
|
+
Requires-Dist: pydantic<2.0,>=1.10
|
|
13
|
+
Requires-Dist: packaging
|
|
14
|
+
Requires-Dist: click
|
|
15
|
+
Requires-Dist: pyyaml
|
|
16
|
+
Provides-Extra: gcp
|
|
17
|
+
Requires-Dist: google-cloud-pubsub; extra == "gcp"
|
|
18
|
+
Requires-Dist: google-cloud-storage; extra == "gcp"
|
|
19
|
+
Provides-Extra: tracing
|
|
20
|
+
Requires-Dist: opentelemetry-api; extra == "tracing"
|
|
21
|
+
Requires-Dist: opentelemetry-sdk; extra == "tracing"
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest; extra == "dev"
|
|
24
|
+
Requires-Dist: pytest-mock; extra == "dev"
|
|
25
|
+
Requires-Dist: ruff; extra == "dev"
|
|
26
|
+
Requires-Dist: ty; extra == "dev"
|
|
27
|
+
Provides-Extra: docs
|
|
28
|
+
Requires-Dist: mkdocs-material>=9.5; extra == "docs"
|
|
29
|
+
Requires-Dist: mkdocs-exclude>=1.0; extra == "docs"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# er-smart-sync
|
|
33
|
+
|
|
34
|
+
Synchronize [SMART Connect](https://smartconservationtools.org/) wildlife-monitoring
|
|
35
|
+
data with [EarthRanger](https://www.earthranger.com/).
|
|
36
|
+
|
|
37
|
+
## 📖 Full documentation
|
|
38
|
+
|
|
39
|
+
**https://padas.github.io/earthranger-smart-utils/**
|
|
40
|
+
|
|
41
|
+
Includes install instructions, step-by-step workflows for every sync flow,
|
|
42
|
+
a complete CLI reference, conceptual background, and troubleshooting.
|
|
43
|
+
|
|
44
|
+
## What it does
|
|
45
|
+
|
|
46
|
+
- **Datamodel sync** (SMART → ER) — turn SMART data models into EarthRanger
|
|
47
|
+
event categories and event types.
|
|
48
|
+
- **Event sync** (ER → SMART) — poll EarthRanger events and forward them via
|
|
49
|
+
message broker.
|
|
50
|
+
- **Patrol sync** (ER → SMART) — poll EarthRanger patrols with track points
|
|
51
|
+
and attached files.
|
|
52
|
+
|
|
53
|
+
## Quick install
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
uv pip install er-smart-sync
|
|
57
|
+
er-smart-sync --help
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or install from source (for development):
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git clone git@github.com:PADAS/earthranger-smart-utils.git
|
|
64
|
+
cd earthranger-smart-utils
|
|
65
|
+
uv pip install -e ".[dev]"
|
|
66
|
+
er-smart-sync --help
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
See the [Installation page](https://padas.github.io/earthranger-smart-utils/getting-started/install/)
|
|
70
|
+
for prerequisites, optional extras, and verification steps.
|
|
71
|
+
|
|
72
|
+
## For contributors
|
|
73
|
+
|
|
74
|
+
Working on the codebase itself? Start with:
|
|
75
|
+
|
|
76
|
+
- **[CLAUDE.md](CLAUDE.md)** — codebase conventions: Pydantic v1 API, SMART version-gating (<7.5.3 needs `smart_observation_uuid` patching), the bracketed-CA-label convention, and the protocol-based dependency-injection pattern.
|
|
77
|
+
- **[USAGE.md](USAGE.md)** — developer-oriented CLI reference and the bracketed-CA-label convention as it affects the codebase.
|
|
78
|
+
- **[docs/superpowers/specs/](docs/superpowers/specs/)** — design specs for non-trivial features (v2 event types, choices population, etc.).
|
|
79
|
+
- **[docs/superpowers/plans/](docs/superpowers/plans/)** — implementation plans for recent feature work.
|
|
80
|
+
|
|
81
|
+
The user-facing documentation at the link above covers what `er-smart-sync` does and how to use it; the references in this section cover how it's built.
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
Apache License 2.0. See [LICENSE](LICENSE).
|