Skip to content

Commit

Permalink
[v1.0.51] added jupyter magic support (#51)
Browse files Browse the repository at this point in the history
* added jupyter magic support %%notify

* Add the %%notify Jupyter command

* Add Jupyter magic command docs

* updated readme

Co-authored-by: Cizin <[email protected]>
Co-authored-by: Snir Shechter <[email protected]>
  • Loading branch information
3 people authored and camparibot committed Oct 27, 2021
1 parent 436122c commit 2abb7c3
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ my_model.fit(...)
```

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](docs/assets/printed-tracking-url-and-qr-code.png)
- Enter the tracking url
Expand All @@ -73,6 +74,22 @@ Supported ML frameworks:
- [Tensorflow](https://www.tensorflow.org/)
- [Catboost](https://catboost.ai/)

### 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.
Expand Down Expand Up @@ -111,12 +128,15 @@ model.fit(...)
## API

The library exports four items:

```python
from mlnotify import start, end, plugins_manager, BasePlugin
```

### `start() -> None`

Starts tracking.

### `end() -> None`

Ends tracking.
Expand All @@ -135,10 +155,13 @@ Methods:
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:
Expand Down
2 changes: 1 addition & 1 deletion sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "No need to keep checking your training. Add just 1 import line an
homepage = 'https://mlnotify.aporia.com'
name = "mlnotify"
repository = "https://github.com/aporia-ai/mlnotify"
version = "v1.0.50"
version = "v1.0.51"

[tool.poetry.dependencies]
python = "^3.6"
Expand Down
9 changes: 9 additions & 0 deletions sdk/src/mlnotify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@
start = plugin_manager.run_before
end = plugin_manager.run_after


try:
from mlnotify.jupyter_magic import register_jupyter_magic
register_jupyter_magic()
except:
# Not in jupyter notebook
pass


__all__ = [start, end, plugin_manager, BasePlugin]
19 changes: 19 additions & 0 deletions sdk/src/mlnotify/jupyter_magic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from IPython.core.magic import Magics, magics_class, line_cell_magic
from mlnotify.mlnotify import plugin_manager

# Jupyter line and cell magic
@magics_class
class MLNotifyMagic(Magics):
@line_cell_magic
def notify(self, line, cell=None):
plugin_manager.run_before()
self.shell.run_cell(line)
if cell is not None:
self.shell.run_cell(cell)
plugin_manager.run_after()


def register_jupyter_magic():
ipython = get_ipython()
ipython.register_magics(MLNotifyMagic)

0 comments on commit 2abb7c3

Please sign in to comment.