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).--direct-db: Enable direct database ingestion usingpypgstac. This bypasses the STAC API for writes, resulting in much faster ingestion. It uses a single database transaction, ensuring that if the crawl fails, the database remains untouched.--db-dsn TEXT: Connection string for the PgSTAC database (e.g.,postgresql://user:pass@localhost:5432/eoapi). If not provided, the crawler will automatically use standard PostgreSQL environment variables (PGHOST,PGUSER,PGPASSWORD,PGDATABASE,PGPORT).--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.
Direct Database Ingestion (Recommended)
For large crawls, it is recommended to use direct database ingestion. This mode writes items to a temporary local file during the crawl and loads them into the database in a single, fast transaction once the crawl is complete. This keeps the API fully populated with existing data until the very end and is significantly faster than HTTP-based ingestion.
# Using explicit DSN
osc-to-eoapi crawl --direct-db --db-dsn "postgresql://postgres:adminpassword@localhost:5432/eoapi"
# Using environment variables from .env
set -a; source .env; set +a
osc-to-eoapi crawl --direct-db
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 using direct database ingestion:
# Load environment variables set -a; source .env; set +a # Run the crawl transactionally osc-to-eoapi crawl --test-endpoint --reset-db --direct-db
(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
Metadata
Release files for osc-to-eoapi 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| osc_to_eoapi-0.2.5.tar.gz | 19.5 kB | Without provenance | Details for osc_to_eoapi-0.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| osc_to_eoapi-0.2.5-py3-none-any.whl | Python 3 | none | any | Details for osc_to_eoapi-0.2.5-py3-none-any.whl |
Total release size: 37.9 kB
Release files / osc_to_eoapi-0.2.5.tar.gz
| Download URL | osc_to_eoapi-0.2.5.tar.gz |
|---|---|
| Size | 19.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0404da591277143189621177af432e9bbcace2157e080090139d091acae91a62
|
|
BLAKE2b-256 checksum How to use checksums |
dd47dd9c94a8c4e2ca5424898c4a03e7831abe2bd9856a4b37ca2ab862882291
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / osc_to_eoapi-0.2.5-py3-none-any.whl
| Download URL | osc_to_eoapi-0.2.5-py3-none-any.whl |
|---|---|
| Size | 18.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
45e7c463bbab852aa2d38b28b140b6e9e29397c64eb49ee25d65ca640c02d409
|
|
BLAKE2b-256 checksum How to use checksums |
965aa7614a3aeaf0c45e54099412e6d4aadbcf26cc3f1c24e769aec0d31502a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Security for osc-to-eoapi 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.