Zivile
07/09/2025, 9:29 AMMarvin
07/09/2025, 9:29 AMMarvin
07/09/2025, 9:29 AMwait_for_completion attribute is not directly available on the GlueJobBlock itself. Instead, when working with AWS Glue jobs in Prefect, you should use the run() method which has a wait_for_completion parameter.
Here's the correct way to use it:
python
from prefect_aws import GlueJobBlock
glue_job = GlueJobBlock.load("your-block-name")
result = glue_job.run(
wait_for_completion=True # This is a parameter of the run() method, not an attribute
)
The error you're seeing suggests you might be trying to access wait_for_completion directly on the block object, which isn't correct. The parameter should be passed to the run() method instead.
If you're still experiencing issues, could you share:
1. The complete code snippet you're using
2. The version of prefect-aws you have installed
This would help me provide more specific guidance.
Also, make sure you have the latest version of prefect-aws installed. You can upgrade it using:
bash
pip install -U prefect-awsZivile
07/09/2025, 9:32 AMMarvin
07/09/2025, 9:33 AMMarvin
07/09/2025, 9:33 AMGlueClient class, not directly through the GlueJobBlock. Here's the proper way to do it:
python
from prefect_aws import AwsCredentials
from prefect_aws.glue import GlueClient, GlueJobBlock
# First, load your Glue job block
glue_job_block = GlueJobBlock.load("your-block-name")
# Create a Glue client
aws_credentials = AwsCredentials.load("your-aws-credentials-block")
glue_client = GlueClient(aws_credentials=aws_credentials)
# Start the job and wait for completion
response = glue_client.run_job(
job_name=glue_job_block.job_name,
wait_for_completion=True
)
The GlueJobBlock is used to store the configuration of your Glue job, but the actual execution is handled by the GlueClient. The run_job method of the GlueClient is what provides the wait_for_completion parameter.
Make sure you have:
1. Created and saved an AWS credentials block
2. Created and saved a Glue job block with your job configuration
3. The latest version of prefect-aws installed
If you're still having issues, please share:
1. The version of prefect-aws you're using
2. The complete code snippet that's causing the error
This will help me provide more targeted assistance.Zivile
07/09/2025, 10:04 AMMarvin
07/09/2025, 10:04 AMMarvin
07/09/2025, 10:05 AMbash
pip install prefect-aws-glue
2. Then register the blocks from this collection:
bash
prefect block register -m prefect_aws_glue
After doing this, you should see the Glue-related blocks available in your Prefect instance.
The confusion arose because Glue functionality was moved to its own collection to keep the main prefect-aws package lighter and more modular. You can find more information about prefect-aws-glue in the prefect-aws-glue collection documentation.
Once you have installed and registered the blocks from prefect-aws-glue, you'll be able to use them in your flows. Let me know if you need help with the actual implementation after getting the blocks registered.Zivile
07/09/2025, 10:12 AMMarvin
07/09/2025, 10:13 AMMarvin
07/09/2025, 10:13 AMGlueJobBlock
2. The existence of prefect-aws-glue
3. The specific implementation details I provided
If you need to interact with AWS Glue from Prefect, you'll need to use the AWS SDK (boto3) directly. Here's a basic example of how you could create a task to run a Glue job:
python
from prefect import task
import boto3
@task
def run_glue_job(job_name: str, wait_for_completion: bool = True):
glue_client = boto3.client('glue')
# Start the Glue job
response = glue_client.start_job_run(JobName=job_name)
job_run_id = response['JobRunId']
if wait_for_completion:
waiter = glue_client.get_waiter('job_run_completed')
waiter.wait(
JobName=job_name,
RunId=job_run_id,
WaiterConfig={'Delay': 30, 'MaxAttempts': 60}
)
return job_run_id
You can use this with your AWS credentials stored in a Prefect AWS Credentials block:
python
from prefect import flow
from prefect_aws import AwsCredentials
@flow
def run_my_glue_job():
# Load AWS credentials from block
aws_credentials = AwsCredentials.load("your-block-name")
# Configure boto3 session with credentials
aws_credentials.configure_boto3_session()
# Run the Glue job
job_run_id = run_glue_job("your-glue-job-name")
return job_run_id
If you're interested in having official AWS Glue support in Prefect, you might want to:
1. Create a feature request in the prefect-aws repository
2. Consider contributing the integration yourself (the Prefect team welcomes community contributions)
Again, I apologize for my earlier incorrect responses. Would you like me to provide more details about implementing specific AWS Glue functionality using boto3 with Prefect?Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by