A tool to crawl OSC STAC catalogs and ingest them into eoapi
Project description
osc-to-eoapi
A Python package to crawl OSC (Open Science Catalog) STAC catalogs and ingest them into an eoapi STAC API instance.
Installation
pip install .
Usage
Ingesting Data
osc-to-eoapi crawl [OPTIONS]
Options:
--github-url TEXT: URL to the root OSC STACcatalog.jsonon GitHub. (Default: ESA OSC main branch)--eoapi-url TEXT: URL to theeoapiSTAC API instance. (Default:http://localhost:8080)--update: If a collection/item already exists (409), attempt to update it with aPUTrequest.--overwrite: Force overwrite by deleting existing collections/items before ingestion.--reset-db: Clear all collections from the target STAC API before starting the crawl.--test-endpoint: Perform a health check on the STAC API before starting.--crawl-external: Enable recursive crawling of external STAC links found in the catalog. Includes cycle detection to prevent infinite loops.--kb-cache TEXT: Path to a local JSON file to cache the taxonomies (variables, projects, etc.) to significantly speed up subsequent runs. In order to disable it set it to an empty string. (Default:kb_cache.json)--skip-collection TEXT: Collection ID to skip if it is already present in the target API. Can be provided multiple times (e.g.,--skip-collection "col1" --skip-collection "col2").--category TEXT: Specific category to crawl. Defaults to crawling all categories (products,experiments,workflows). Can be provided multiple times (e.g.,--category workflows --category experiments).--add-source-links: Add the source catalog URL as acanonicallink (and attempt to setselflinks).--links-self-base-url TEXT: Override the base URL forselflinks (e.g., to point to GitHub Pages instead of raw GitHub content).--debug: Enable verbose debug logging to trace the recursive traversal of external catalogs and item discovery. Useful for identifying bottlenecks or infinite loops in remote datasets.
Configuring Source Links (e.g., GitHub Pages)
You can configure the crawler to preserve the original source links for STAC collections and items rather than generating API-relative links. This is especially useful if your API acts as a discovery layer for static catalogs hosted on GitHub Pages.
osc-to-eoapi crawl \
--github-url https://raw.githubusercontent.com/ESA-EarthCODE/open-science-catalog-metadata/main/catalog.json \
--add-source-links \
--source-base-url https://esa-earthcode.github.io/open-science-catalog-metadata
Loading Queryables
To enable filtering by the custom OSC properties (e.g., osc:project, kb:variable:title), load the queryables schema:
osc-to-eoapi load-queryables
You can also provide a custom schema:
osc-to-eoapi load-queryables --schema ./my-schema.json
Publishing to PyPI
- Ensure you have
buildandtwineinstalled:pip install build twine
- Build the package:
python -m build
- Upload to PyPI:
python -m twine upload dist/*
Development
-
Create and activate a Python virtual environment:
python -m venv venv source venv/bin/activate # On Linux/macOS # OR: venv\Scripts\activate # On Windows
-
Install in editable mode with dependencies:
pip install -e .
Local Testing Environment
A docker-compose.yml is provided to easily spin up a local PgSTAC database and eoapi STAC API instance for testing.
-
Start the local infrastructure:
docker compose up -d
-
Export local database credentials (required for
pypgstacto load queryables). A.envfile is provided, which you can source directly:set -a; source .env; set +a
-
Load the custom queryables into the local database:
osc-to-eoapi load-queryables -
Run the crawler against the local API (running on
http://localhost:8080):osc-to-eoapi crawl --test-endpoint --reset-db --eoapi-url http://localhost:8080
(Add
--crawl-externalif you want to test recursive external link crawling). -
Tear down the local infrastructure and wipe test data when finished:
docker compose down -v
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file osc_to_eoapi-0.1.3.tar.gz.
File metadata
- Download URL: osc_to_eoapi-0.1.3.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f23fb6157742170b0e0391b2570667ab196ff3891b45020bec466d4ee91e694b
|
|
| MD5 |
6b25e33358457da277068f57580ff417
|
|
| BLAKE2b-256 |
d60b34b1d9ec0eaa6f6760435da633907d1a651d20bb3b606e43ecdcb454d681
|
File details
Details for the file osc_to_eoapi-0.1.3-py3-none-any.whl.
File metadata
- Download URL: osc_to_eoapi-0.1.3-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6869dd09e90556659c344f99b9bef31fbf753f14a0972ee2ef2f0bf970041a4
|
|
| MD5 |
d4116fb6a0b6d98f51bbcd548b99672b
|
|
| BLAKE2b-256 |
a58ad3e1a65b2918a09adffb94ac4e1eac16ed0c13809bc0affe68f845fabf03
|