Skip to main content

youvegotdata

Uses RabbitMQ to send new file notifications, with the ultimate purpose of getting the file metadata into the Data Inventory Database.

The "producer" youvegotdata.py will usually be called by the CIRA data ingest scripts when a new file is added to the CIRA data stores, and will send a message through RabbitMQ to the consumers with the file's metadata.

Message "consumers" will be running to receive the file metadata and insert it into the database. It is expected that multiple consumers process will be accepting messages in RabbitMQ's "fair dispatch" configuration. A given notification will be received by one consumer.

Installing youvegotdata

This module requires Python 3.8 or greater. It is deployed to PyPi, so it can be installed with:

pip install youvegotdata

Which will install the ygd CLI command in your current Python environment.

Library usage

youvegotdata is also importable as a plain Python package so that ingest scripts can send notifications programmatically instead of shelling out to the ygd CLI. The public API is re-exported from the top-level package:

from youvegotdata import (
    Config,
    ConfigError,
    Notification,
    load_config,
    resolve_data_store,
    send_notification,
)

Loading configuration

load_config() reads and validates ~/.config/youvegotdata/config.ini (the same file the CLI uses) and returns a frozen Config dataclass. Validation errors raise ConfigError:

try:
    config = load_config()
except ConfigError as exc:
    print(f"configuration problem: {exc}")
    raise

To point at a specific file (e.g. for tests), pass an explicit path:

config = load_config("/path/to/config.ini")

The returned Config exposes rmq_host (str) and ceph_ips (dict[str, list[str]]).

Resolving a data store from a filepath

resolve_data_store maps a local path to its data store name and a store-relative path. It reads /proc/self/mountinfo, so it only works on Linux:

data_store, store_path = resolve_data_store("/data/file.hdf", config.ceph_ips)

Sending a notification

Build a Notification and pass it (plus a Config) to send_notification. It publishes one durable JSON message to the file_notif_queue queue and returns True on success or False if the data store could not be resolved. RabbitMQ errors are logged and re-raised as pika.exceptions.AMQPError:

notification = Notification(
    filepath="/data/file.hdf",
    product="L2_VIS",
    version="1.0",
    start_time="2024-01-01T00:00:00",
    end_time="2024-01-01T01:00:00",
    size=1024,
    checksum="abc123",
    platform_name="VIIRS",
    source_name="imager",
    addl_metadata={
        "geoips_variables": {
            "variables": ["red", "green", "blue"],
            "SSP_spatial_resolution": "0.02 km",
        }
    },
)
send_notification(notification, config)

Only filepath is required; the rest default to None. The checksum must be an xxhash value if it is included.

Backward compatibility

The v1.x function produce_notification(config, filepath, ...) is kept as a deprecated shim that emits a DeprecationWarning and forwards to send_notification. It still accepts a raw configparser.ConfigParser or a Config. New code should use send_notification instead.

Running youvegotdata.py as ygd

Create the ~/.config/youvegotdata/ directory if it does not already exist. Create a config.ini file in this directory that looks like:

[Settings]
RMQ_HOST = <host of the RabbitMQ server>

[Data-store-mappings]
# The list of common Ceph IPs for every Ceph data store
# A dictionary of lists. This must be valid JSON: double quotes, no trailing commas.
CEPH_IPS = {"name": ["IP", "IP", "IP"], "name2": ["IP", "IP", "IP"]}

And fill it in with the RabbitMQ server's host name, and the IP address mappings across different Linux versions for the Ceph data stores.

Run the code with:

ygd [-h] [-v] [-p PRODUCT] [-r VERSION] [-s START_TIME] [-e END_TIME] [-l LENGTH] [-c CHECKSUM] [-t PLATFORM_NAME] [-o SOURCE_NAME] [-a ADDL_METADATA] filepath

Run this with the -h (--help) argument to see the available flagged arguments.

This will usually be run with just the filepath argument. An example is:

ygd /full/path/to/local/file/data_file.hdf

The filepath file must exist on the local machine.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

youvegotdata-2.1.0.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

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

youvegotdata-2.1.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file youvegotdata-2.1.0.tar.gz.

File metadata

  • Download URL: youvegotdata-2.1.0.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for youvegotdata-2.1.0.tar.gz
Algorithm Hash digest
SHA256 f0d8d8f33084b3ed903be04cc6c740620143b66429a4ec5fcea1354892799678
MD5 4ab22fbcead0a8ab389aed6fa05a7da9
BLAKE2b-256 63794a4f911a198bc54cdbae12f9873f9a1d38396093463ed9f568369a9f6e1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for youvegotdata-2.1.0.tar.gz:

Publisher: package-and-publish.yaml on CIRA-GEOIPS/youvegotdata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file youvegotdata-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: youvegotdata-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for youvegotdata-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 221120ec0b77e667197d2b1c4afdcc1f4aa7fc1cfd3cb44836a379d43a2ed7e5
MD5 4c58e50d9d70094c4b1417b4e7d69ddc
BLAKE2b-256 91af95d36e89664d2fbe96df729185d35e55f1e6dba26ae3bfa64e9a930a7711

See more details on using hashes here.

Provenance

The following attestation bundles were made for youvegotdata-2.1.0-py3-none-any.whl:

Publisher: package-and-publish.yaml on CIRA-GEOIPS/youvegotdata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 files

2.0.0

2 files

1.1.4

2 files

1.1.1

2 files

1.0.1

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page