diff --git a/base/base/inputs_api.py b/base/base/inputs_api.py index 5734da7d..4abe9c0d 100644 --- a/base/base/inputs_api.py +++ b/base/base/inputs_api.py @@ -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] diff --git a/base/pyproject.toml b/base/pyproject.toml index 5d77e111..20988900 100644 --- a/base/pyproject.toml +++ b/base/pyproject.toml @@ -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] diff --git a/miner/miner/submit.py b/miner/miner/submit.py index fddc3ddf..adf49b3f 100644 --- a/miner/miner/submit.py +++ b/miner/miner/submit.py @@ -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( diff --git a/tests/uv.lock b/tests/uv.lock index 6177af53..02c7d5b1 100644 --- a/tests/uv.lock +++ b/tests/uv.lock @@ -406,7 +406,7 @@ dev = [{ name = "pytest", specifier = ">=8.3.4" }] [[package]] name = "edge-maxxing-validator" -version = "5.6.1" +version = "5.6.2" source = { editable = "../validator" } dependencies = [ { name = "edge-maxxing-base" }, diff --git a/validator/base_validator/auto_updater.py b/validator/base_validator/auto_updater.py index 8c652635..27df37bb 100644 --- a/validator/base_validator/auto_updater.py +++ b/validator/base_validator/auto_updater.py @@ -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() diff --git a/validator/pyproject.toml b/validator/pyproject.toml index b5b73456..16b9bc71 100644 --- a/validator/pyproject.toml +++ b/validator/pyproject.toml @@ -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] diff --git a/validator/submission_tester/__init__.py b/validator/submission_tester/__init__.py index 489dadd8..aa9203b4 100644 --- a/validator/submission_tester/__init__.py +++ b/validator/submission_tester/__init__.py @@ -1 +1 @@ -from .api import app +from .api import app # noqa F401 diff --git a/validator/uv.lock b/validator/uv.lock index 2b15ceb1..a2aa7947 100644 --- a/validator/uv.lock +++ b/validator/uv.lock @@ -381,7 +381,10 @@ requires-dist = [ ] [package.metadata.requires-dev] -dev = [{ name = "pytype", specifier = "==2024.10.11" }] +dev = [ + { name = "pytype", specifier = "==2024.10.11" }, + { name = "ruff", specifier = ">=0.8.2" }, +] [[package]] name = "edge-maxxing-pipelines" @@ -396,7 +399,7 @@ requires-dist = [{ name = "pydantic", specifier = ">=2.9.2" }] [[package]] name = "edge-maxxing-validator" -version = "5.5.9" +version = "5.6.3" source = { editable = "." } dependencies = [ { name = "edge-maxxing-base" }, @@ -430,6 +433,7 @@ dependencies = [ [package.dev-dependencies] dev = [ { name = "pytype" }, + { name = "ruff" }, ] [package.metadata] @@ -463,7 +467,10 @@ requires-dist = [ ] [package.metadata.requires-dev] -dev = [{ name = "pytype", specifier = "==2024.10.11" }] +dev = [ + { name = "pytype", specifier = "==2024.10.11" }, + { name = "ruff", specifier = ">=0.8.2" }, +] [[package]] name = "eth-hash" @@ -2091,6 +2098,31 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/f9/9b/335f9764261e915ed497fcdeb11df5dfd6f7bf257d4a6a2a686d80da4d54/requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6", size = 64928 }, ] +[[package]] +name = "ruff" +version = "0.8.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/5e/2b/01245f4f3a727d60bebeacd7ee6d22586c7f62380a2597ddb22c2f45d018/ruff-0.8.2.tar.gz", hash = "sha256:b84f4f414dda8ac7f75075c1fa0b905ac0ff25361f42e6d5da681a465e0f78e5", size = 3349020 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/91/29/366be70216dba1731a00a41f2f030822b0c96c7c4f3b2c0cdce15cbace74/ruff-0.8.2-py3-none-linux_armv6l.whl", hash = "sha256:c49ab4da37e7c457105aadfd2725e24305ff9bc908487a9bf8d548c6dad8bb3d", size = 10530649 }, + { url = "https://files.pythonhosted.org/packages/63/82/a733956540bb388f00df5a3e6a02467b16c0e529132625fe44ce4c5fb9c7/ruff-0.8.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:ec016beb69ac16be416c435828be702ee694c0d722505f9c1f35e1b9c0cc1bf5", size = 10274069 }, + { url = "https://files.pythonhosted.org/packages/3d/12/0b3aa14d1d71546c988a28e1b412981c1b80c8a1072e977a2f30c595cc4a/ruff-0.8.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:f05cdf8d050b30e2ba55c9b09330b51f9f97d36d4673213679b965d25a785f3c", size = 9909400 }, + { url = "https://files.pythonhosted.org/packages/23/08/f9f08cefb7921784c891c4151cce6ed357ff49e84b84978440cffbc87408/ruff-0.8.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:60f578c11feb1d3d257b2fb043ddb47501ab4816e7e221fbb0077f0d5d4e7b6f", size = 10766782 }, + { url = "https://files.pythonhosted.org/packages/e4/71/bf50c321ec179aa420c8ec40adac5ae9cc408d4d37283a485b19a2331ceb/ruff-0.8.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:cbd5cf9b0ae8f30eebc7b360171bd50f59ab29d39f06a670b3e4501a36ba5897", size = 10286316 }, + { url = "https://files.pythonhosted.org/packages/f2/83/c82688a2a6117539aea0ce63fdf6c08e60fe0202779361223bcd7f40bd74/ruff-0.8.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b402ddee3d777683de60ff76da801fa7e5e8a71038f57ee53e903afbcefdaa58", size = 11338270 }, + { url = "https://files.pythonhosted.org/packages/7f/d7/bc6a45e5a22e627640388e703160afb1d77c572b1d0fda8b4349f334fc66/ruff-0.8.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:705832cd7d85605cb7858d8a13d75993c8f3ef1397b0831289109e953d833d29", size = 12058579 }, + { url = "https://files.pythonhosted.org/packages/da/3b/64150c93946ec851e6f1707ff586bb460ca671581380c919698d6a9267dc/ruff-0.8.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:32096b41aaf7a5cc095fa45b4167b890e4c8d3fd217603f3634c92a541de7248", size = 11615172 }, + { url = "https://files.pythonhosted.org/packages/e4/9e/cf12b697ea83cfe92ec4509ae414dc4c9b38179cc681a497031f0d0d9a8e/ruff-0.8.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e769083da9439508833cfc7c23e351e1809e67f47c50248250ce1ac52c21fb93", size = 12882398 }, + { url = "https://files.pythonhosted.org/packages/a9/27/96d10863accf76a9c97baceac30b0a52d917eb985a8ac058bd4636aeede0/ruff-0.8.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5fe716592ae8a376c2673fdfc1f5c0c193a6d0411f90a496863c99cd9e2ae25d", size = 11176094 }, + { url = "https://files.pythonhosted.org/packages/eb/10/cd2fd77d4a4e7f03c29351be0f53278a393186b540b99df68beb5304fddd/ruff-0.8.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:81c148825277e737493242b44c5388a300584d73d5774defa9245aaef55448b0", size = 10771884 }, + { url = "https://files.pythonhosted.org/packages/71/5d/beabb2ff18870fc4add05fa3a69a4cb1b1d2d6f83f3cf3ae5ab0d52f455d/ruff-0.8.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d261d7850c8367704874847d95febc698a950bf061c9475d4a8b7689adc4f7fa", size = 10382535 }, + { url = "https://files.pythonhosted.org/packages/ae/29/6b3fdf3ad3e35b28d87c25a9ff4c8222ad72485ab783936b2b267250d7a7/ruff-0.8.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:1ca4e3a87496dc07d2427b7dd7ffa88a1e597c28dad65ae6433ecb9f2e4f022f", size = 10886995 }, + { url = "https://files.pythonhosted.org/packages/e9/dc/859d889b4d9356a1a2cdbc1e4a0dda94052bc5b5300098647e51a58c430b/ruff-0.8.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:729850feed82ef2440aa27946ab39c18cb4a8889c1128a6d589ffa028ddcfc22", size = 11220750 }, + { url = "https://files.pythonhosted.org/packages/0b/08/e8f519f61f1d624264bfd6b8829e4c5f31c3c61193bc3cff1f19dbe7626a/ruff-0.8.2-py3-none-win32.whl", hash = "sha256:ac42caaa0411d6a7d9594363294416e0e48fc1279e1b0e948391695db2b3d5b1", size = 8729396 }, + { url = "https://files.pythonhosted.org/packages/f8/d4/ba1c7ab72aba37a2b71fe48ab95b80546dbad7a7f35ea28cf66fc5cea5f6/ruff-0.8.2-py3-none-win_amd64.whl", hash = "sha256:2aae99ec70abf43372612a838d97bfe77d45146254568d94926e8ed5bbb409ea", size = 9594729 }, + { url = "https://files.pythonhosted.org/packages/23/34/db20e12d3db11b8a2a8874258f0f6d96a9a4d631659d54575840557164c8/ruff-0.8.2-py3-none-win_arm64.whl", hash = "sha256:fb88e2a506b70cfbc2de6fae6681c4f944f7dd5f2fe87233a7233d888bad73e8", size = 9035131 }, +] + [[package]] name = "safetensors" version = "0.4.5" diff --git a/validator/weight_setting/benchmarking_api.py b/validator/weight_setting/benchmarking_api.py index 0fae19dd..638d3789 100644 --- a/validator/weight_setting/benchmarking_api.py +++ b/validator/weight_setting/benchmarking_api.py @@ -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}") diff --git a/validator/weight_setting/state_manager.py b/validator/weight_setting/state_manager.py index e6f68787..f4aeb7b6 100644 --- a/validator/weight_setting/state_manager.py +++ b/validator/weight_setting/state_manager.py @@ -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()) diff --git a/validator/weight_setting/telemetry_attributes.py b/validator/weight_setting/telemetry_attributes.py index dec9b6c5..53cb8eb5 100644 --- a/validator/weight_setting/telemetry_attributes.py +++ b/validator/weight_setting/telemetry_attributes.py @@ -1,3 +1,5 @@ +# ruff: noqa: E402 + import logging logging.disable() diff --git a/validator/weight_setting/weight_setter.py b/validator/weight_setting/weight_setter.py index 5f6031c0..8c4d2f09 100644 --- a/validator/weight_setting/weight_setter.py +++ b/validator/weight_setting/weight_setter.py @@ -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)