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="VIIRS",
    version="1.0",
    start_time="2024-01-01T00:00:00",
    end_time="2024-01-01T01:00:00",
    length=1024,
    checksum="abc123",
    checksum_type="md5",
)
send_notification(notification, config)

Only filepath is required; the rest default to None.

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 CHECKSUM_TYPE] 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.0.0.tar.gz (22.2 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.0.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for youvegotdata-2.0.0.tar.gz
Algorithm Hash digest
SHA256 7fe1a6dd9aec5cefb3011ed380ce38194949dd0d011f89ebc8db8a68f22b890b
MD5 67c8d9c5027f176ed3373f57450754ec
BLAKE2b-256 b5644fb8f7c19708975753c0a716a4849aee1395cb803e72c4ceb773e5ca3bfd

See more details on using hashes here.

Provenance

The following attestation bundles were made for youvegotdata-2.0.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.0.0-py3-none-any.whl.

File metadata

  • Download URL: youvegotdata-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc398889e57e29bd81f14b019451a14c617a735e6af3013754c344ef2992655a
MD5 03e158ae4ddf9bfd202e9f99ec050397
BLAKE2b-256 e5bea5b7cdd19abe0450d8e3830fb7a98cf3b912e7be6d11e20e13232a114e95

See more details on using hashes here.

Provenance

The following attestation bundles were made for youvegotdata-2.0.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

2.1.0

2 files

This release

2.0.0 This release

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