Skip to content

Commit

Permalink
Show tensorboard (#272)
Browse files Browse the repository at this point in the history
* start tb in init

* .

* .

* .

* .

* .

* .

* .

* Remove trainer.tb_writer, only use a single tb_writer

* Testing more stuff

* Revert

* Revert "Remove trainer.tb_writer, only use a single tb_writer"

This reverts commit 41bd0c4.

* Add tensorboard button to train dialogue

* Add tensorboard button to train dialogue

* Add tensorboard button to train dialogue

* Add tensorboard button to train dialogue

* Update poetry.lock and pyproject.toml to add psutil

* some i18n to replace

Co-authored-by: mattchrlw <mattchrlw@gmail.com>
  • Loading branch information
benfoley and mattchrlw committed Dec 6, 2021
1 parent 5019de9 commit 89b0327
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 9 deletions.
26 changes: 21 additions & 5 deletions elpis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
from pathlib import Path
from requests import get
from dotenv import load_dotenv

from tensorboard import program
import psutil
from werkzeug.serving import is_running_from_reloader

def create_app(test_config=None):
# Called by the flask run command in the cli.
Expand Down Expand Up @@ -67,10 +69,6 @@ def create_app(test_config=None):
app.config['INTERFACE'] = Interface(interface_path)
else:
app.config['INTERFACE'] = Interface(interface_path, use_existing=True)
# app.config['CURRENT_DATASET'] = None # not okay for multi-user
# app.config['CURRENT_PRON_DICT'] = None # not okay for multi-user & need to remove later because it is Kaldi-specific.
# app.config['CURRENT_MODEL'] = None # not okay for multi-user
# app.config['CURRENT_TRANSCRIPTION'] = None # not okay for multi-user

# Developer-friendly mode has convenient interface widgets for setting engine etc
load_dotenv()
Expand All @@ -80,6 +78,24 @@ def create_app(test_config=None):
app.register_blueprint(endpoints.bp)
# print(app.url_map)

if is_running_from_reloader():
# Start Tensorboard if not already running (because Flask init happens twice)
tensorboard_running = False
for proc in psutil.process_iter():
for conns in proc.connections(kind='inet'):
if conns.laddr.port == 6006:
tensorboard_running = True
print('Tensorboard is running on', proc.pid)
if not tensorboard_running:
print('Tensorboard is not running, start it')
tensorboard = program.TensorBoard()
tensorboard.configure(argv=['tensorboard',
'--logdir=/state/models',
'--port=6006',
'--host=0.0.0.0'])
url = tensorboard.launch()
print(f"Tensorflow listening on {url}")

# the rest of the routes below are for the single file react app.
@app.route('/index.html')
def index_file():
Expand Down
10 changes: 10 additions & 0 deletions elpis/gui/src/components/Model/Train.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class ModelTrain extends Component {
downloadjs(log, "log.txt", "text/txt");
};

handleTensorBoard = () => {
window.open(window.location.protocol + "//" + window.location.hostname + ":6006", "_blank").focus();
}

onScroll = () => {};

follow = () => {};
Expand Down Expand Up @@ -184,6 +188,12 @@ class ModelTrain extends Component {
>
{t("model.train.logButton")}
</Button>
<Button
onClick={this.handleTensorBoard}
disabled={!name}
>
{t("model.train.tensorboardButton")}
</Button>
</Segment>
)}
</>
Expand Down
3 changes: 2 additions & 1 deletion elpis/gui/src/translations/en-GB/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@
"logsDescription": "gory detail from Kaldi (coming soon)",
"trainButton": "Start training",
"statusButton": "Check progress",
"logButton": "Download logs"
"logButton": "Download logs",
"tensorboardButton": "View progress in TensorBoard"
},
"results": {
"title": "Results",
Expand Down
4 changes: 3 additions & 1 deletion elpis/gui/src/translations/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@
"logsHeader": "Journalisation",
"logsDescription": "Détail sanglain pour Kaldi (arrivée prochaine)",
"trainButton": "Démarrer l’entraînement",
"statusButton": "Voir l’avancement"
"statusButton": "Voir l’avancement",
"logButton": "Download logs",
"tensorboardButton": "View progress in TensorBoard"
},
"results": {
"title": "Résultats",
Expand Down
4 changes: 3 additions & 1 deletion elpis/gui/src/translations/hin/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@
"logsHeader": "लॉग्स",
"logsDescription": "कलदी से घमासान विवरण (जल्द ही आ रहा है)",
"trainButton": "प्रशिक्षण शुरू करें",
"statusButton": "प्रगति की जाँच करें"
"statusButton": "प्रगति की जाँच करें",
"logButton": "Download logs",
"tensorboardButton": "View progress in TensorBoard"
},
"results": {
"title": "परिणाम",
Expand Down
43 changes: 42 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ numba = "0.54.0"
python-dotenv = "^0.15.0"
praatio = "^5.0.0"
nltk = "^3.6.5"
psutil = "^5.8.0"

[tool.poetry.dev-dependencies]
pytest = "^6.2.1"
Expand Down

0 comments on commit 89b0327

Please sign in to comment.