zincware / ZnTrack

Create, visualize, run & benchmark DVC pipelines in Python & Jupyter notebooks.
https://zntrack.readthedocs.io
Apache License 2.0
44 stars 4 forks source link

send notification once a stage has finished #796

Open PythonFZ opened 2 months ago

PythonFZ commented 2 months ago

It would be handy to get some information once a stage has successfully finished. This could include

The configuration should be handled via a file, e.g. .zntrack/config.yaml with a notification section.

MrJulEnergy commented 2 months ago

Sending an EMail seems to be a dead an since we either need to use an existing EMail account (for example gmail) and then store a password and username somewhere, or alternativly host our own smtp server, which isnt as simple as it sounds

MrJulEnergy commented 2 months ago

797 Tries to add a method of storing sensitive data

MrJulEnergy commented 2 months ago

I wrote the following Node which can send an Notification to a Discord server when given an webhook_url. Note that zntrack.local_config() isnt currently implemented in ZnTrack

class NotifyMe(zntrack.Node):
    webhook_url = zntrack.local_config()
    previus_node = zntrack.deps()

    def run(self):
            try:
                node_name = self.previus_node.name
                time = datetime.now().strftime("%H:%M:%S")
                day = datetime.now().strftime("%B %d. %Y")
                msg = {"content": f"Your Workflow has reached {node_name} at {time} on {day}!"}
            except AttributeError:
                msg = {"content": f"Your Workflow has reached this Node at at {time} on {day}!"}

            response = requests.post(self.webhook_url, json=msg)

            if response.status_code == 204:
                pass
            else: 
                raise Exception("Could not send Message")
PythonFZ commented 2 months ago

Maybe something like https://github.com/caronc/apprise