A collection of usefull hydra callbacks for hydra configuration
Project description
Hydra Callbacks
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 🌟
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
hydra-callbacks-0.5.1.tar.gz
(17.6 kB
view details)
Built Distribution
File details
Details for the file hydra-callbacks-0.5.1.tar.gz
.
File metadata
- Download URL: hydra-callbacks-0.5.1.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7feac413aa7b2d41304e2762b785a8cca9952d6e65949e634874557002f2a0eb |
|
MD5 | 36476786efcd17945078260fc61e4e30 |
|
BLAKE2b-256 | 828a3ec3301f7080d5506f587f8073362debcc26d29578236bad92d15363b83f |
File details
Details for the file hydra_callbacks-0.5.1-py3-none-any.whl
.
File metadata
- Download URL: hydra_callbacks-0.5.1-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcec80604ffe2814b46afa4bd5bff4af819111c97e08372c4151205345d242df |
|
MD5 | 9cb0323d804b4084284bb17bedcc0266 |
|
BLAKE2b-256 | f7363a2cb7322ab1024dddce1807e34178c32fc9002ea82fd53fe284f94393fb |