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

Add ruff formatter and reformat #110

Merged
merged 2 commits into from
Dec 10, 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 base/base/inputs_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class InputsState(BaseModel):
active_contests: dict[ContestId, dict[MetricType, int]]

def get_metric_weights(self, contest_id: ContestId) -> dict[MetricType, int]:
if not contest_id in self.active_contests:
if contest_id not in self.active_contests:
raise ValueError(f"Contest {contest_id} is not active")

return self.active_contests[contest_id]
Expand Down
3 changes: 2 additions & 1 deletion base/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ edge-maxxing-pipelines = { path = "../pipelines", editable = true }

[dependency-groups]
dev = [
"pytype==2024.10.11"
"pytype==2024.10.11",
"ruff>=0.8.2",
]

[tool.pytype]
Expand Down
2 changes: 1 addition & 1 deletion miner/miner/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def submit():
try:
start_benchmarking(find_contest(submission.contest_id), keypair, submission)
except Exception as e:
logger.critical(f"Benchmarking failed, submission cancelled", exc_info=e)
logger.critical("Benchmarking failed, submission cancelled", exc_info=e)
exit(1)

print(
Expand Down
2 changes: 1 addition & 1 deletion tests/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion validator/base_validator/auto_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _monitor(self):
sleep_minutes = UPDATE_RATE_MINUTES - current_time.tm_min % UPDATE_RATE_MINUTES
self._stop_flag.wait(sleep_minutes * 60 - current_time.tm_sec)
except Exception as e:
logger.error(f"Error occurred while checking for updates, attempting to fix the issue by restarting", exc_info=e)
logger.error("Error occurred while checking for updates, attempting to fix the issue by restarting", exc_info=e)
self._stop_flag.wait(1)
self._restart()

Expand Down
3 changes: 2 additions & 1 deletion validator/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ edge-maxxing-base = { path = "../base", editable = true }

[dependency-groups]
dev = [
"pytype==2024.10.11"
"pytype==2024.10.11",
"ruff>=0.8.2",
]

[tool.pytype]
Expand Down
2 changes: 1 addition & 1 deletion validator/submission_tester/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .api import app
from .api import app # noqa F401
38 changes: 35 additions & 3 deletions validator/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion validator/weight_setting/benchmarking_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def send_submissions_to_api(version: str, all_apis: list[BenchmarkingApi], submi

active_contests = get_inputs_state().get_active_contests()
for contest_id, apis in contest_api_assignment.items():
if not contest_id in active_contests:
if contest_id not in active_contests:
continue
if contest_id not in submissions_by_contest:
raise RuntimeError(f"No API compatible with contest type {contest_id.name}")
Expand Down
6 changes: 3 additions & 3 deletions validator/weight_setting/state_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ def load_state(self) -> ContestState | None:
if not self._state_file.exists():
return None

logger.info(f"Loading state")
logger.info("Loading state")

try:
with self._state_file.open("rb") as file:
return ContestState.model_validate_json(file.read())
except ValidationError as e:
logger.error(f"Failed to load state", exc_info=e)
logger.error("Failed to load state", exc_info=e)
return None

def save_state(self, state: ContestState):
logger.debug(f"Saving state")
logger.debug("Saving state")

with self._state_file.open("wb") as file:
file.write(state.model_dump_json(indent=4).encode())
2 changes: 2 additions & 0 deletions validator/weight_setting/telemetry_attributes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# ruff: noqa: E402

import logging

logging.disable()
Expand Down
2 changes: 1 addition & 1 deletion validator/weight_setting/weight_setter.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def set_weights(self) -> bool:
contest_state.benchmarks.pop(hotkey, None)
contest_state.last_benchmarks.pop(hotkey, None)
contest_state.submissions.pop(hotkey, None)
if not hotkey in contest_state.submissions:
if hotkey not in contest_state.submissions:
contest_state.benchmarks.pop(hotkey, None)
contest_state.last_benchmarks.pop(hotkey, None)

Expand Down
Loading