-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ready for aws cloudformation testing
- Loading branch information
Showing
68 changed files
with
1,595 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import time | ||
from subprocess import call | ||
|
||
import requests | ||
|
||
|
||
def check_spot_termination(): | ||
"""Check for Spot Instance termination notice.""" | ||
termination_url = "http://169.254.169.254/latest/meta-data/spot/instance-action" | ||
try: | ||
response = requests.get(termination_url, timeout=2) | ||
if response.status_code == 200: | ||
return True | ||
except requests.exceptions.RequestException: | ||
pass | ||
return False | ||
|
||
|
||
def graceful_shutdown(): | ||
"""Initiate a graceful shutdown of the Celery worker.""" | ||
# Replace `celery_worker_name` with the actual name of your worker | ||
call(["pkill", "-9", "celery"]) | ||
|
||
|
||
if __name__ == "__main__": | ||
while True: | ||
if check_spot_termination(): | ||
print("Spot Instance termination notice detected. Initiating graceful shutdown.") | ||
graceful_shutdown() | ||
break | ||
time.sleep(30) # Check every 30 seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit | ||
set -o pipefail | ||
set -o nounset | ||
|
||
# N.B. If only .env files supported variable expansion... | ||
export CELERY_BROKER_URL="redis://${REDIS_HOST}:${REDIS_PORT}/0" | ||
|
||
if [ -z "${POSTGRES_USER}" ]; then | ||
base_postgres_image_default_user='postgres' | ||
export POSTGRES_USER="${base_postgres_image_default_user}" | ||
fi | ||
export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}" | ||
|
||
python << END | ||
import sys | ||
import time | ||
import psycopg | ||
def database_exists(conn_params, dbname): | ||
with psycopg.connect(**conn_params) as conn: | ||
with conn.cursor() as cur: | ||
cur.execute("SELECT 1 FROM pg_database WHERE datname = %s", (dbname,)) | ||
return cur.fetchone() is not None | ||
def create_database(conn_params, dbname): | ||
with psycopg.connect(**conn_params) as conn: | ||
conn.autocommit = True | ||
with conn.cursor() as cur: | ||
cur.execute(f"CREATE DATABASE \"{dbname}\"") | ||
conn_params = { | ||
"dbname": "postgres", # connect to the default database to check/create | ||
"user": "${POSTGRES_USER}", | ||
"password": "${POSTGRES_PASSWORD}", | ||
"host": "${POSTGRES_HOST}", | ||
"port": "${POSTGRES_PORT}" | ||
} | ||
dbname = "${POSTGRES_DB}" | ||
if not database_exists(conn_params, dbname): | ||
print("Database does not exist. Creating database: {}".format(dbname)) | ||
create_database(conn_params, dbname) | ||
else: | ||
print("Database {} already exists.".format(dbname)) | ||
# Now connect to the target database | ||
conn_params["dbname"] = dbname | ||
with psycopg.connect(**conn_params) as conn: | ||
print('Connected to the database successfully') | ||
END | ||
|
||
>&2 echo 'PostgreSQL is available' | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -553,4 +553,4 @@ | |
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{ | ||
"model_name": "Binding", | ||
"fields": [ | ||
{ | ||
"name": "id", | ||
"type": "BigAutoField" | ||
}, | ||
{ | ||
"name": "upload_date", | ||
"type": "DateField" | ||
}, | ||
{ | ||
"name": "modified_date", | ||
"type": "DateTimeField" | ||
}, | ||
{ | ||
"name": "batch", | ||
"type": "CharField" | ||
}, | ||
{ | ||
"name": "replicate", | ||
"type": "PositiveIntegerField" | ||
}, | ||
{ | ||
"name": "source_orig_id", | ||
"type": "CharField" | ||
}, | ||
{ | ||
"name": "strain", | ||
"type": "CharField" | ||
}, | ||
{ | ||
"name": "condition", | ||
"type": "CharField" | ||
}, | ||
{ | ||
"name": "file", | ||
"type": "FileField" | ||
}, | ||
{ | ||
"name": "genomic_inserts", | ||
"type": "PositiveIntegerField" | ||
}, | ||
{ | ||
"name": "mito_inserts", | ||
"type": "PositiveIntegerField" | ||
}, | ||
{ | ||
"name": "plasmid_inserts", | ||
"type": "PositiveIntegerField" | ||
}, | ||
{ | ||
"name": "notes", | ||
"type": "CharField" | ||
} | ||
], | ||
"relationships": [ | ||
{ | ||
"name": "bindingmanualqc", | ||
"related_model": "BindingManualQC", | ||
"type": "UnknownRelation" | ||
}, | ||
{ | ||
"name": "promotersetsig", | ||
"related_model": "PromoterSetSig", | ||
"type": "UnknownRelation" | ||
}, | ||
{ | ||
"name": "uploader", | ||
"related_model": "User", | ||
"type": "ForeignKey" | ||
}, | ||
{ | ||
"name": "modifier", | ||
"related_model": "User", | ||
"type": "ForeignKey" | ||
}, | ||
{ | ||
"name": "regulator", | ||
"related_model": "Regulator", | ||
"type": "ForeignKey" | ||
}, | ||
{ | ||
"name": "source", | ||
"related_model": "DataSource", | ||
"type": "ForeignKey" | ||
} | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"model_name": "BindingManualQC", | ||
"fields": [ | ||
{ | ||
"name": "id", | ||
"type": "BigAutoField" | ||
}, | ||
{ | ||
"name": "upload_date", | ||
"type": "DateField" | ||
}, | ||
{ | ||
"name": "modified_date", | ||
"type": "DateTimeField" | ||
}, | ||
{ | ||
"name": "best_datatype", | ||
"type": "CharField" | ||
}, | ||
{ | ||
"name": "data_usable", | ||
"type": "CharField" | ||
}, | ||
{ | ||
"name": "passing_replicate", | ||
"type": "CharField" | ||
}, | ||
{ | ||
"name": "rank_recall", | ||
"type": "CharField" | ||
}, | ||
{ | ||
"name": "notes", | ||
"type": "CharField" | ||
} | ||
], | ||
"relationships": [ | ||
{ | ||
"name": "uploader", | ||
"related_model": "User", | ||
"type": "ForeignKey" | ||
}, | ||
{ | ||
"name": "modifier", | ||
"related_model": "User", | ||
"type": "ForeignKey" | ||
}, | ||
{ | ||
"name": "binding", | ||
"related_model": "Binding", | ||
"type": "ForeignKey" | ||
} | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.