Skip to content

Commit

Permalink
run task on ec2; not working
Browse files Browse the repository at this point in the history
  • Loading branch information
zzeppozz committed Oct 16, 2024
1 parent 6771781 commit a64dce2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
12 changes: 7 additions & 5 deletions aws/events/bison_s0_resolve_riis_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
external_schema = "redshift_spectrum"
timeout = 900
waittime = 1
bison_task_instance_id = "i-0595bfd381e64d2c9"
EC2_TASK_INSTANCE_ID = "i-0c7e54e257d5c8574"
EC2_KEY = bison_task_key
# bison_task_ec2 = "arn:aws:ec2:us-east-1:321942852011:instance/i-0595bfd381e64d2c9"

# Initialize Botocore session
Expand All @@ -28,7 +29,8 @@
client_ssm = session.client("ssm", config=config)

# Bison command
bison_script = "~/bison/bison/tools/annotate_riis.py"
bison_script = "venv/bin/python -m bison.tools.annotate_riis"


# --------------------------------------------------------------------------------------
def lambda_handler(event, context):
Expand All @@ -47,7 +49,7 @@ def lambda_handler(event, context):
Exception: on unknown error.
"""
response = client_ec2.start_instances(
InstanceIds=[bison_task_instance_id],
InstanceIds=[EC2_TASK_INSTANCE_ID],
AdditionalInfo="Task initiated by Lambda",
DryRun=False
)
Expand All @@ -69,7 +71,7 @@ def lambda_handler(event, context):
# sudo docker compose -f docker-compose.task.yml up
response = client_ssm.send_command(
DocumentName='AWS-RunShellScript',
Parameters={'commands': [script]},
InstanceIds=exec_list
Parameters={'commands': [bison_script]},
InstanceIds=[bison_task_instance_id]
)
return instance_id
2 changes: 1 addition & 1 deletion aws/permissions/policy/bison_create_run_ec2_policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"Resource": "arn:aws:ec2:us-east-1:321942852011:instance/i-0595bfd381e64d2c9"
}
]
}
}
2 changes: 1 addition & 1 deletion bison/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
GBIF_ODR_FNAME = "occurrence.parquet"

TMP_PATH = "/tmp"

EC2_TASK_INSTANCE_ID = "i-0c7e54e257d5c8574"
S3_BUCKET = f"{PROJECT}-{AWS_ACCOUNT}-{REGION}"
S3_IN_DIR = "input"
S3_OUT_DIR = "output"
Expand Down
1 change: 1 addition & 0 deletions flask_app/task/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def index():
"""
return render_template("task.index.html")


# .....................................................................................
# .....................................................................................
if __name__ == "__main__":
Expand Down

0 comments on commit a64dce2

Please sign in to comment.