Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI updates #73

Merged
merged 18 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bmds_ui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import sys

__version__ = "24.1a5"
__version__ = "24.1a6"


def manage():
Expand Down
15 changes: 1 addition & 14 deletions bmds_ui/analysis/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,4 @@ def add_schema_to_path(schema: dict, path: str, verb: str, name: str):


class ApiSchemaGenerator(SchemaGenerator):
def get_schema(self, *args, **kwargs):
schema = super().get_schema(*args, **kwargs)
add_schemas(schema, [EditKeySchema, WrappedAnalysisSelectedSchema])
add_schema_to_path(schema, "/api/v1/analysis/{id}/execute/", "post", EditKeySchema.__name__)
add_schema_to_path(
schema, "/api/v1/analysis/{id}/execute-reset/", "post", EditKeySchema.__name__
)
add_schema_to_path(
schema,
"/api/v1/analysis/{id}/select-model/",
"post",
WrappedAnalysisSelectedSchema.__name__,
)
return schema
pass
2 changes: 1 addition & 1 deletion bmds_ui/analysis/templates/analysis/desktop_home.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="col-lg-8">

<div class="d-flex">
<h3 class="flex-grow-1">Analyses</h3>
<h2 class="flex-grow-1">Analyses</h2>

<div class="dropdown mr-2">
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-expanded="false">Collections</button>
Expand Down
1 change: 1 addition & 0 deletions bmds_ui/analysis/validators/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class NestedDichotomousOption(BaseModel):
litter_specific_covariate: LitterSpecificCovariate
bootstrap_iterations: int
bootstrap_seed: int
estimate_background: bool


class DichotomousOptions(BaseModel):
Expand Down
11 changes: 1 addition & 10 deletions bmds_ui/common/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from rest_framework import permissions, status, viewsets
from rest_framework import status, viewsets
from rest_framework.decorators import action
from rest_framework.response import Response
from rest_framework.throttling import UserRateThrottle
Expand All @@ -20,12 +20,3 @@ def worker(self, request):
is_healthy = worker_healthcheck.healthy()
status_code = status.HTTP_200_OK if is_healthy else status.HTTP_503_SERVICE_UNAVAILABLE
return Response({"healthy": is_healthy}, status=status_code)

@action(
detail=False,
permission_classes=(permissions.IsAdminUser,),
throttle_classes=(FivePerMinuteThrottle,),
)
def throttle(self, request):
throttle = self.get_throttles()[0]
return Response({"identity": throttle.get_ident(request)})
10 changes: 5 additions & 5 deletions bmds_ui/common/management/commands/scrub_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.contrib.auth.hashers import make_password
from django.core.management.base import BaseCommand, CommandError
from django.db import transaction
from django.db.models import Value
from django.db.models import CharField, Value
from django.db.models.functions import Concat


Expand Down Expand Up @@ -41,10 +41,10 @@ def update_users(self):

# save all programs
get_user_model().objects.update(
first_name=Concat(Value("first-"), "id"),
last_name=Concat(Value("last-"), "id"),
username=Concat(Value("username-"), "id"),
email=Concat(Value("user-"), "id", Value("@bmdsonline.org")),
first_name=Concat(Value("f-"), "id", output_field=CharField()),
last_name=Concat(Value("l-"), "id", output_field=CharField()),
username=Concat(Value("u-"), "id", output_field=CharField()),
email=Concat(Value("e-"), "id", Value("@bmdsonline.org"), output_field=CharField()),
password=hash_password,
)

