Skip to main content

CMR Metadata Validation scripts for NASA Earth Science collections

Project description

NASA Earth Science Collections Metadata Validator

Description

This Python script automates the process of validating metadata for NASA Earth Science collections allowing users to set a collection date range between 2000-01-01 and present date. It fetches collection metadata from NASA's Common Metadata Repository (CMR) APIs, performs validation checks, assesses public accessibility, and retrieves granule counts for each collection. The results are compiled into a comprehensive CSV report with a calculated collection validation percentage.

Features

  • Fetches collection metadata using NASA's CMR API
  • Validates collection records using the CMR validation API
  • Checks public accessibility of each record
  • Retrieves granule counts for collections
  • Processes collections in parallel for improved efficiency
  • Generates a detailed CSV report with validation results
    • Provides a calculated collection validation percentage in the CVS reports

Requirements

  • Script package was developed under Python 3.13.X
  • Required additional Python packages:
    • requests
    • jq
  • Launchpad token using a PEM certificate file
  • Permissions to CMR metadata providers' holdings

Installation

  1. Clone this repository or download the script.
  2. Install uv https://docs.astral.sh/uv/getting-started/installation/
  3. Run uv init
  4. Run uv pip install -e . to install all dependencies in the pyproject.toml
  5. Install the jq dependency using OS package manager such as brew for MacOs
  6. Ensure you have a valid cert.pem file in the same directory as the script for Launchpad authentication. You can run the pfx_to_pem if you need utilizing a pfx file from the NASA Launchpad team see https://wiki.earthdata.nasa.gov/spaces/CMR/pages/155197043/Launchpad+Authentication+User+s+Guide for more information
  7. If you have the uv env already you may need to use uv venv to initialize the virtual environment then source it source .venv/bin/activate

Usage

Run the script from the command line, specifying either a provider or consortium:

Install the package in development mode so that code updates automatically get used. uv pip install -e .

(You can install a distribution version by omitting the -e)

cmr-metadata-validator --provider LANCEMODIS

that will install this library as a development version in .venv if you are for some reason using pip or pip3 directly that will be installed in a different location dependent on OS directly though the workflow should be the same

cmr-metadata-validator -h, --help  (Show this help message and exit)

or

cmr-metadata-validator --provider [PROVIDER_NAME]

or

cmr-metadata-validator --consortium [CONSORTIUM_NAME]
(note: under development.)

or

cmr-metadata-validator --provider [PROVIDER_NAME] --start_date [START_DATE]

or

cmr-metadata-validator --provider [PROVIDER_NAME] --end_date [END_DATE]

Command-line Arguments

  • --provider: Specify a NASA data provider (ASF, ASIPS, CDDIS, ESDIS, GES_DISC, GESDISCCLD, GHRC, GHRC_DAAC, LAADS, LANCEAMSR2, LANCEMODIS, LARC_ASDC, LARC_CLOUD, LARC, LPCLOUD, LPDAAC_ECS, NSIDC_CPRD, NSIDC_ECS, NSIDCV0, OB_CLOUD, OB_DAAC, OMINRT, ORNL_CLOUD, POCLOUD, PODAAC, SEDAC)

  • --consortium: Specify a consortium (EOSDIS, CWIC, CEOS, GEOSS, FEDEO)

  • --start_date: START_DATE Start date for the first metadata ingestion of collections (format: YYYY-MM-DD, default: 2000-01-01).

  • --end_date: END_DATE End date for the last metadata ingestion of collections (format: YYYY-MM-DD, default: current date).

Authentication

The script requires Launchpad authentication. Ensure your cert.pem file is up-to-date and properly configured. What is a PEM certificate file?.

Output

The script generates a CSV file named [PROVIDER/CONSORTIUM]_collections_[TIMESTAMP].csv with the following columns:

  • Provider
  • Concept ID
  • Native ID
  • ShortName
  • Version
  • Collection Progress
  • Granule Count
  • Public/Private Status
  • Issue Type (Error/Warning)
  • Error/Warning Path
  • Error/Warning Message

Adds the Provider's calculated collection validation percentage at the end of the file.

Running test suite

uv run pytest

To run a specific test use uv run pytest path/to/your/test_file.py

To run a specific test in the test file use uv run pytest tests/test_api_utils.py::MyTestClass::test_name replace the class if there is one with the test class and the test_name with the name of the test module

Important Notes

  • This script interacts with NASA's CMR APIs. Ensure you have the necessary permissions.
  • Processing time may vary based on the number of collections and API response times.
  • Check console output for progress updates and any error messages.

Error Handling

The script includes error handling for API requests and data processing. Errors are logged to stderr.

Customization

You can modify the script to adjust:

  • The number of concurrent workers in the thread pool
  • The CMR query structure
  • CSV output format

Distribution

  1. uv build creates the distribution and wheel in the /dist directory
  2. You need to have an API token saved as an env var UV_PUBLISH_TOKEN to publish under the project
  3. For new versions use the uv version --bump patch at least depending on the extent of changes it may be a minor or major
  4. Use uv publish to publish the package on https://pypi.org/

Note: You will want to likely use uv build --clear if you already have distribution files because the publish will publish all of them or target specific version

Contact

Michael Morahan Email: michael.p.morahan@nasa.gov

License

This work was supported by NASA/GSFC under Raytheon Technologies contract Earth Observing System Data and Information System (EOSDIS) Evolution and Development (EED-3) (contract number 80GSFC21CA001). All Rights Reserved.

Creation Date: 2025-08-08 Update date: 2025-11-14 Version: 1.1

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

cmr_metadata_validator-0.1.4.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmr_metadata_validator-0.1.4-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file cmr_metadata_validator-0.1.4.tar.gz.

File metadata

  • Download URL: cmr_metadata_validator-0.1.4.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cmr_metadata_validator-0.1.4.tar.gz
Algorithm Hash digest
SHA256 ba4f7565e654ceccba842d9530d3ea61fc82797ee025fc802786a67d59b892ed
MD5 a71a277e45b588771f218728cc0d93d0
BLAKE2b-256 6dbbce92624e11960cac8a9c7e871856acba49e39693fd91891fde4bd3c61f38

See more details on using hashes here.

File details

Details for the file cmr_metadata_validator-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: cmr_metadata_validator-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cmr_metadata_validator-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d7f9698b7dca6da0466f69664b3b1f6ff7c3a35fafe0b3e0188a13aceb131a24
MD5 864918b21dd0a19b8a99e87037909cfe
BLAKE2b-256 e527e922ada4571a3b1ebca4714718d040e71b58f0189d6a85ff458f557abcd7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page