Skip to content

Commit 534494d

Browse files
committed
Auto enable extension when install this package
1 parent 9e420ca commit 534494d

File tree

3 files changed

+49
-11
lines changed

3 files changed

+49
-11
lines changed

README.rst

+22-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A jupyter server extension for jupyter notebook and tensorboard (a visualization
1010
Installation
1111
------------
1212

13-
#. Be sure that tensorflow(-gpu)>=1.3.0 has been installed. If not, you should install or upgrade your tensorflow>=1.3.0 first, and tensorbaord is a dependency of tensorflow so that it is automatically installed. This package does not have a tensorbaord or tensorflow dependency because there are several versions of tensorflow, for example, tensorflow and tensorflow-gpu, if jupyter_tensorboard requires any version of the tensorflow, it will install the version and abrupt the environment. Any way, you must be sure you have tensorflow(-gpu) installed before install this package.
13+
#. Be sure that tensorflow(-gpu)>=1.3.0 has been installed. If not, you should install or upgrade your tensorflow>=1.3.0 first, and tensorboard is a dependency of tensorflow so that it is automatically installed. This package does not have a tensorboard or tensorflow dependency because there are several versions of tensorflow, for example, tensorflow and tensorflow-gpu, if jupyter_tensorboard requires any version of the tensorflow, it will install the version and abrupt the environment. Any way, you must be sure you have tensorflow(-gpu) installed before install this package.
1414

1515
#. Install the pip package. The python version must be the same as Jupyter: if you start jupyter notebook in python3, ``pip3`` may be used to install the package
1616

@@ -20,13 +20,6 @@ Installation
2020

2121
The python version are important, you must be sure that your *jupyter*, *jupyter_tensorboard*, *tensorflow* have the same python version. If your tensorflow python and jupyter python versions are different, e.g., use tensorflow in py2 but jupyter starts in py3, both versions of tensorflow(py2 and py3) should be installed, and jupyter_tensorboard should install to py3, in accordance with jupyter.
2222

23-
#. Enabling the notebook server to load the server extension. A `jupyter` subcommand is provided for this. You can enable the serverextension and the configurator nbextensions listed below for the current user with
24-
25-
``jupyter tensorboard enable --user``
26-
27-
28-
The command accepts the same flags as the ``jupyter serverextension`` command provided by notebook versions >= 5.0, including ``--system`` to enable in system-wide config (the default), or ``--sys-prefix`` to enable in config files inside python's ``sys.prefix``, such as for a virtual environment. The provided ``jupyter tensorboard`` command can also be used to ``disable``.
29-
3023
#. Restart the jupyter notebook server.
3124

3225

@@ -39,18 +32,37 @@ Once `jupyter_tensorboard` is installed and enabled, and your notebook server ha
3932

4033
.. image:: https://github.com/lspvic/jupyter_tensorboard/raw/master/docs/_static/tensorboard_button.png
4134

42-
- In notebook tree view, click the ``tensorbaord`` menu in ``new`` and a new tensorbaord instance is started with current directory as logdir.
35+
- In notebook tree view, click the ``tensorboard`` menu in ``new`` and a new tensorboard instance is started with current directory as logdir.
4336

4437
.. image:: https://github.com/lspvic/jupyter_tensorboard/raw/master/docs/_static/tensorboard_menu.png
4538

4639
- In notebook ``running`` tab, a list of tensorboard instances are showed. Managing operations such as browsing, navigating, shutdown can be found here.
4740

4841
.. image:: https://github.com/lspvic/jupyter_tensorboard/raw/master/docs/_static/tensorboard_list.png
4942

50-
- The tensorbaord instance interface is in ``http://jupyter-host/tensorboard/<name>/`` with the instance names increasing from 1.
43+
- The tensorboard instance interface is in ``http://jupyter-host/tensorboard/<name>/`` with the instance names increasing from 1.
5144

5245
.. image:: https://github.com/lspvic/jupyter_tensorboard/raw/master/docs/_static/tensorboard_url.png
5346

47+
Uninstall
48+
---------
49+
To purge the installation of the extension, there are a few steps to execute:
50+
51+
.. code:: bash
52+
53+
jupyter tensorboard disable --user
54+
pip uninstall jupyter-tensorboard
55+
56+
or if you have uninstall the pip package, but the extension seems to be not purged, you can execute:
57+
58+
.. code:: bash
59+
60+
jupyter serverextension disable --user
61+
jupyter nbextension disable jupyter_tensorboard/tree --user
62+
jupyter nbextension uninstall jupyter_tensorboard --user
63+
64+
The commands accept the same flags as the ``jupyter serverextension`` command provided by notebook versions, including ``--system`` to enable(or disable) in system-wide config, or ``--sys-prefix`` to enable(or disable) in config files inside python's ``sys.prefix``, such as for a virtual environment.
65+
5466
Troubleshooting
5567
---------------
5668

setup.py

+27
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import io
66
import re
77
from setuptools import setup
8+
from setuptools.command.install import install
9+
from setuptools.command.develop import develop
810

911

1012
def read(*names, **kwargs):
@@ -24,6 +26,27 @@ def find_version(*file_paths):
2426
raise RuntimeError("Unable to find version string.")
2527

2628

29+
def enable_extension_after_install():
30+
from jupyter_tensorboard.application import (
31+
EnableJupyterTensorboardApp,
32+
)
33+
EnableJupyterTensorboardApp.launch_instance(argv=[])
34+
35+
36+
class EnableExtensionDevelop(develop):
37+
38+
def run(self):
39+
develop.run(self)
40+
enable_extension_after_install()
41+
42+
43+
class EnableExtensionInstall(install):
44+
45+
def run(self):
46+
install.run(self)
47+
enable_extension_after_install()
48+
49+
2750
name = 'jupyter_tensorboard'
2851

2952
setup(
@@ -64,4 +87,8 @@ def find_version(*file_paths):
6487
'Programming Language :: Python :: 3.5',
6588
'Programming Language :: Python :: 3.6',
6689
],
90+
cmdclass={
91+
'install': EnableExtensionInstall,
92+
'develop': EnableExtensionDevelop,
93+
},
6794
)

tox.ini

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ deps =
77
tensorflow13: tensorflow>=1.3, <1.4
88

99
commands =
10-
jupyter tensorboard enable --user
1110
pytest
1211

1312
alwayscopy = True

0 commit comments

Comments
 (0)