Skip to content

Commit

Permalink
Merge pull request #31 from ctreffe/develop
Browse files Browse the repository at this point in the history
Small improvements and fixes
  • Loading branch information
jobrachem authored Mar 16, 2020
2 parents 165b101 + fd3608e commit e751115
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions mortimer/web_experiments/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def new_experiment():
'author': current_user.username,
'version': form.version.data,
'type': settings.experiment.type,
'exp_id': exp.id,
'exp_id': str(exp.id),
'qt_fullscreen': settings.experiment.qt_full_screen,
'web_layout': settings.experiment.web_layout
},
Expand Down Expand Up @@ -122,20 +122,20 @@ def experiment(username, exp_title):
datasets = {}

datasets["all_datasets"] = alfred_web_db\
.count_documents({"exp_id": exp.id})
.count_documents({"exp_id": str(exp.id)})

datasets["all_finished_datasets"] = alfred_web_db\
.count_documents({"exp_id": exp.id,
.count_documents({"exp_id": str(exp.id),
"exp_finished": True})

datasets["all_unfinished_datasets"] = datasets["all_datasets"] - datasets["all_finished_datasets"]

datasets["datasets_current_version"] = alfred_web_db\
.count_documents({"exp_id": exp.id,
.count_documents({"exp_id": str(exp.id),
"exp_version": exp.version})

datasets["finished_datasets_current_version"] = alfred_web_db\
.count_documents({"exp_id": exp.id,
.count_documents({"exp_id": str(exp.id),
"exp_version": exp.version,
"exp_finished": True})

Expand All @@ -145,7 +145,7 @@ def experiment(username, exp_title):
versions = {}
all_activity = []
finished = []
cur = alfred_web_db.find({"exp_id": exp.id})
cur = alfred_web_db.find({"exp_id": str(exp.id)})
for single_exp in cur:
all_activity.append(single_exp["start_time"])
if single_exp["exp_version"] not in versions.keys():
Expand Down Expand Up @@ -481,24 +481,24 @@ def web_export(username, experiment_title):

if form.validate_on_submit():
if "all versions" in form.version.data:
results = alfred_web_db.count_documents({"exp_id": experiment.id})
results = alfred_web_db.count_documents({"exp_id": str(experiment.id)})
if results == 0:
flash("No data found for this experiment.", "warning")
return redirect(url_for('web_experiments.web_export', username=experiment.author,
experiment_title=experiment.title))

cur = alfred_web_db.find({"exp_id": experiment.id})
cur = alfred_web_db.find({"exp_id": str(experiment.id)})
else:
for version in form.version.data:
results = []
results.append(alfred_web_db.count_documents({"exp_id": experiment.id,
results.append(alfred_web_db.count_documents({"exp_id": str(experiment.id),
"exp_version": version}))
if max(results) == 0:
flash("No data found for this experiment.", "warning")
return redirect(url_for('web_experiments.web_export', username=experiment.author,
experiment_title=experiment.title))

cur = alfred_web_db.find({"exp_id": experiment.id,
cur = alfred_web_db.find({"exp_id": str(experiment.id),
"exp_version": {"$in": form.version.data}})

none_value = None
Expand Down Expand Up @@ -653,7 +653,7 @@ def experiment_log(username, experiment_title):
if exp.author!= current_user.username:
abort(403)

p = re.compile(r"(?P<date>20.+?) - (?P<module>.+?) - (?P<log_level>.+?) - ((experiment id=)(?P<exp_id>.+?), )?(session id=(?P<session_id>.+?) - )?(?P<message>(.|\s)*?(?=(\d{4}-\d{2}-\d{2}|\Z)))")
p = re.compile(r"(?P<date>20.+?) - (?P<module>.+?) - (?P<log_level>.+?) - ((experiment id=)(?P<exp_id>.+?), )?(session id=(?P<session_id>.+?) - )?(?P<message>(.|\s)*?(?=(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}|\Z)))")
mortimer_path = os.path.abspath(os.path.dirname(sys.argv[0]))
log_path = os.path.join(mortimer_path, "log")
log_file = os.path.join(log_path, "alfred.log")
Expand Down

0 comments on commit e751115

Please sign in to comment.