Skip to content

Commit

Permalink
making a better deployment spec for multiple environments and updatin…
Browse files Browse the repository at this point in the history
…g validate to match
  • Loading branch information
EvanDietzMorris committed Apr 19, 2024
1 parent 5dcc959 commit a7b1831
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 31 deletions.
106 changes: 106 additions & 0 deletions deploy/deployment_spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@

deployments:
- dev:
automat_url: https://automat.renci.org/
platers:
binding-db: a2be7202f6e0e329
cam-kp: 974c4a7f23f1088a
ctd: 50cb84a1eeeb4c06
drugcentral: 69dab8a3d7bce2f4
genome-alliance: c9a10307ecbb5f09
gtex: 7b82716a34a83ee2
gtopdb: ebcf5d12e388cf70
gwas-catalog: 6722acadeca463ef
hetio: 4fa8f269b9eb8831
hgnc: 732252c3b81b9fa4
hmdb: 1eb8c128aaca7d16
human-goa: f4137b0fccd76fc1
icees-kg: 10-25-2023
intact: 590258263f89111d
monarch-kg: 2024-03-18
panther: 399a2024b78947d3
pharos: 45dab165ca92e24d
reactome: c637a1b81cdf62da
robokopkg: 6fce5de1f1332b19
string-db: 6fe0eac4c12ee2b6
textminingkp: d14a28a2fa096e82
ubergraph: 7a3f64b6368aad3c
viral-proteome: 365c51354d2ed0cc
- ci:
automat_url: https://automat.ci.transltr.io/1.4/
platers:
binding-db: 711f33bcebbef313
cam-kp: e553a5174c60a698
ctd: 3d3553d73a030b29
drugcentral: 25acfc0e82d4f8c5
genome-alliance: 52b222baedc80328
gtex: 069168a67b09b862
gtopdb: 570e405b674eb991
gwas-catalog: 7c0cb91e678a3d1f
hetio: 1491072f27daadfc
hgnc: a49bc657186d2f87
hmdb: c31a890b052df047
human-goa: 50dc16e17d5763eb
icees-kg: 10-25-2023
intact: 95bbc26a9a1f8fb2
monarch-kg: 2023-09-15
panther: bfb3978535ac7d5f
pharos: 1a20bf45c2983099
reactome: d7df62d3266ae128
robokopkg: 81b624e768dac7d1
string-db: 6d1da8f1689a8bac
textminingkp: d14a28a2fa096e82
ubergraph: f6c87c92c433b5d7
viral-proteome: 8a78ab9faf52b16d
- testing:
automat_url: https://automat.test.transltr.io/1.4/
platers:
binding-db: 711f33bcebbef313
cam-kp: e553a5174c60a698
ctd: 3d3553d73a030b29
drugcentral: 25acfc0e82d4f8c5
genome-alliance: 52b222baedc80328
gtex: 069168a67b09b862
gtopdb: 570e405b674eb991
gwas-catalog: 7c0cb91e678a3d1f
hetio: 1491072f27daadfc
hgnc: a49bc657186d2f87
hmdb: c31a890b052df047
human-goa: 50dc16e17d5763eb
icees-kg: 10-25-2023
intact: 95bbc26a9a1f8fb2
monarch-kg: 2023-09-15
panther: bfb3978535ac7d5f
pharos: 1a20bf45c2983099
reactome: d7df62d3266ae128
robokopkg: 81b624e768dac7d1
string-db: 6d1da8f1689a8bac
textminingkp: d14a28a2fa096e82
ubergraph: f6c87c92c433b5d7
viral-proteome: 8a78ab9faf52b16d
- prod:
automat_url: https://automat.transltr.io/1.4/
platers:
binding-db: 711f33bcebbef313
cam-kp: e553a5174c60a698
ctd: 3d3553d73a030b29
drugcentral: 25acfc0e82d4f8c5
genome-alliance: 52b222baedc80328
gtex: 069168a67b09b862
gtopdb: 570e405b674eb991
gwas-catalog: 7c0cb91e678a3d1f
hetio: 1491072f27daadfc
hgnc: a49bc657186d2f87
hmdb: c31a890b052df047
human-goa: 50dc16e17d5763eb
icees-kg: 10-25-2023
intact: 95bbc26a9a1f8fb2
monarch-kg: 2023-09-15
panther: bfb3978535ac7d5f
pharos: 1a20bf45c2983099
reactome: d7df62d3266ae128
robokopkg: 81b624e768dac7d1
string-db: 6d1da8f1689a8bac
textminingkp: d14a28a2fa096e82
ubergraph: f6c87c92c433b5d7
viral-proteome: 8a78ab9faf52b16d
54 changes: 23 additions & 31 deletions deploy/validate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import requests
import os
import yaml

