Skip to content

Commit

Permalink
Fix bugbear errors
Browse files Browse the repository at this point in the history
  • Loading branch information
olzhasar-reef committed Sep 26, 2024
1 parent c064d17 commit c750a70
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion compute_horde/compute_horde/test_base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def start_process(cls, args, additional_env: dict[str, str]):

@classmethod
def wait_for_process_start(cls, process_name, probe_function, process: subprocess.Popen):
for i in range(300):
for _ in range(300):
if probe_function():
return
if process.poll() is not None:
Expand Down
2 changes: 1 addition & 1 deletion executor/bin/rotate-local-backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def rotate_backups(path, file_count):
files = files[:-file_count]
if files:
print(f"Removing {len(files)} old files")
for mtime, f in files:
for _mtime, f in files:
f.unlink()
else:
print("No old files to remove")
Expand Down
2 changes: 1 addition & 1 deletion miner/bin/rotate-local-backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def rotate_backups(path, file_count):
files = files[:-file_count]
if files:
print(f"Removing {len(files)} old files")
for mtime, f in files:
for _mtime, f in files:
f.unlink()
else:
print("No old files to remove")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ def __init__(self, reason: str, errors: list[Error]):
self.errors = errors


async def save_facilitator_event(subtype: str, long_description: str, data={}, success=False):
async def save_facilitator_event(
subtype: str, long_description: str, data: dict[str, str] | None = None, success=False
):
await SystemEvent.objects.using(settings.DEFAULT_DB_ALIAS).acreate(
type=SystemEvent.EventType.FACILITATOR_CLIENT_ERROR,
subtype=subtype,
long_description=long_description,
data=data,
data=data or {},
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,7 @@ def __init__(
mocked_commit_weights=lambda: (True, ""),
mocked_reveal_weights=lambda: (True, ""),
mocked_metagraph=lambda: MockMetagraph(),
hyperparameters=MockHyperparameters(
commit_reveal_weights_enabled=False,
commit_reveal_weights_interval=1000,
max_weight_limit=65535,
),
hyperparameters=None,
block_duration=timedelta(seconds=1),
override_block_number=None,
increase_block_number_with_each_call=False,
Expand All @@ -222,7 +218,11 @@ def __init__(
self.mocked_commit_weights = mocked_commit_weights
self.mocked_reveal_weights = mocked_reveal_weights
self.mocked_metagraph = mocked_metagraph
self.hyperparameters = hyperparameters
self.hyperparameters = hyperparameters or MockHyperparameters(
commit_reveal_weights_enabled=False,
commit_reveal_weights_interval=1000,
max_weight_limit=65535,
)
self.weights_set: list[list[numbers.Number]] = []
self.weights_committed: list[list[numbers.Number]] = []
self.weights_revealed: list[list[numbers.Number]] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_debug_run_organic_job_command__job_not_created():
Miner.objects.create(hotkey="miner_client")

with redirect_stdout(io.StringIO()) as buf:
with pytest.raises(BaseException):
with pytest.raises(SystemExit):
management.call_command(
"debug_run_organic_job", docker_image="noop", timeout=4, cmd_args=""
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ async def test_facilitator_client(ws_server_cls):
facilitator_client.specs_task.cancel()
task.cancel()
if ws_server.facilitator_error:
assert False, ws_server.facilitator_error
pytest.fail(str(ws_server.facilitator_error))


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ async def interaction_callback(miner_client, after_job_sent):
miner_client = mocked_synthetic_miner_client.instance
async for job in SyntheticJob.objects.filter(job_uuid__in=job_uuids):
receipt = miner_client._query_sent_models(
lambda m: m.payload.job_uuid == str(job.job_uuid), V0JobFinishedReceiptRequest
lambda m, j=job: m.payload.job_uuid == str(j.job_uuid), V0JobFinishedReceiptRequest
)[0]
time_took = receipt.payload.time_took_us / 1_000_000
assert abs(job.score * time_took - expected_multiplier) < 0.0001
Expand Down Expand Up @@ -555,7 +555,7 @@ async def interaction_callback(miner_client, after_job_sent):
miner_client = mocked_synthetic_miner_client.instance
for job in SyntheticJob.objects.filter(job_uuid__in=job_uuids):
receipt = miner_client._query_sent_models(
lambda m: m.payload.job_uuid == str(job.job_uuid), V0JobFinishedReceiptRequest
lambda m, j=job: m.payload.job_uuid == str(j.job_uuid), V0JobFinishedReceiptRequest
)[0]
time_took = receipt.payload.time_took_us / 1_000_000
assert abs(job.score * time_took - expected_multiplier) < 0.0001
Expand Down
2 changes: 1 addition & 1 deletion validator/bin/rotate-local-backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def rotate_backups(path, file_count):
files = files[:-file_count]
if files:
print(f"Removing {len(files)} old files")
for mtime, f in files:
for _mtime, f in files:
f.unlink()
else:
print("No old files to remove")
Expand Down

0 comments on commit c750a70

Please sign in to comment.