Skip to content

Commit dc0c35d

Browse files
committed
WIP: start repo-wide ruff cleanup
1 parent 08d4375 commit dc0c35d

9 files changed

Lines changed: 362 additions & 335 deletions

analysis/dashboard/pareto_tab.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,10 @@ def _fmt_delta(pct):
122122
st.warning("Select exactly 2 points to compare. Clear selection and try again.")
123123

124124
# Clear selection button (visible when any points are selected)
125-
if len(points) >= 1:
126-
if st.button("Clear selection", key="clear_pareto_selection"):
127-
st.session_state.pareto_chart_gen += 1
128-
st.session_state.pareto_swapped = False
129-
st.rerun()
125+
if len(points) >= 1 and st.button("Clear selection", key="clear_pareto_selection"):
126+
st.session_state.pareto_chart_gen += 1
127+
st.session_state.pareto_swapped = False
128+
st.rerun()
130129

131130
# Debug info for frontier
132131
if pareto_options["show_frontier"]:

analysis/srtlog/cache_manager.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,7 @@ def save_to_cache(self, cache_name: str, data: pd.DataFrame | list[dict], source
126126
source_patterns: Glob patterns for source files
127127
"""
128128
# Convert to DataFrame if needed
129-
if isinstance(data, list):
130-
if not data:
131-
# Save empty DataFrame
132-
df = pd.DataFrame()
133-
else:
134-
df = pd.DataFrame(data)
135-
else:
136-
df = data
129+
df = (pd.DataFrame() if not data else pd.DataFrame(data)) if isinstance(data, list) else data
137130

138131
# Save to parquet
139132
cache_file = self.cache_dir / f"{cache_name}.parquet"

analysis/srtlog/config_reader.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,17 @@ def validate_config_structure(config: dict[str, Any], config_path: str) -> None:
3434
)
3535

3636
# Validate nested structure
37-
if "config" in config:
38-
if "server_args" not in config["config"]:
39-
logger.warning(
40-
f"Config at {config_path} missing 'server_args' in 'config'. "
41-
f"Available keys in config: {list(config['config'].keys())}"
42-
)
37+
if "config" in config and "server_args" not in config["config"]:
38+
logger.warning(
39+
f"Config at {config_path} missing 'server_args' in 'config'. "
40+
f"Available keys in config: {list(config['config'].keys())}"
41+
)
4342

44-
if "gpu_info" in config:
45-
if "gpus" not in config["gpu_info"]:
46-
logger.warning(
47-
f"Config at {config_path} missing 'gpus' in 'gpu_info'. "
48-
f"Available keys: {list(config['gpu_info'].keys())}"
49-
)
43+
if "gpu_info" in config and "gpus" not in config["gpu_info"]:
44+
logger.warning(
45+
f"Config at {config_path} missing 'gpus' in 'gpu_info'. "
46+
f"Available keys: {list(config['gpu_info'].keys())}"
47+
)
5048

5149

5250
def read_config_file(config_path: str) -> NodeConfig | None:

analysis/srtlog/visualizations.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,7 @@ def create_node_metric_graph(
291291
continue
292292

293293
# Extract value
294-
if value_extractor:
295-
value = value_extractor(batch)
296-
else:
297-
value = batch.get(metric_key)
294+
value = value_extractor(batch) if value_extractor else batch.get(metric_key)
298295

299296
if value is not None:
300297
timestamps.append(batch["timestamp"])
@@ -516,11 +513,10 @@ def calculate_pareto_frontier(df: pd.DataFrame, y_metric: str = "Output TPS/GPU"
516513

517514
# Check if this point is dominated by any other point
518515
for j, (x2, y2) in enumerate(points):
519-
if i != j:
516+
if i != j and x2 >= x1 and y2 >= y1 and (x2 > x1 or y2 > y1):
520517
# Point (x2, y2) dominates (x1, y1) if it's better in both dimensions
521-
if x2 >= x1 and y2 >= y1 and (x2 > x1 or y2 > y1):
522-
is_dominated = True
523-
break
518+
is_dominated = True
519+
break
524520

525521
if not is_dominated:
526522
frontier.append((x1, y1))

0 commit comments

Comments
 (0)