Skip to content

Commit 1a23e87

Browse files
committed
style: fix black/isort/flake8 formatting for CI
- Run black + isort on all source and test files (19 reformatted) - Add .flake8 config (max-line-length=88, ignore E203/W503) - All lint checks now pass: black, isort, flake8 - 66 tests pass, 81% coverage
1 parent d69526b commit 1a23e87

23 files changed

Lines changed: 60 additions & 77 deletions

.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length = 88
3+
extend-ignore = E203, W503

liulian/data/local.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import csv
1010
import os
11-
from typing import Any, Dict, List, Tuple
11+
from typing import List, Tuple
1212

1313
import numpy as np
1414

@@ -85,7 +85,6 @@ def list_data_files(
8585
files = [
8686
os.path.join(directory, f)
8787
for f in sorted(os.listdir(directory))
88-
if os.path.isfile(os.path.join(directory, f))
89-
and f.lower().endswith(extensions)
88+
if os.path.isfile(os.path.join(directory, f)) and f.lower().endswith(extensions)
9089
]
9190
return files

liulian/data/manifest.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import yaml
1313

14-
1514
# Required top-level keys in a valid manifest
1615
_REQUIRED_KEYS: List[str] = ["name", "version", "fields", "splits"]
1716

@@ -74,8 +73,6 @@ def load_manifest(path: str) -> Dict[str, Any]:
7473

7574
errors = validate_manifest(manifest)
7675
if errors:
77-
raise ValueError(
78-
f"Invalid manifest '{path}':\n " + "\n ".join(errors)
79-
)
76+
raise ValueError(f"Invalid manifest '{path}':\n " + "\n ".join(errors))
8077

8178
return manifest

liulian/data/spec.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,4 @@ def to_dict(self) -> Dict[str, Any]:
7676
}
7777

7878
def __repr__(self) -> str:
79-
return (
80-
f"TopologySpec(nodes={self.num_nodes}, edges={self.num_edges})"
81-
)
79+
return f"TopologySpec(nodes={self.num_nodes}, edges={self.num_edges})"

liulian/loggers/interface.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ def log_metrics(self, step: int, metrics: Dict[str, float]) -> None:
2626
"""
2727

2828
@abstractmethod
29-
def log_artifact(self, path: str, metadata: Optional[Dict[str, Any]] = None) -> None:
29+
def log_artifact(
30+
self, path: str, metadata: Optional[Dict[str, Any]] = None
31+
) -> None:
3032
"""Log an artifact file (checkpoint, config snapshot, etc.).
3133
3234
Args:

liulian/loggers/local_logger.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ def log_metrics(self, step: int, metrics: Dict[str, float]) -> None:
4343
with open(self._metrics_path, "a", encoding="utf-8") as fh:
4444
fh.write(json.dumps(record) + "\n")
4545

46-
def log_artifact(self, path: str, metadata: Optional[Dict[str, Any]] = None) -> None:
46+
def log_artifact(
47+
self, path: str, metadata: Optional[Dict[str, Any]] = None
48+
) -> None:
4749
"""Copy an artifact file into the run directory.
4850
4951
Args:

liulian/optim/base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ class BaseOptimizer(ABC):
3535
"""
3636

3737
@abstractmethod
38-
def run(
39-
self, spec: Any, search_space: Dict[str, Any]
40-
) -> OptimizationResult:
38+
def run(self, spec: Any, search_space: Dict[str, Any]) -> OptimizationResult:
4139
"""Execute a hyperparameter search.
4240
4341
Args:

liulian/optim/ray_optimizer.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,17 @@ def _run_fallback(
209209
# Without a real training loop we use a deterministic hash-based
210210
# proxy metric. In production code the caller should supply a
211211
# ``trainable`` and use the Ray path instead.
212-
proxy = sum(abs(hash(str(v))) % 1000 for v in combo) / max(len(combo), 1) / 1000.0
212+
proxy = (
213+
sum(abs(hash(str(v))) % 1000 for v in combo)
214+
/ max(len(combo), 1)
215+
/ 1000.0
216+
)
213217
trial_metrics = {metric: proxy}
214218
trials_summary.append(
215219
{"trial_id": i, "config": config, "metrics": trial_metrics}
216220
)
217221

218-
is_better = (
219-
proxy < best_value if mode == "min" else proxy > best_value
220-
)
222+
is_better = proxy < best_value if mode == "min" else proxy > best_value
221223
if is_better:
222224
best_value = proxy
223225
best_config = config

liulian/runtime/experiment.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import os
1212
from typing import Any, Callable, Dict, List, Optional
1313

14-
import yaml
15-
1614
from liulian.data.base import BaseDataset
1715
from liulian.loggers.interface import LoggerInterface
1816
from liulian.models.base import ExecutableModel

liulian/runtime/state_machine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class ExecutionMode(Enum):
3030
"""
3131

3232
OFFLINE = "offline"
33-
ONLINE = "online" # streaming / real-time (v1+)
34-
HITL = "hitl" # human-in-the-loop (v1+)
33+
ONLINE = "online" # streaming / real-time (v1+)
34+
HITL = "hitl" # human-in-the-loop (v1+)
3535
AGENT_ASSIST = "agent_assist" # LLM-assisted (v1+)
3636

3737

0 commit comments

Comments
 (0)