-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Conversation
CodSpeed Performance ReportMerging #16053 will not alter performanceComparing Summary
|
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
78ef6a3
to
8d3ab49
Compare
prefect_aws.batch
prefect_aws.batch
off sync_compatible
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 |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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
?
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
related to #15008
migrates
prefect_aws.batch
tasks to explicit sync / async viaasync_dispatch
also updates
async_dispatch
to allow dispatching async task objectswill continue with
prefect_aws
after this PR