Expand Down
11 changes: 11 additions & 0 deletions bmds_ui/static/css/epa/bmdsonline.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,14 @@ a.dropdown-toggle:not([href])::after {
.bmds-desktop,.footer__column{
width: 100%;
}

/* reduce font size */
h1 {
font-size: 2rem;
}
h2 {
font-size: 1.7rem;
}
h2 {
font-size: 1.5rem;
}
2 changes: 1 addition & 1 deletion bmds_ui/templates/includes/epa/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
{% endif %}
</header>
<nav class="bmds-header navbar justify-content-between">
<h2><a href="{% url 'home' %}">{% if IS_DESKTOP %}Benchmark Dose Tools (BMDS) Desktop{% else %}Benchmark Dose Tools (BMDS) Online{% endif %}</a></h2>
<h1><a href="{% url 'home' %}">{% if IS_DESKTOP %}Benchmark Dose Tools (BMDS) Desktop{% else %}Benchmark Dose Tools (BMDS) Online{% endif %}</a></h1>
<ul class="nav text-right">
{% if user.is_staff %}
<li class="nav-item">
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class App extends Component {

return this.props.mainStore.isUpdateComplete ? (
<HashRouter>
<h3>
<h2>
{getHeader()}
{isFuture ? (
<span
Expand All @@ -47,7 +47,7 @@ class App extends Component {
<Icon name="lightning-fill" />
</span>
) : null}
</h3>
</h2>
<Navigation />
</HashRouter>
) : null;
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/IndividualModel/ModelDetailModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ModelBody extends Component {
/>
</Col>
<Col xl={4}>
<Summary store={outputStore} />
<Summary />
</Col>
<Col xl={8}>
<DoseResponsePlot
Expand Down Expand Up @@ -194,7 +194,7 @@ class MultitumorModalBody extends Component {
/>
</Col>
<Col xl={4}>
<Summary model={model} />
<Summary />
</Col>
<Col xs={8}>
<DoseResponsePlot
Expand Down Expand Up @@ -250,7 +250,7 @@ class NestedDichotomousModalBody extends Component {
<ModelOptionsTable dtype={dtype} model={model} />
</Col>
<Col xs={6}>
<Summary results={model.results} />
<Summary />
</Col>
<Col xs={6}>
<DoseResponsePlot
Expand Down
11 changes: 6 additions & 5 deletions frontend/src/components/IndividualModel/ModelOptionsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {observer} from "mobx-react";
import PropTypes from "prop-types";
import React, {Component} from "react";

import {getLabel} from "@/common";
import {checkOrEmpty, getLabel} from "@/common";
import TwoColumnTable from "@/components/common/TwoColumnTable";
import {Dtype} from "@/constants/dataConstants";
import {hasDegrees} from "@/constants/modelConstants";
Expand Down Expand Up @@ -70,19 +70,20 @@ class ModelOptionsTable extends Component {
["BMR Type", getLabel(model.settings.bmr_type, dichotomousBmrOptions)],
["BMR", ff(model.settings.bmr)],
["Confidence Level (one sided)", ff(1 - model.settings.alpha)],
["Bootstrap Seed", model.settings.bootstrap_seed],
["Bootstrap Iterations", model.settings.bootstrap_iterations],
[
"Litter Specific Covariate",
getLabel(
`${getLabel(
model.settings.litter_specific_covariate,
litterSpecificCovariateOptions
),
)} (${ff(model.results.fixed_lsc)})`,
],
[
"Intralitter Correlation",
getLabel(model.settings.intralitter_correlation, intralitterCorrelation),
],
["Estimate Background", checkOrEmpty(model.settings.estimate_background)],
["Bootstrap Iterations", model.settings.bootstrap_iterations],
["Bootstrap Seed", model.settings.bootstrap_seed],
];
} else {
throw "Unknown dtype";
Expand Down
53 changes: 34 additions & 19 deletions frontend/src/components/IndividualModel/Summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,62 @@ import {ff, fractionalFormatter} from "@/utils/formatters";
class Summary extends Component {
render() {
const {outputStore} = this.props,
model = outputStore.modalModel;
model = outputStore.modalModel,
{results} = model;
let data;
if (outputStore.isNestedDichotomous) {
data = [
["BMD", ff(model.results.bmd), model.results.bmd],
["BMDL", ff(model.results.bmdl), model.results.bmdl],
["BMDU", ff(model.results.bmdu), model.results.bmdu],
["AIC", ff(model.results.aic), model.results.aic],
["BMD", ff(results.bmd), results.bmd],
["BMDL", ff(results.bmdl), results.bmdl],
["BMDU", ff(results.bmdu), results.bmdu],
["AIC", ff(results.aic), results.aic],
[
<span key={0}>
<i>P</i>-value
</span>,
fractionalFormatter(model.results.combined_pvalue),
fractionalFormatter(results.combined_pvalue),
results.combined_pvalue,
],
["Model d.f.", ff(model.results.dof)],
[<span key={1}>Chi²</span>, ff(model.results.chi_squared)],
["Model d.f.", ff(results.dof), results.dof],
[<span key={1}>Chi²</span>, ff(results.chi_squared), results.chi_squared],
];
} else if (outputStore.getModelType === mc.MODEL_CONTINUOUS) {
data = [
["BMD", ff(results.bmd), results.bmd],
["BMDL", ff(results.bmdl), results.bmdl],
["BMDU", ff(results.bmdu), results.bmdu],
["AIC", ff(results.fit.aic), results.fit.aic],
[
<span key={0}>
<i>P</i>-value
</span>,
fractionalFormatter(results.tests.p_values[3]),
results.tests.p_values[3],
],
["Model d.f.", ff(results.tests.dfs[3]), results.tests.dfs[3]],
["Log-Likelihood", ff(results.fit.loglikelihood), results.fit.loglikelihood],
];
} else {
const isContinuous = outputStore.getModelType === mc.MODEL_CONTINUOUS,
results = model.bmd ? model : model.results,
p_value = isContinuous ? results.tests.p_values[3] : results.gof.p_value,
df = isContinuous ? results.tests.dfs[3] : results.gof.df;
data = [
["BMD", ff(results.bmd), results.bmd],
["BMDL", ff(results.bmdl), results.bmdl],
["BMDU", ff(results.bmdu), results.bmdu],
outputStore.isMultiTumor
? ["Slope Factor", ff(results.slope_factor), results.slope_factor]
: null,
["AIC", ff(results.fit.aic), results.fit.aic],
["Log-Likelihood", ff(results.fit.loglikelihood)],
[
<span key={0}>
<i>P</i>-value
</span>,
fractionalFormatter(p_value),
fractionalFormatter(results.gof.p_value),
results.gof.p_value,
],
["Model d.f.", ff(df)],
["Model d.f.", ff(results.gof.df), results.gof.df],
["Log-Likelihood", ff(results.fit.loglikelihood), results.fit.loglikelihood],
["Chi²", ff(results.fit.chisq), results.fit.chisq],
];
if (outputStore.isMultiTumor) {
data.splice(3, 0, ["Slope Factor", ff(results.slope_factor), results.slope_factor]);
}
}

return <TwoColumnTable data={data} label="Modeling Summary" />;
}
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/Logic/LogicRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Logic extends Component {
return (
<div className="container-fluid">
<DecisionLogic />
<h3>Model Recommendation and Bin Placement Logic</h3>
<RuleTable />
</div>
);
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/components/Logic/RuleTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ class RuleList extends Component {
return (
<table id="rule-table" className="table table-sm">
<thead className="bg-custom">
<tr>
<th colSpan="5">Model Recommendation and Bin Placement Logic</th>
</tr>
<tr>
<th>Test Description</th>
<th>Enabled</th>
Expand Down
Loading