Hydrogen: ability to define watchers in source

Created on 10 Feb 2017  路  3Comments  路  Source: nteract/hydrogen

It would be really nice to, instead of adding them manually using the GUI, add watchers in the source code, similar to how you can add code cells in the source code. e.g.:

# %%
%reload_ext autoreload
%autoreload 2
%matplotlib inline

import numpy
import matplotlib.pyplot as plt

data = numpy.random.rand(3, 3)

#watch: plt.show(data)

This has been added to the Hydrogen Wiki Plugins. If you close this issue please remove it from the Hydrogen Wiki.

enhancement help wanted plugin-idea

Most helpful comment

I think this could be doable as a "macro" that adds watches based on some addition to the # %% cell methodology. This seems like a great idea for a hydrogen plugin so that it can be used/maintained by those who desire the feature (including me).

I have a minimal concept implemented as a hydrogen plugin, but it requires a small change to hydrogen's watch module. I'll try to post more on this soon.

My first thought is, when should the file be parsed for possible watch statements?

@lgeiger I was thinking as part of run-cell, but modified by a method inside the mentioned plugin.

All 3 comments

Definitely a interesting idea though not trivial.

Could you elaborate a bit more? What would the desired workflow be?
My first thought is, when should the file be parsed for possible watch statements?

The idea is to have different watchers in different cells and files and to show them accordingly whenever you execute a cell

E.g. if you need to work on a different project or go home for the day, the next day all your watchers are gone. Or you switch between two cells and need to manually change watchers every time you do.

It is probably non-trivial to add or even replace watchers when you execute a different cell.

I think this could be doable as a "macro" that adds watches based on some addition to the # %% cell methodology. This seems like a great idea for a hydrogen plugin so that it can be used/maintained by those who desire the feature (including me).

I have a minimal concept implemented as a hydrogen plugin, but it requires a small change to hydrogen's watch module. I'll try to post more on this soon.

My first thought is, when should the file be parsed for possible watch statements?

@lgeiger I was thinking as part of run-cell, but modified by a method inside the mentioned plugin.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

olegantonyan picture olegantonyan  路  3Comments

HaoranXue picture HaoranXue  路  4Comments

danbri picture danbri  路  4Comments

DannyDannyDanny picture DannyDannyDanny  路  3Comments

ekoepplin picture ekoepplin  路  4Comments