Skip to content

Commit

Permalink
Merge pull request #114 from DESm1th/0.2.1
Browse files Browse the repository at this point in the history
[ENH] Release v0.2.1
  • Loading branch information
DESm1th authored Apr 15, 2024
2 parents 19939e9 + 4557efe commit 006cf45
Show file tree
Hide file tree
Showing 29 changed files with 210 additions and 199 deletions.
6 changes: 5 additions & 1 deletion containers/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM tigrlab/datman:0.1 as prod
FROM tigrlab/datman:0.2.1 as prod

# NOTE: When building this container, do it from
# inside the dashboard folder and build with
Expand All @@ -12,6 +12,10 @@ COPY containers/entrypoint.sh /entrypoint.sh
# that rebuilds are faster.
COPY ./requirements.txt /

# Install requirements for pip installing uwsgi
RUN apt update && \
apt install -y --no-install-recommends gcc python3.11-dev

RUN pip install --upgrade pip && \
pip install -r /requirements.txt

Expand Down
8 changes: 6 additions & 2 deletions containers/dashboard.env
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ POSTGRES_SRVR=dash_postgres
POSTGRES_USER=dashboard
POSTGRES_DATABASE=dashboard
# POSTGRES_TEST_DATABASE=test_dashboard


# POSTGRES_PORT=5432
# TIMEZONE=-240


Expand Down Expand Up @@ -58,6 +57,11 @@ POSTGRES_DATABASE=dashboard
# DASH_LOG_DIR=


# Menu Configuration
# ------------------
# DASH_MENU_CONFIG=


# Debugging settings
# ------------------
# FLASK_ENV=
Expand Down
5 changes: 1 addition & 4 deletions containers/prod/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ version: '3'
services:
app:
container_name: dashboard
build:
context: ../../
dockerfile: containers/Dockerfile
target: prod
image: tigrlab/dashboard:0.2.1
env_file: ../dashboard.env
ports:
- 5000:5000
Expand Down
2 changes: 1 addition & 1 deletion dashboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def create_app(config=None):

load_blueprints(app)

if app.debug and app.env == 'development':
if app.debug and app.config['ENV'] == 'development':
# Never run this on a production server!
setup_devel_ext(app)

Expand Down
4 changes: 2 additions & 2 deletions dashboard/blueprints/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def study(study_id=None, active_tab=None):
display_metrics = current_app.config['DISPLAY_METRICS']

# get the study object from the database
study = Study.query.get(study_id)
study = db.session.get(Study, study_id)

# this is used to update the readme text file
form = StudyOverviewForm()
Expand Down Expand Up @@ -416,7 +416,7 @@ def analysis(analysis_id=None):
if not analysis_id:
analyses = Analysis.query.all()
else:
analyses = Analysis.query.get(analysis_id)
analyses = db.session.get(Analysis, analysis_id)

for analysis in analyses:
# format the user objects for display on page
Expand Down
6 changes: 3 additions & 3 deletions dashboard/blueprints/redcap/monitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from .emails import missing_session_data
from dashboard.monitors import add_monitor, get_emails
from dashboard.models import Session, User
from dashboard.models import Session, User, db
from dashboard.exceptions import MonitorException
from dashboard.queue import submit_job

