agent: |
FS6km40Slgy4DKab5lkmWait until the instance is running
Wait until the instance is running
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.
It takes a few seconds for the instance to come up. Keep checking the status for a few seconds. After a specified number of iterations, just give up and print an error message.
inputs
outputs
import time
op = ""
iter = 0
if "running" not in op and iter < 3:
cmd = f'aws ec2 describe-instances --instance-ids {instance_id} --query "Reservations[].Instances[].State.Name" --output text'
op = _exe(None, cmd)
iter = iter + 1
time.sleep(60)
cmd = f'aws ec2 describe-instances --instance-ids {instance_id} --query "Reservations[].Instances[].State.Name" --output text'
op = _exe(None, cmd)
task_title = context.task_title
if "running" not in op:
msg = f"Giving up. The host doesn't seem to be coming up: {instance_id}"
msg_type = "ERROR"
print(msg)
context.proceed = False
else:
msg = f"This instance {instance_id} is now running"
msg_type = "SUCCESS"
print(msg)
context.log(msg_type, msg)
context.job_context[task_title] = {"msg" : msg, "msg_type" : msg_type}
copied