Skip to main content

Shared Utility Functions for Indicators

Project description

Delphi Python Utilities

This package provides various utilities used by the Delphi group at Carnegie Mellon University for its data pipelines and analyses.

Submodules:

  • archive: Diffing and archiving CSV files.
  • export: DataFrame to CSV export.
  • geomap: Mappings between geographic resolutions.
  • logger: Structured JSON logger.
  • nancodes: Enum constants encoding not-a-number cases.
  • runner: Orchestrator for running an indicator pipeline.
  • signal: Indicator (signal) naming.
  • slack_notifier: Slack notification integration.
  • smooth: Data smoothing functions.
  • utils: JSON parameter interactions.
  • validator: Data sanity checks and anomaly detection.

Source code can be found here: https://github.com/cmu-delphi/covidcast-indicators/

Logger Usage

To make our structured logging as useful as it can be, particularly within the context of how we use logs in Elastic, the event argument (typically the first unnamed arg) should be a static string (to make filtering easier), and each dynamic/varying value should be specified in an individual meaningfully- and consistently-named argument to the logger call (for use in filtering, thresholding, grouping, visualization, etc).

Commonly used argument names:

  • data_source
  • geo_type
  • signal
  • issue_date
  • filename

Single-thread usage.

from delphi_utils.logger import get_structured_logger

logger = get_structured_logger('my_logger')
logger.info('Hello', name='World')

Multi-thread usage.

from delphi_utils.logger import get_structured_logger, pool_and_threadedlogger

def f(x, threaded_logger):
    threaded_logger.info(f'x={x}')
    return x*x

logger = get_structured_logger('my_logger')
logger.info('Hello, world!')
with pool_and_threadedlogger(logger, n_cpu) as (pool, threaded_logger):
    for i in range(10):
        pool.apply_async(f, args=(i, threaded_logger))

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

delphi_utils-0.3.27.tar.gz (80.6 MB view details)

Uploaded Source

Built Distribution

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

delphi_utils-0.3.27-py3-none-any.whl (4.2 MB view details)

Uploaded Python 3

File details

Details for the file delphi_utils-0.3.27.tar.gz.

File metadata

  • Download URL: delphi_utils-0.3.27.tar.gz
  • Upload date:
  • Size: 80.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for delphi_utils-0.3.27.tar.gz
Algorithm Hash digest
SHA256 f68e6977dadfd8b003dfe597cfaf554796e67b950dadae50cc68d664b02ecc42
MD5 4b160da450a8dd9de5ca7a6f320ee234
BLAKE2b-256 8d9268ff6e7bfbfdce196fd93ed7f6b2630ddadc3cdb83887731a50d0c4ad250

See more details on using hashes here.

File details

Details for the file delphi_utils-0.3.27-py3-none-any.whl.

File metadata

  • Download URL: delphi_utils-0.3.27-py3-none-any.whl
  • Upload date:
  • Size: 4.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for delphi_utils-0.3.27-py3-none-any.whl
Algorithm Hash digest
SHA256 b7e6261c8a8e0a31a6ff9a4668126b2415f1650909955b0ec25a2621725c2cb8
MD5 6f70b4216619fd4584959711300121a0
BLAKE2b-256 4f281f62e241c921afe68107870b5fdd26b2e18b53408ccdca994736322fb9c1

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