Skip to content

Commit

Permalink
fix: GUI when no data was imported
Browse files Browse the repository at this point in the history
- Fix error resulting when no data is imported and `viewer` is triggered first
  • Loading branch information
argysamo committed May 29, 2022
1 parent 227bcc2 commit 875ecc0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
8 changes: 1 addition & 7 deletions bin/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@click.option('--template', required=True,
help='template file to parse data with')
@click.option('--metadata', required=True,
help='configuration file to annotate data with')
help='metadata file to annotate data with')
@click.option('--var', required=False, default="",
help='Extra variables for URI generation')
@click.option('--drop', required=False, default='no',
Expand All @@ -35,11 +35,5 @@ def cli(input_file, template, metadata, var, drop):
resolver.store_timeseries()


def run():
app.jinja_env.auto_reload = True
app.config['TEMPLATES_AUTO_RELOAD'] = True
app.run(host=SERVER['host'], port=SERVER['port'], debug=SERVER['debug'])


if __name__ == '__main__':
cli()
11 changes: 11 additions & 0 deletions bin/viewer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from edam.reader.models.database import recreate_database

from edam import SERVER
from edam.viewer.app.views import app
from edam import database_url
import os


def run():
Expand All @@ -8,5 +12,12 @@ def run():
app.run(host=SERVER['host'], port=SERVER['port'], debug=SERVER['debug'])


def verify_database():
if database_url.drivername == 'sqlite':
if not os.path.isfile(database_url.database):
recreate_database()


if __name__ == "__main__":
verify_database()
run()
6 changes: 5 additions & 1 deletion edam/viewer/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ def about():
@app.route('/graphs')
def graphs():
all_stations = stations() # type: [Station]
metrics = all_stations[0].observable_ids
try:
metrics = all_stations[0].observable_ids
except IndexError:
logger.exception("Exception:")
metrics = []
return render_template('graphs.html', stations=all_stations,
metrics=metrics)

Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pytest==7.1.2
coverage==6.3.2
coverage==6.4
pytest-bdd==5.0.0
pylint==2.13.8
pylint==2.13.9
vcrpy==4.1.1

0 comments on commit 875ecc0

Please sign in to comment.