Skip to content

Commit

Permalink
fix impl
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz committed Dec 20, 2024
1 parent 05c2a5a commit 2055ed9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/prefect/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ async def _call_explicitly_async_block_method(
see https://github.com/PrefectHQ/prefect/issues/15008
"""
if hasattr(block, f"a{method}"): # explicit async method
return await getattr(block, f"a{method}")(*args, **kwargs)
logger.debug(f"Calling explicit async method {block}.a{method}")
return await getattr(block.__class__.__name__, f"a{method}")(*args, **kwargs)
elif hasattr(getattr(block, method, None), "aio"): # sync_compatible
return await getattr(block, method).aio(block, *args, **kwargs)
else: # should not happen in prefect, but users can override impls
Expand Down
10 changes: 5 additions & 5 deletions tests/results/test_state_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ def store(storage_block: WritableFileSystem) -> ResultStore:


@pytest.fixture
async def a_real_result(store) -> ResultRecord:
async def a_real_result(store: ResultStore) -> ResultRecord[str]:
return store.create_result_record(
"test-graceful-retry",
)


@pytest.fixture
def completed_state(a_real_result: ResultRecord) -> State[str]:
def completed_state(a_real_result: ResultRecord[str]) -> State[str]:
return State(type=StateType.COMPLETED, data=a_real_result.metadata)


Expand Down Expand Up @@ -107,7 +107,7 @@ async def test_graceful_retries_reraise_last_error_while_retrieving_missing_resu
now = time.monotonic()
with pytest.raises(FileNotFoundError):
with mock.patch(
"prefect.filesystems.LocalFileSystem.read_path",
"prefect.filesystems.LocalFileSystem.read_path.aio",
new=mock.AsyncMock(
side_effect=[
OSError,
Expand All @@ -129,7 +129,7 @@ async def test_graceful_retries_reraise_last_error_while_retrieving_missing_resu

async def test_graceful_retries_eventually_succeed_while(
shorter_result_retries: None,
a_real_result: ResultRecord,
a_real_result: ResultRecord[str],
completed_state: State[str],
store: ResultStore,
):
Expand All @@ -147,7 +147,7 @@ async def test_graceful_retries_eventually_succeed_while(
# even if it misses a couple times, it will eventually return the data
now = time.monotonic()
with mock.patch(
"prefect.filesystems.LocalFileSystem.read_path",
"prefect.filesystems.LocalFileSystem.read_path.aio",
new=mock.AsyncMock(
side_effect=[
FileNotFoundError,
Expand Down

0 comments on commit 2055ed9

Please sign in to comment.