Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hpprc/deadbeats
☠️ Easy to use slack messaging library ☠️
https://github.com/hpprc/deadbeats
heartbeat python research slack
Last synced: 10 days ago
JSON representation
☠️ Easy to use slack messaging library ☠️
- Host: GitHub
- URL: https://github.com/hpprc/deadbeats
- Owner: hppRC
- License: mit
- Created: 2020-10-29T15:12:31.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-07T07:08:34.000Z (over 3 years ago)
- Last Synced: 2024-10-09T23:07:14.535Z (27 days ago)
- Topics: heartbeat, python, research, slack
- Language: Python
- Homepage: https://pypi.org/project/deadbeats/
- Size: 205 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DEADBEATS
An easy to use Slack messaging library for research.
## Usage
```python
from deadbeats import DEADBEATS
# set environment variables as below
# SLACK_ACCESS_TOKEN=xxxx-xxxxxxxxxxxxx-xxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx (Get your own Slack API access token)
# SLACK_CHANNEL_ID=deadbeats (set slack channel id whatever you like!)# or you can set configurations manually.
DEADBEATS.set_access_token("SLACK_ACCESS_TOKEN")
DEADBEATS.set_channel_id("SLACK_CHANNEL_ID")# `DEADBEATS.wrap` sends a message at the beginning and the end of the wrapped function.
# `DEADBEATS.wrap` catch every errors and raise it after sending a error message.
@DEADBEATS.wrap
def main():
# A simple "heartbeating" message.
DEADBEATS.ping()# Start threading!
# All subsequent messages will be sent to the thread.
DEADBEATS.start_thread()# You can add extra information like below.
params = {"loss": 0.5, "val_loss": 1.6, "acc": 100.0}
DEADBEATS.ping(text="message whatever you like", params=params, additional="info", huga="huga")# If you want to stop threading, you can use this method.
# This method reset "thread_ts" of a instance variable, which is a id of thread.
DEADBEATS.reset_thread()
```## With PyTorch Lightning
```python
from deadbeats import DEADBEATSclass MyModel(pl.LightningModule):
...
def on_train_start(self):
DEADBEATS.start_thread()...
def validation_epoch_end(self, outputs):
avg_loss = torch.stack([x['val_loss'] for x in outputs]).mean()DEADBEATS.ping(val_loss = avg_loss, current_epoch = self.current_epoch)
return {'val_loss': avg_loss}
...
# custom training function
@DEADBEATS.wrap
def fit(self, trainer):
trainer.fit(self)```
## messages like below
![example](.github/images/example_message.png)
This library is named after the wonderful work of [Mori Calliope](https://www.youtube.com/channel/UCL_qhgtOy0dy1Agp8vkySQg), [DEAD BEATS](https://youtu.be/6ydgEipkUEU), and inspired by [hugginface/knockknock](https://github.com/huggingface/knockknock).