Expand Down Expand Up @@ -78,7 +78,7 @@ def check_scans(name, num, recipients=None):
:obj:`dashboard.exceptions.MonitorException`: If a matching session
can't be found.
"""
session = Session.query.get((name, num))
session = db.session.get(Session, (name, num))
if not session:
raise MonitorException("Monitored session {}_{:02d} is no "
"longer in database. Cannot verify whether "
Expand Down Expand Up @@ -151,7 +151,7 @@ def monitor_scan_download(session, end_time=None):


def download_session(name, num, end_time):
session = Session.query.get((name, num))
session = db.session.get(Session, (name, num))
if not session:
raise MonitorException(
"Monitored session {}_{} is no longer in database, aborting "
Expand Down
9 changes: 5 additions & 4 deletions dashboard/blueprints/redcap/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import redcap as REDCAP

from .monitors import monitor_scan_import, monitor_scan_download
from dashboard.models import Session, Timepoint, RedcapRecord, RedcapConfig
from dashboard.models import Session, Timepoint, RedcapRecord, RedcapConfig, db
from dashboard.queries import get_studies
from dashboard.exceptions import RedcapException
import datman.scanid
Expand All @@ -20,7 +20,7 @@ def get_redcap_record(record_id, fail_url=None):
if not fail_url:
fail_url = url_for('main.index')

record = RedcapRecord.query.get(record_id)
record = db.session.get(RedcapRecord, record_id)

if record is None:
logger.error("Tried and failed to retrieve RedcapRecord with "
Expand Down Expand Up @@ -149,7 +149,7 @@ def set_session(name):
name = ident.get_full_subjectid_with_timepoint()
num = datman.scanid.get_session_num(ident)

session = Session.query.get((name, num))
session = db.session.get(Session, (name, num))
if not session:
timepoint = get_timepoint(ident)
session = timepoint.add_session(num)
Expand All @@ -166,7 +166,8 @@ def find_study(ident):


def get_timepoint(ident):
timepoint = Timepoint.query.get(ident.get_full_subjectid_with_timepoint())
timepoint = db.session.get(
Timepoint, ident.get_full_subjectid_with_timepoint())
if not timepoint:
study = find_study(ident)[0]
timepoint = study.add_timepoint(ident)
Expand Down
4 changes: 2 additions & 2 deletions dashboard/blueprints/timepoints/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask_wtf import FlaskForm
from wtforms import SubmitField, TextAreaField, TextField, BooleanField
from wtforms import SubmitField, TextAreaField, StringField, BooleanField
from wtforms.validators import DataRequired


Expand Down Expand Up @@ -43,7 +43,7 @@ class TimepointCommentsForm(FlaskForm):


class NewIssueForm(FlaskForm):
title = TextField(
title = StringField(
"Title: ",
validators=[DataRequired()],
render_kw={'required': True})
Expand Down
5 changes: 3 additions & 2 deletions dashboard/blueprints/timepoints/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import logging

from github import Github

from flask import current_app, flash
from ...models import Study
from ...models import Study, db

logger = logging.getLogger(__name__)

Expand All @@ -22,7 +23,7 @@ def search_issues(token, timepoint):

def handle_issue(token, issue_form, study_id, timepoint):
title = clean_issue_title(issue_form.title.data, timepoint)
study = Study.query.get(study_id)
study = db.session.get(Study, study_id)

staff_member = study.choose_staff_contact()
if staff_member:
Expand Down
25 changes: 12 additions & 13 deletions dashboard/blueprints/users/forms.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
from flask_wtf import FlaskForm

from wtforms import (SubmitField, HiddenField, TextField, FormField,
BooleanField, FieldList, RadioField, SelectMultipleField)
from wtforms.fields.html5 import EmailField, TelField
from wtforms.compat import iteritems
from wtforms import (SubmitField, HiddenField, StringField, FormField,
BooleanField, FieldList, RadioField, SelectMultipleField,
EmailField, TelField)
from wtforms.validators import DataRequired


class UserForm(FlaskForm):
id = HiddenField()
first_name = TextField('First Name: ',
first_name = StringField('First Name: ',
validators=[DataRequired()],
render_kw={
'required': True,
'maxlength': '64',
'placeholder': 'Jane'
})
last_name = TextField('Last Name: ',
last_name = StringField('Last Name: ',
validators=[DataRequired()],
render_kw={
'required': True,
Expand All @@ -34,7 +33,7 @@ class UserForm(FlaskForm):
validators=[DataRequired()],
choices=[('github', 'GitHub')],
default='github')
account = TextField('Username: ',
account = StringField('Username: ',
validators=[DataRequired()],
render_kw={
'required':
Expand All @@ -44,12 +43,12 @@ class UserForm(FlaskForm):
'placeholder':
'Username used on account ' + 'provider\'s site'
})
position = TextField('Position: ',
position = StringField('Position: ',
render_kw={
'maxlength': '64',
'placeholder': 'Job title or position'
})
institution = TextField('Institution: ',
institution = StringField('Institution: ',
render_kw={
'maxlength':
'128',
Expand All @@ -61,7 +60,7 @@ class UserForm(FlaskForm):
'maxlength': '20',
'placeholder': '555-555-5555'
})
ext = TextField('Extension: ',
ext = StringField('Extension: ',
render_kw={
'maxlength': '10',
'placeholder': 'XXXXXXXXXX'
Expand All @@ -71,7 +70,7 @@ class UserForm(FlaskForm):
'maxlength': '20',
'placeholder': '555-555-5555'
})
alt_ext = TextField('Alt. Extension: ',
alt_ext = StringField('Alt. Extension: ',
render_kw={
'maxlength': '10',
'placeholder': 'XXXXXXXXXX'
Expand Down Expand Up @@ -136,7 +135,7 @@ def process(self, formdata=None, obj=None, data=None, **kwargs):
# Temporarily, this can simply be merged with kwargs.
kwargs = dict(data, **kwargs)

for name, field, in iteritems(self._fields):
for name, field, in self._fields.items():
if obj is not None and hasattr(obj, name):
# This if statement is the only change made to the original
# code for BaseForm.process() - Dawn
Expand All @@ -158,7 +157,7 @@ def populate_obj(self, obj):
default with the 'studies' field treated as a special case to
account for the fact that it is a mapped collection
"""
for name, field in iteritems(self._fields):
for name, field in self._fields.items():
if name == 'studies':
for study_form in self.studies.entries:
if study_form.site_id.data == '':
Expand Down
10 changes: 5 additions & 5 deletions dashboard/blueprints/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from . import user_bp
from .utils import get_user_form, parse_enabled_sites
from .forms import UserForm
from ...models import User, AccountRequest
from ...models import User, AccountRequest, db
from ...utils import report_form_errors, dashboard_admin_required


