Coder Social home page Coder Social logo

aporia-ai / mlnotify Goto Github PK

View Code? Open in Web Editor NEW
341.0 5.0 19.0 10.46 MB

๐Ÿ”” No need to keep checking your training - just one import line and you'll know the second it's done.

Home Page: https://mlnotify.aporia.com

License: MIT License

Makefile 2.80% Shell 0.05% Python 25.95% JavaScript 6.25% TypeScript 23.53% Vue 40.93% SCSS 0.49%
ml machine-learning machinelearning machinelearning-python data-science deep-learning deeplearning notifications notification python

mlnotify's Introduction

ML Notify

SDK Build SDK Build License Issues Last Commit Downloads

No need to keep checking your training. Add just 1 import line and MLNotify will let you know the second it's done.

Features:

  • Just pip install mlnotify and import mlnotify to get started
  • Out-of-the-box email & push notifications on desktop, mobile
  • Support for most major ML frameworks (as in Keras, LightGBM, SKLearn, XGBoost, Tensorflow)
  • A simple & intuitive UX
  • Fully secure - no sensitive data leaves your machine (only training start time / end time)

Made with โค๏ธ by Aporia

ML Notify

Quickstart

pip3 install mlnotify
# STEP 1: Import package
import mlnotify

# STEP 2: Do your thing.
my_model.fit(...)

# STEP 3: Browse to mlnotify.com and get notified when training is done!

The import will automagically hook into your fit/train method.

  • Once you start training your model a tracking url & QR code will be printed to the console. Printed tracking URL & QR code
  • Enter the tracking url
  • Grab a coffee and relax, the tracking url will notify you when the training is complete via desktop, mobile, or email notifications

Usage

Simple

import mlnotify

This will automagically hook into your fit/train method.

Supported ML frameworks:

Jupyter Notebook

import mlnotify

And in any Jupyter cell:

%%notify
...

Works with line magic, too

%notify your_code()

Manual

The library also exports a manual API to be used if you want to do it manually.

import mlnotify

mlnotify.start() # Start tracking
# ...
mlnotify.end() # End tracking

Advanced

The library uses a simple plugin architecture. You can register your own plugins to extend the library's functionality.

from mlnotify import BasePlugin, plugin_manager

# A plugin is simply a class with `before` and `after` methods
class MyPlugin(BasePlugin):
    def before(self, *args, **kwargs):
        # Called before the fit/train method
        print("MyPlugin: training started")

    def after(self, *args, **kwargs):
        # Called after the fit/train method
        print("MyPlugin: training finished")

plugin_manager.register_plugin(MyPlugin())

# Use mlnotify as you normally would
model.fit(...)

API

The library exports four items:

from mlnotify import start, end, plugins_manager, BasePlugin

start() -> None

Starts tracking.

end() -> None

Ends tracking.

plugins_manager: PluginsManager

The class handling all plugin registration and invocation. Methods:

  • plugins_manager.register_plugin(plugin: BasePlugin) -> None

    Registers a plugin.

  • plugins_manager.clear_plugins() -> None

    Removes all registered plugins.

Security

No sensitive data is sent to the MLNotify server - only training start & end time.

Contribution, self-deployment & local development

Contributions and self-deployments are more than welcome.

Website & API

This project relies heavily on SaaS products, and must receive proper config for Netlify, Firebase and SendGrid for it to work. You can run this project locally using the Netlify CLI:

  • Make sure you installed the Netlify CLI globally: npm install -g netlify-cli
  • You must have the following environment variables set:
    • FIREBASE_SERVER_CERT - a stringified JSON containing the firebase server config (it contains the following keys: {type, project_id, private_key_id, private_key, client_email, client_id, auth_uri, token_uri, auth_provider_x509_cert_url, client_x509_cert_url})
    • GRIDSOME_FIREBASE_APP_CONFIG - a stringified JSON containing the firebase client config (it contains the following keys: {apiKey, projectId, messagingSenderId, appId})
    • SENDGRID_API_KEY - a string containing the SendGrid API Key
  • cd website
  • netlify dev

SDK

  • pip install ./sdk
  • Write a python file using the SDK and just import mlnotify

License

FOSSA Status

mlnotify's People

Contributors

alongubkin avatar nicarod avatar pragyansubedi avatar snirshechter avatar yanivd avatar yanivzoh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mlnotify's Issues

Runtime estimation

When I'm training a model using keras, I always calculate the runtime by hand (Using the estimated time per epoch)
It would be great if when I use mlnotify the estimated runtime will appear too (next to the time since the start of training)
You can do that using the ETA provided by keras times the number of epochs.

[BUG] If a task is interrupted before mlnotify.end() is called, it runs forver

I had to kill a task since it was going to take too long - mltnoify will run forever unless I remember to manually call mlnotify.end(). Forgetting to call end() also prevents me from calling start() - it prints the warning "before hook was already called", which is not the most informative and doesn't tell me that it actually failed to start a new counter. Maybe it should suggest calling mlnotify.end() instead?

[FEATURE] Run start() without printing QR code

