o-nikolas commented on code in PR #69576:
URL: https://github.com/apache/airflow/pull/69576#discussion_r3540073216
##########
providers/amazon/tests/system/amazon/aws/example_bedrock_agentcore.py:
##########
@@ -58,20 +83,52 @@
test_context = sys_test_context_task()
env_id = test_context["ENV_ID"]
- runtime_name = f"airflow-agentcore-{env_id}"
+ runtime_name = f"airflow_agentcore_{env_id}"
+ bucket_name = f"airflow-agentcore-code-{env_id}"
+ s3_key = "code.zip"
+
+ # [START howto_setup_bedrock_agentcore]
+ create_bucket = S3CreateBucketOperator(
+ task_id="create_bucket",
+ bucket_name=bucket_name,
+ )
+
+ @dag.task
+ def upload_code(bucket: str, key: str):
+ """Create a zip with the agent code and upload it to S3."""
+ import io
+ import zipfile
+
+ import boto3
+
+ buf = io.BytesIO()
+ with zipfile.ZipFile(buf, "w", zipfile.ZIP_DEFLATED) as zf:
+ zf.writestr("main.py", CODE_CONTENT)
+ buf.seek(0)
+
+ boto3.client("s3").upload_fileobj(buf, bucket, key)
+
+ upload_code_task = upload_code(bucket_name, s3_key)
+ # [END howto_setup_bedrock_agentcore]
# [START howto_operator_bedrock_create_agent_runtime]
create_agent_runtime = BedrockCreateAgentRuntimeOperator(
task_id="create_agent_runtime",
agent_runtime_name=runtime_name,
agent_runtime_artifact={
- "containerConfiguration": {
- "containerUri": test_context[CONTAINER_URI_KEY],
+ "codeConfiguration": {
+ "code": {
+ "s3": {
+ "bucket": bucket_name,
+ "prefix": s3_key,
+ },
+ },
+ "runtime": "PYTHON_3_12",
+ "entryPoint": ["main.py"],
},
},
role_arn=test_context[ROLE_ARN_KEY],
network_configuration={"networkMode": "PUBLIC"},
- deferrable=True,
Review Comment:
Good catch
##########
providers/amazon/tests/system/amazon/aws/example_bedrock_agentcore.py:
##########
@@ -58,20 +83,52 @@
test_context = sys_test_context_task()
env_id = test_context["ENV_ID"]
- runtime_name = f"airflow-agentcore-{env_id}"
+ runtime_name = f"airflow_agentcore_{env_id}"
+ bucket_name = f"airflow-agentcore-code-{env_id}"
+ s3_key = "code.zip"
+
+ # [START howto_setup_bedrock_agentcore]
+ create_bucket = S3CreateBucketOperator(
+ task_id="create_bucket",
+ bucket_name=bucket_name,
+ )
+
+ @dag.task
+ def upload_code(bucket: str, key: str):
+ """Create a zip with the agent code and upload it to S3."""
+ import io
+ import zipfile
+
+ import boto3
Review Comment:
Any reason for local imports?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]