Skip to main content

Hydra Callbacks

style framework codecov CD CI Release

A collection of usefulls and simple to use callbacks for the https://hydra.cc/ configuration framework.

Installation

pip install hydra-callbacks

Development version

pip install git+https://github.com/paquiteau/hydra-callbacks

Usage

In your hydra root config file add the following, or analoguous:

hydra:
  callbacks:
    git_infos:
      _target_: hydra_callbacks.GitInfo
      clean: true
    latest_run:
      _target_: hydra_callbacks.LatestRunLink
    resource_monitor:
      _target_: hydra_callbacks.ResourceMonitor
      sample_interval: 0.5
    runtime_perf:
      _target_: hydra_callbacks.RuntimePerformance      

This will enrich your script output with:

paquiteau@laptop$ python my_app.py
[hydra] Git sha: 844b9ca1a74d8307ef5331351897cebb18f71b88, dirty: False

## All your app log and outputs ##

[hydra][INFO] - Total runtime: 0.51 seconds
[hydra][INFO] - Writing monitoring data to [...]/outputs/2023-04-06/16-02-46/resource_monitoring.csv
[hydra][INFO] - Latest run is at: [...]/outputs/latest

Detailled configuration for each callback is available in the tests/test_app/ folder.

Available Callbacks

Name Action
GitInfo Check status of Repository
LatestRunLink Get a link to the latest run
MultiRunGatherer Gather results json file in a single table
RuntimePerformance Get Execution time for each run
ResourceMonitor Monitor resources of running jobs (CPU and Memory)

And more to come !

Also Available

  • PerfLogger : A simple to use performance logger
  
from hydra_callbacks import PerfLogger 
import logging

log = logging.getLogger(__name__)
def main_app(cfg):
    with PerfLogger(log, "step1"):
        sleep(1)

    with PerfLogger(log, "step2"):
        sleep(2)
    PerfLogger.recap(log)
  • RessourceMonitorService : A simple CPU and GPU usage and memory sampler. It launches an extra process to monitor everything.
from hydra_callbacks.monitor import RessourceMonitorService
import os 

monitor = RessourceMonitorService(interval=0.2, gpu_monit=True)

monitor.start()
# Launch heavy stuff 
metrics = monitor.stop()

# Or use it as a context manager
with RessourceMonitorService(interval=0.2, gpu_monit=True) as monitor: 
   # launch heavy stuff
   
metrics_values = monitor.get_values()

You too, have cool Callbacks, or idea for one ?

Open a PR or an issue !

Possible Ideas

  • A callback that summarize log from multiple runs
  • Monitoring of GPU using nvitop

:star2: If you like this work, don't forget to star it and share it 🌟

Metadata

Release files for hydra-callbacks 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hydra-callbacks 0.6.1
File Size Uploaded
hydra_callbacks-0.6.1.tar.gz 18.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hydra-callbacks 0.6.1
File Interpreter ABI Platform
hydra_callbacks-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 30.4 kB

Release files / hydra_callbacks-0.6.1.tar.gz

Download URL hydra_callbacks-0.6.1.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
24bc3adaf6d328966b8baa0fc5ea22357c86ea332a57408858ddca068e2e0f99
BLAKE2b-256 checksum
How to use checksums
59812c73ffba354d5aa9144431033a548d497586f71c631254a4883fb498c787
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / hydra_callbacks-0.6.1-py3-none-any.whl

Download URL hydra_callbacks-0.6.1-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90cdb8f0e9cea500a6f0b25d86af46d65606f5b20138aea259b1fc58cf615db3
BLAKE2b-256 checksum
How to use checksums
c7897d39bb3349ebbf944eceb94410314c24f14b8adcff0c5aeebd671ad848f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.5.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release 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