Working in a jupyter notebook, I naturally click on the link instead of scanning the QR code, so it would be nice to have a way to have it hidden by default. The mltnotify timer's page conveniently has the QR code already there, so if I need it I can still find it.

[FEATURE] SDK keep-alive machanism

Is your feature request related to a problem? Please describe.
If for some reason the SDK cannot send a "training-end" request (i.e offline or error), the training will never be finished and the user will never get a notification.

Describe the solution you'd like
The SDK should have a keep-alive mechanism and send a ping every ~1min to the server to show it is active. After ~5min of inactivity, the training should fail.

This feature also requires a fail UI and notification.

Error when training the same model few times

My notebook : https://colab.research.google.com/drive/1yTwFNn0QbQKYT7o4_ZrkxsCdSGWtAP7G?usp=sharing

Error:
TypeError: set_model() missing 1 required positional argument: 'model'

To Reproduce
open a notebook in google colab
import the latest version of tensorflow 2.6
import mlnotify
build a Sequential model and save to the variable model
compile the model
train and save a variable history(a=model.fit) (everything was going good)
train again and save to another variable(b=model.fit)
now you get an error

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: windows 10
  • Browser: brave
  • accelerator: TPU (free version of colab)

Additional context
Add any other context about the problem here.
Full Error:
TypeError Traceback (most recent call last)
in ()
----> 1 history2 = model.fit(x=trainx, y=trainy, batch_size=64, epochs=20, callbacks=tf.keras.callbacks.TensorBoard)

3 frames
/usr/local/lib/python3.7/dist-packages/mlnotify/hooks.py in base_patch_func(__original_func, __before, __after, *args, **kwargs)
30 logger.debug("Failed to run hook function (before)", exc_info=True)
31
---> 32 res = __original_func(*args, **kwargs)
33
34 try:

/usr/local/lib/python3.7/dist-packages/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing)
1157 verbose=verbose,
1158 epochs=epochs,
-> 1159 steps=data_handler.inferred_steps)
1160
1161 self.stop_training = False

/usr/local/lib/python3.7/dist-packages/keras/callbacks.py in init(self, callbacks, add_history, add_progbar, model, **params)
208
209 if model:
--> 210 self.set_model(model)
211 if params:
212 self.set_params(params)

/usr/local/lib/python3.7/dist-packages/keras/callbacks.py in set_model(self, model)
283 model.history = self._history
284 for callback in self.callbacks:
--> 285 callback.set_model(model)
286
287 def _call_batch_hook(self, mode, hook, batch, logs=None):

TypeError: set_model() missing 1 required positional argument: 'model'

[FEATURE] Trainings cleanup

Is your feature request related to a problem? Please describe.
Currently, all ended trainings are manually deleted by me. This should be automatic.

Describe the solution you'd like
A Github action CRON which runs a script once a day to delete all old trainings (i.e endedAt more than a week ago or so).

[FEATURE] New plugins and plugin improvements

Notify plugin improvements

Allow subscribing to the training via push notifications without entering the tracking URL:

  • Website: Add the user's push notifications token to the UI and allow to copy it
  • NotifyPlugin: allow passing that token as an argument and POSTing it to the training-start function
  • training-start should automatically subscribe that token to the specific training, thus subscribing the user's device without him needing to enter the tracking url.

SMS plugin

A plugin which sends an SMS on training end

  • Create a plugin which receives an array of numbers and POSTs a netlify function when done
    Code example:
plugins_manager.register_plugin(SmsPlugin(phones=["..."]))
  • Create a netlify function to send an SMS regarding a finished training
    • Args: trainingId, startedAt, endedAt
    • Returns: 200 OK
  • Website: The email section in the training page should have another tab for entering a phone number

Email plugin

A plugin which sends an Email on training end

  • Create a plugin which receives an array of emails and POSTs a netlify function when done
    Code example:
plugins_manager.register_plugin(EmailPlugin(emails=["..."]))
  • Create a netlify function to send an Email regarding a finished training
    • Args: trainingId, startedAt, endedAt
    • Returns: 200 OK

[FEATURE] Jupyter notebook magic command

Is your feature request related to a problem? Please describe.
When using a Jupyter notebook, it'd be nice to just use a magic command instead of importing mlnotify.

Describe the solution you'd like
%%mlnotify

[FEATURE] Enable custom title

Is your feature request related to a problem? Please describe.
As the library is useful for other processes as well, not only training, it would be useful to enable title modifications

Describe the solution you'd like
Implement a function set_title(custom_title) that replaces custom title, (e.g. Waiting my custom process to complete")

[BUG] PWA - duplicate notifications

Describe the bug
When installing the application after allowing notifications, the notifications are sent twice: once via the PWA and once via Chrome.

To Reproduce
Steps to reproduce the behavior:

  1. Start a training
  2. Go to the training page and allow notifications
  3. Install the application as a PWA
  4. End the training

Two notifications will be sent.
Expected behavior
There should only be one notification - the PWA's.

Possible solutions
We should check of a way to disable notifications and do it upon installing the application and/or add a button for users.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.