@lm.user_loader
def load_user(uid):
return User.query.get(int(uid))
return db.session.get(User, int(uid))


@user_bp.before_app_request
Expand Down Expand Up @@ -58,7 +58,7 @@ def user(user_id=None):
return redirect(url_for('users.user'))

if user_id:
user = User.query.get(user_id)
user = db.session.get(User, user_id)
else:
user = current_user

Expand All @@ -74,7 +74,7 @@ def user(user_id=None):
flash("You are not authorized to update other users' settings.")
return redirect(url_for('users.user'))

updated_user = User.query.get(submitted_id)
updated_user = db.session.get(User, submitted_id)

if form.update_access.data:
# Give user access to a new study or site
Expand Down Expand Up @@ -123,7 +123,7 @@ def manage_users(user_id=None, approve=False):
# URL gets parsed into unicode
approve = False

user_request = AccountRequest.query.get(user_id)
user_request = db.session.get(AccountRequest, user_id)
if not approve:
try:
user_request.reject()
Expand Down
4 changes: 2 additions & 2 deletions dashboard/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from flask_wtf import FlaskForm
from wtforms import (SelectMultipleField, HiddenField, TextAreaField,
TextField)
StringField)
from wtforms.validators import DataRequired


Expand Down Expand Up @@ -49,6 +49,6 @@ class AnalysisForm(FlaskForm):
This feature has not yet been fully implemented.
"""
name = TextField('Brief name', validators=[DataRequired()])
name = StringField('Brief name', validators=[DataRequired()])
description = TextAreaField('Description', validators=[DataRequired()])
software = TextAreaField('Software')
Loading

0 comments on commit 006cf45

Please sign in to comment.