Skip to content

Commit 1467fb4

Browse files
authored
improvement: style <progress/> consistently (#4909)
1 parent 272cce3 commit 1467fb4

File tree

3 files changed

+179
-0
lines changed

3 files changed

+179
-0
lines changed

frontend/src/css/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
@import url("./md-tooltip.css");
88
@import url("./admonition.css");
99
@import url("./table.css");
10+
@import url("./progress.css");

frontend/src/css/progress.css

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/* Copyright 2024 Marimo. All rights reserved. */
2+
3+
/*
4+
* Global styling for progress bars to ensure consistent appearance
5+
* across both marimo native components and IPython outputs
6+
*/
7+
8+
/* Container styling */
9+
.progress-container {
10+
display: flex;
11+
flex-direction: column;
12+
margin-left: auto;
13+
margin-right: auto;
14+
15+
@apply max-w-sm p-6;
16+
}
17+
18+
/* Title styling */
19+
.progress-title {
20+
font-family: var(--heading-font, "Lora", serif);
21+
22+
@apply text-lg font-bold text-foreground/60;
23+
}
24+
25+
/* Subtitle styling */
26+
.progress-subtitle {
27+
font-family: var(--text-font, "PT Sans", sans-serif);
28+
29+
@apply text-sm text-muted-foreground font-normal;
30+
}
31+
32+
/* Progress wrapper */
33+
.progress-wrapper {
34+
width: 100%;
35+
display: flex;
36+
flex-direction: column;
37+
@apply gap-1 mt-2;
38+
}
39+
40+
/* Progress bar row */
41+
.progress-row {
42+
display: flex;
43+
align-items: baseline;
44+
font-family: var(--text-font, "PT Sans", sans-serif);
45+
46+
@apply gap-3 text-sm text-muted-foreground;
47+
}
48+
49+
/* Meta information row */
50+
.progress-meta {
51+
display: flex;
52+
font-family: var(--text-font, "PT Sans", sans-serif);
53+
54+
@apply gap-2 text-muted-foreground text-sm;
55+
}
56+
57+
/* Base progress element styling */
58+
progress {
59+
appearance: none;
60+
position: relative;
61+
overflow: hidden;
62+
border-radius: 9999px;
63+
border: none;
64+
flex: 1;
65+
66+
@apply bg-slate-200 dark:bg-accent/60 h-2 max-h-2 mr-1;
67+
}
68+
69+
/* Progress bar fill styling */
70+
progress::-webkit-progress-bar {
71+
border-radius: 9999px;
72+
73+
@apply bg-slate-200 dark:bg-accent/60;
74+
}
75+
76+
progress::-webkit-progress-value {
77+
transition: width 0.2s ease;
78+
@apply bg-blue-500 dark:bg-primary;
79+
}
80+
81+
progress::-moz-progress-bar {
82+
transition: width 0.2s ease;
83+
@apply bg-blue-500 dark:bg-primary;
84+
}
85+
86+
/* Wrap existing progress elements */
87+
progress:not(.wrapped) {
88+
display: inline-block;
89+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import marimo
2+
3+
__generated_with = "0.13.7"
4+
app = marimo.App(width="medium")
5+
6+
7+
@app.cell
8+
def __1():
9+
import time
10+
from transformers.utils.notebook import NotebookProgressCallback
11+
from transformers.training_args import IntervalStrategy
12+
return IntervalStrategy, NotebookProgressCallback, time
13+
14+
15+
@app.cell
16+
def _(
17+
MockTrainingArgs,
18+
MockTrainingControl,
19+
MockTrainingState,
20+
NotebookProgressCallback,
21+
time,
22+
):
23+
def simulate_transformers_training():
24+
# Training parameters
25+
num_train_epochs = 5
26+
steps_per_epoch = 100
27+
total_steps = num_train_epochs * steps_per_epoch
28+
29+
# Initialize state, args, and control
30+
state = MockTrainingState(total_steps, num_train_epochs)
31+
args = MockTrainingArgs()
32+
control = MockTrainingControl()
33+
34+
# Initialize the callback
35+
callback = NotebookProgressCallback()
36+
37+
# Start training
38+
callback.on_train_begin(args, state, control)
39+
40+
# Simulate epochs
41+
for epoch in range(1, num_train_epochs + 1):
42+
state.epoch = epoch
43+
44+
# Simulate steps within epoch
45+
for step in range(1, steps_per_epoch + 1):
46+
state.global_step = (epoch - 1) * steps_per_epoch + step
47+
48+
# Simulate work
49+
time.sleep(0.01) # Reduced sleep time for faster simulation
50+
51+
# Update progress
52+
callback.on_step_end(args, state, control)
53+
54+
# Call on_evaluate
55+
callback.on_evaluate(args, state, control, metrics={})
56+
57+
# End training
58+
callback.on_train_end(args, state, control)
59+
60+
61+
simulate_transformers_training()
62+
return
63+
64+
65+
@app.cell
66+
def _(IntervalStrategy):
67+
# Create a mock training state and args for the callback
68+
class MockTrainingState:
69+
def __init__(self, max_steps, num_train_epochs):
70+
self.max_steps = max_steps
71+
self.num_train_epochs = num_train_epochs
72+
self.global_step = 0
73+
self.epoch = 0
74+
self.log_history = []
75+
76+
77+
class MockTrainingArgs:
78+
def __init__(self):
79+
self.eval_strategy = IntervalStrategy.EPOCH
80+
81+
82+
class MockTrainingControl:
83+
def __init__(self):
84+
pass
85+
return MockTrainingArgs, MockTrainingControl, MockTrainingState
86+
87+
88+
if __name__ == "__main__":
89+
app.run()

0 commit comments

Comments
 (0)