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

migrate prefect_aws.batch off sync_compatible #16053

Merged
merged 2 commits into from
Nov 19, 2024
Merged

Conversation

zzstoatzz
Copy link
Collaborator

@zzstoatzz zzstoatzz commented Nov 19, 2024

related to #15008

migrates prefect_aws.batch tasks to explicit sync / async via async_dispatch

also updates async_dispatch to allow dispatching async task objects

will continue with prefect_aws after this PR

@github-actions github-actions bot added the enhancement An improvement of an existing feature label Nov 19, 2024
Copy link

codspeed-hq bot commented Nov 19, 2024

CodSpeed Performance Report

Merging #16053 will not alter performance

Comparing async-dispatch-aws-batch (e6dd4c8) with main (de2f6fd)

Summary

✅ 3 untouched benchmarks

@zzstoatzz zzstoatzz added integrations Related to integrations with other services development Tech debt, refactors, CI, tests, and other related work. and removed enhancement An improvement of an existing feature labels Nov 19, 2024
Comment on lines 87 to 128
assert_valid_job_id(job_id)


async def test_batch_submit_async_dispatch(
job_queue_arn, job_definition_arn, aws_credentials
):
@flow
async def test_flow():
return await batch_submit(
"batch_test_job",
job_queue_arn,
job_definition_arn,
aws_credentials,
)

job_id = await test_flow()
assert_valid_job_id(job_id)


async def test_batch_submit_explicit_async(
job_queue_arn, job_definition_arn, aws_credentials
):
job_id = await batch_submit_async(
"batch_test_job",
job_queue_arn,
job_definition_arn,
aws_credentials,
)
assert_valid_job_id(job_id)


async def test_batch_submit_force_sync_from_async(
job_queue_arn, job_definition_arn, aws_credentials
):
job_id = batch_submit(
"batch_test_job",
job_queue_arn,
job_definition_arn,
aws_credentials,
_sync=True,
)
assert_valid_job_id(job_id)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tried a couple permutations of pytest tricks but explicitly writing out the individual cases felt simplest to me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The smallest of nits, but can you group the tests into classes so it's easier to find the tests for each implementation?

@zzstoatzz zzstoatzz marked this pull request as ready for review November 19, 2024 15:53
@zzstoatzz zzstoatzz self-assigned this Nov 19, 2024
@github-actions github-actions bot added enhancement An improvement of an existing feature labels Nov 19, 2024
@zzstoatzz zzstoatzz changed the title migrate prefect_aws.batch migrate prefect_aws.batch off sync_compatible Nov 19, 2024
Comment on lines +25 to +30
def _is_acceptable_callable(obj: Union[Callable, Task]) -> bool:
if inspect.iscoroutinefunction(obj):
return True
if isinstance(obj, Task) and inspect.iscoroutinefunction(obj.fn):
return True
return False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we'll need to bump the version of prefect in prefect-aws to get this change?

from prefect_aws.credentials import AwsCredentials


@task
@sync_compatible
async def batch_submit(
async def batch_submit_async(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be abatch_submit?

Comment on lines 87 to 128
assert_valid_job_id(job_id)


async def test_batch_submit_async_dispatch(
job_queue_arn, job_definition_arn, aws_credentials
):
@flow
async def test_flow():
return await batch_submit(
"batch_test_job",
job_queue_arn,
job_definition_arn,
aws_credentials,
)

job_id = await test_flow()
assert_valid_job_id(job_id)


async def test_batch_submit_explicit_async(
job_queue_arn, job_definition_arn, aws_credentials
):
job_id = await batch_submit_async(
"batch_test_job",
job_queue_arn,
job_definition_arn,
aws_credentials,
)
assert_valid_job_id(job_id)


async def test_batch_submit_force_sync_from_async(
job_queue_arn, job_definition_arn, aws_credentials
):
job_id = batch_submit(
"batch_test_job",
job_queue_arn,
job_definition_arn,
aws_credentials,
_sync=True,
)
assert_valid_job_id(job_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The smallest of nits, but can you group the tests into classes so it's easier to find the tests for each implementation?

Copy link
Member

@desertaxle desertaxle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@zzstoatzz zzstoatzz merged commit 743c4ee into main Nov 19, 2024
41 checks passed
@zzstoatzz zzstoatzz deleted the async-dispatch-aws-batch branch November 19, 2024 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Tech debt, refactors, CI, tests, and other related work. enhancement An improvement of an existing feature integrations Related to integrations with other services
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants