Skip to content

Commit

Permalink
Flake8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
WardLT committed Sep 3, 2024
1 parent c153895 commit 169751c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 1 addition & 3 deletions colmena/proxy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Utilities for interacting with ProxyStore"""
import logging
import warnings
from typing import Dict
from typing import Any, Dict, Union, List, Optional

import proxystore
from proxystore.proxy import extract
Expand All @@ -10,8 +10,6 @@
from proxystore.store.base import Store
from proxystore.store.utils import resolve_async, get_key

from typing import Any, Dict, Union, List, Optional

proxystore_version = tuple(int(v) for v in proxystore.__version__.split('.'))
if proxystore_version >= (0, 7, 0):
# In ProxyStore v0.7 and later, the Store config is a pydantic model.
Expand Down
11 changes: 8 additions & 3 deletions colmena/task_server/tests/test_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# Make global state for the retry task
RETRY_COUNT = 0


def retry_task(success_idx: int) -> bool:
"""Task that will succeed (return True) every `success_idx` times."""
global RETRY_COUNT
Expand All @@ -18,17 +19,19 @@ def retry_task(success_idx: int) -> bool:
if RETRY_COUNT < success_idx:
RETRY_COUNT += 1
raise ValueError('Retry')

# Reset the retry count
RETRY_COUNT = 0
return True


@fixture
def reset_retry_count():
"""Reset the retry count before each test."""
global RETRY_COUNT
RETRY_COUNT = 0


@fixture()
def config(tmpdir):
"""Make the Parsl configuration."""
Expand All @@ -40,8 +43,9 @@ def config(tmpdir):
run_dir=str(tmpdir / 'run'),
)


@fixture
def server_and_queue(config) -> Generator[Tuple[ParslTaskServer, ColmenaQueues], None, None]:
def server_and_queue(config) -> Generator[Tuple[ParslTaskServer, ColmenaQueues], None, None]:
queues = PipeQueues()
server = ParslTaskServer([retry_task], queues, config)
yield server, queues
Expand Down Expand Up @@ -73,11 +77,12 @@ def test_retry_policy_max_retries_zero(server_and_queue, reset_retry_count):
assert not result.success
assert 'Retry' in str(result.failure_info.exception)


@mark.timeout(10)
@mark.parametrize(('success_idx', 'max_retries'), [(0, 0), (1, 1), (4, 10)])
def test_retry_policy_max_retries(server_and_queue, reset_retry_count, success_idx: int, max_retries: int):
"""Test the retry policy.
This test checks the following cases:
- A task that always succeeds (success_idx=0, max_retries=0)
- A task that succeeds after one retry (success_idx=1, max_retries=1)
Expand Down

0 comments on commit 169751c

Please sign in to comment.