def validate_plater(url, expected_version):
results = {
Expand Down Expand Up @@ -62,10 +64,10 @@ def validate_plater(url, expected_version):
results['validation_errors'].append(f'Retrieving open api spec failed: {str(e)}')
return results
openapi_spec = openapi_response.json()
example_trapi_query = openapi_spec['paths']['/1.4/query']['post']['requestBody']['content']['application/json']['example']
example_trapi_query = openapi_spec['paths']['/query']['post']['requestBody']['content']['application/json']['example']

# send the example trapi query and make sure it works
trapi_query_response = requests.post(f'{url}1.4/query', json=example_trapi_query)
trapi_query_response = requests.post(f'{url}query', json=example_trapi_query)
if trapi_query_response.status_code != 200:
try:
cypher_response.raise_for_status()
Expand All @@ -85,35 +87,25 @@ def validate_plater(url, expected_version):

if __name__ == '__main__':

# NOTE - The automat urls and graph_deployment_spec(s) are hardcoded here, but we should be able to read from
# any deployment spec and test against the endpoint(s) specified within. This current set up is also wrong because
# graph versions/deployments are not necessarily the same across the environments.
automat_urls = ['https://automat.renci.org/',
'https://automat.ci.transltr.io/',
'https://automat.test.transltr.io/',
'https://automat.transltr.io/',
'https://robokop-automat.apps.renci.org/'] # TODO get these from a graph deployment spec
graph_deployment_specs = ['./new_graphs.txt'] # TODO get these from cli input

everything_is_good = True
for automat_url in automat_urls:
print(f'Validating deployments on {automat_url}')
for graph_deployment_spec_path in graph_deployment_specs:
with open(graph_deployment_spec_path) as graph_deployment_spec_file:
plater_validation_results = {}
for line in graph_deployment_spec_file:
split_line = line.split()
plater_id = split_line[0]
graph_version = split_line[1]
validation_results = validate_plater(f'{automat_url}{plater_id}/', graph_version)
validation_errors = "\n".join(validation_results['validation_errors'])
if validation_errors:
everything_is_good = False
error_message = f'Validation errors occurred for {plater_id} on {automat_url}: {validation_errors}'
print(error_message)
# else:
# print(f'{plater_id} ({graph_version}) on {automat_url} looks ok.')
plater_validation_results[plater_id] = validation_results
# TODO - do something with plater_validation_results other than print errors?
graph_deployment_spec_path = os.path.join(os.path.dirname(__file__), 'deployment_spec.yaml')
with open(graph_deployment_spec_path) as graph_deployment_spec_file:
deployment_spec = yaml.safe_load(graph_deployment_spec_file)
plater_validation_results = {}
for deployment in deployment_spec['deployments']:
automat_url = deployment['automat_url']
for plater_id, graph_version in deployment['platers'].items():
validation_results = validate_plater(f'{automat_url}{plater_id}/', graph_version)
validation_errors = "\n".join(validation_results['validation_errors'])
if validation_errors:
everything_is_good = False
error_message = f'Validation errors occurred for {plater_id} on {automat_url}: {validation_errors}'
print(error_message)
# else:
# print(f'{plater_id} ({graph_version}) on {automat_url} looks ok.')
plater_validation_results[plater_id] = validation_results
if everything_is_good:
print(f'Yay. Everything looks good.')

# TODO - do something with plater_validation_results other than print errors?

0 comments on commit a7b1831

Please sign in to comment.