Skip to content

Commit 83d8953

Browse files
feat: add a banner for the DST bug (#90)
* feat: add a banner for the DST bug * fix: fix ruff issues and update ruff * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 834d2d3 commit 83d8953

38 files changed

Lines changed: 137 additions & 48 deletions

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ fail_fast: false
22

33
repos:
44
- repo: https://github.com/astral-sh/ruff-pre-commit
5-
rev: v0.2.2
5+
rev: v0.6.8
66
hooks:
77
- id: ruff
88
- id: ruff-format

poetry.lock

Lines changed: 21 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pytest = "^8.0.2"
2727
mypy = "^1.8.0"
2828
pre-commit = "^3.6.2"
2929
pytest-cov = "^4.1.0"
30-
ruff = "^0.2.2"
30+
ruff = "^0.6"
3131
pytest-mock = "^3.12.0"
3232
vulture = "^2.11"
3333

@@ -105,10 +105,10 @@ indent-style = "space"
105105
skip-magic-trailing-comma = false
106106
line-ending = "auto"
107107

108-
[tool.ruff.pydocstyle]
108+
[tool.ruff.lint.pydocstyle]
109109
convention = "google"
110110

111-
[tool.ruff.per-file-ignores]
111+
[tool.ruff.lint.per-file-ignores]
112112
"tests/**/*.py" = [
113113
"S101", # Allow assets
114114
"ARG", # Unused arguments are common in tests (fixtures).

src/actigraphy/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Entrypoints for the Actigraphy app."""
2+
23
import logging
34

45
from actigraphy import app

src/actigraphy/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Main app setup for the Actigraphy app."""
2+
23
import logging
34

45
import dash

src/actigraphy/components/app_license.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""License information for the application."""
2+
23
from dash import html
34

45

src/actigraphy/components/day_slider.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Dash HTML div for a slider component for selecting days."""
2+
23
import datetime
34
import itertools
45
import logging
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""A warning banner for Daylight savings time."""
2+
3+
from dash import html
4+
5+
6+
def dst_banner(day: int) -> html.Div:
7+
"""A warning banner for daylight savings time.
8+
9+
Args:
10+
day: The day of daylight savings time.
11+
12+
Returns:
13+
html.Div: A Dash HTML div containing the banner.
14+
15+
16+
"""
17+
return html.Div(
18+
children=[
19+
html.P(
20+
f"""One or more daylight savings time events were detected in this
21+
participant, with the first one on day {day}. Please be aware there's a known bug
22+
where the data is shifted on data loading of a day with daylight savings time.
23+
When opening these days, please ensure to restore the correct times. Note that if
24+
you accidentally click a DST day, and immediately click on another day, the bug
25+
will still occur.""",
26+
),
27+
],
28+
style={
29+
"backgroundColor": "#ffcc00",
30+
"color": "#333",
31+
"borderLeft": "4px solid #ffae42",
32+
"padding": "10px 20px",
33+
"margin": "0 auto",
34+
"fontSize": "16px",
35+
"fontFamily": "Arial, sans-serif",
36+
"fontWeight": "bold",
37+
"textAlign": "center",
38+
"boxShadow": "0px 4px 6px rgba(0, 0, 0, 0.1)",
39+
"borderRadius": "5px",
40+
"maxWidth": "50rem",
41+
},
42+
)

src/actigraphy/components/file_selection.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@
33
The file selection component contains an input box for the evaluator's name, and
44
dropdown menu for selecting a subject.
55
"""
6+
67
import logging
78

89
import dash
910
import dash_bootstrap_components
1011
from dash import dcc, html
1112

12-
from actigraphy.components import day_slider, finished_checkbox, graph, switches
13+
from actigraphy.components import (
14+
day_slider,
15+
dst_banner,
16+
finished_checkbox,
17+
graph,
18+
switches,
19+
)
1320
from actigraphy.core import callback_manager, config, exceptions
1421
from actigraphy.core import utils as core_utils
1522
from actigraphy.database import crud, database
@@ -129,6 +136,10 @@ def parse_files(
129136
switches.switches(),
130137
graph.graph(),
131138
]
139+
140+
if dst_index := subject.day_of_daylight_savings_time:
141+
ui_components.insert(0, dst_banner.dst_banner(dst_index))
142+
132143
return (
133144
ui_components,
134145
"",

src/actigraphy/components/finished_checkbox.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
The checklist allows the user to indicate whether they are done with the
44
current participant and would like to proceed to the next one.
55
"""
6+
67
import logging
78

89
import dash

0 commit comments

Comments
 (0)