Skip to content

Commit

Permalink
Merge pull request #68 from wormjam-consortium/devel
Browse files Browse the repository at this point in the history
Fix the annotation bug, and reformat scripts with Black
  • Loading branch information
JakeHattwell authored Mar 1, 2021
2 parents 94bd632 + 2e39d25 commit 9fa6ecb
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 45 deletions.
24 changes: 15 additions & 9 deletions .github/tests/failure_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@
import sys
import datetime

DISCORD_ENDPOINT = sys.argv[1] #Github Actions Channel Webhook
GITHUB_BUILD_NUMBER = sys.argv[2] # Github build counter
GITHUB_BUILD_WEB_URL = sys.argv[3] # github unique run ID used for link construction
GITHUB_REPO_SLUG = sys.argv[4] # user/repo
GITHUB_REPO_BRANCH = sys.argv[5].split("/")[-1] #branch - process the string and grab the last term
DISCORD_ENDPOINT = sys.argv[1] # Github Actions Channel Webhook
GITHUB_BUILD_NUMBER = sys.argv[2] # Github build counter
GITHUB_BUILD_WEB_URL = sys.argv[3] # github unique run ID used for link construction
GITHUB_REPO_SLUG = sys.argv[4] # user/repo
GITHUB_REPO_BRANCH = sys.argv[5].split("/")[
-1
] # branch - process the string and grab the last term

payload_json = {
"embeds": [
{
"title": "WormJam CI Report",
"color": 10027008, #red
"color": 10027008, # red
"description": "A build has failed from [%s](%s) on branch %s"
% (GITHUB_REPO_SLUG, "https://github.com/" + GITHUB_REPO_SLUG,GITHUB_REPO_BRANCH),
% (
GITHUB_REPO_SLUG,
"https://github.com/" + GITHUB_REPO_SLUG,
GITHUB_REPO_BRANCH,
),
"fields": [
{"name": "Build Number", "value": str(GITHUB_BUILD_NUMBER)},
{
Expand All @@ -25,13 +31,13 @@
},
],
"thumbnail": {
"url":"https://avatars1.githubusercontent.com/u/44036562?s=280&v=4, " #github actions logo
"url": "https://avatars1.githubusercontent.com/u/44036562?s=280&v=4, " # github actions logo
},
"timestamp": str(datetime.datetime.now().isoformat()),
}
]
}
#send failure message
# send failure message
r = requests.post(
DISCORD_ENDPOINT,
data=json.dumps(payload_json),
Expand Down
24 changes: 15 additions & 9 deletions .github/tests/release_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,42 @@
import datetime


DISCORD_ENDPOINT = sys.argv[1] #Github Actions Channel Webhook
DISCORD_ENDPOINT = sys.argv[1] # Github Actions Channel Webhook
GITHUB_REPO_SLUG = sys.argv[2] # user/repo
GITHUB_REPO_BRANCH = sys.argv[3].split("/")[-1] #branch - process the string and grab the last term
GITHUB_REPO_BRANCH = sys.argv[3].split("/")[
-1
] # branch - process the string and grab the last term

timestamp = datetime.datetime.now().strftime("%Y_%m_%d__%H_%M_%S")
filename = "WormJam" + timestamp + ".tar.gz"

#prepare files for sending
# prepare files for sending
packaged_model_file = {filename: open("WormJam.tar.gz", "rb")}

#construct embed to send to discord
#This embed is used for both messages
# construct embed to send to discord
# This embed is used for both messages
payload_json = {
"embeds": [
{
"title": "WormJam Release",
"color": 2132223, #this is github action colour
"color": 2132223, # this is github action colour
"description": "Release from [%s](%s) for model version %s"
% (GITHUB_REPO_SLUG, "https://github.com/" + GITHUB_REPO_SLUG,GITHUB_REPO_BRANCH),
% (
GITHUB_REPO_SLUG,
"https://github.com/" + GITHUB_REPO_SLUG,
GITHUB_REPO_BRANCH,
),
"fields": [
{"name": "Version", "value": str(GITHUB_REPO_BRANCH)},
],
"thumbnail": {
"url": "https://avatars1.githubusercontent.com/u/44036562?s=280&v=4" #github actions logo
"url": "https://avatars1.githubusercontent.com/u/44036562?s=280&v=4" # github actions logo
},
"timestamp": str(datetime.datetime.now().isoformat()),
}
]
}
#Send the report
# Send the report
r = requests.post(
DISCORD_ENDPOINT,
data=json.dumps(payload_json),
Expand Down
28 changes: 17 additions & 11 deletions .github/tests/send_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,35 @@
import datetime


DISCORD_ENDPOINT = sys.argv[1] #Github Actions Channel Webhook
DISCORD_ENDPOINT_2 = sys.argv[2] # Model Uploads Channel Webhook
DISCORD_ENDPOINT = sys.argv[1] # Github Actions Channel Webhook
DISCORD_ENDPOINT_2 = sys.argv[2] # Model Uploads Channel Webhook
GITHUB_BUILD_NUMBER = sys.argv[3] # Github build counter
GITHUB_BUILD_WEB_URL = sys.argv[4] # github unique run ID used for link construction
GITHUB_REPO_SLUG = sys.argv[5] # user/repo
GITHUB_REPO_BRANCH = sys.argv[6].split("/")[-1] #branch - process the string and grab the last term
GITHUB_REPO_BRANCH = sys.argv[6].split("/")[
-1
] # branch - process the string and grab the last term

timestamp = datetime.datetime.now().strftime("%Y_%m_%d__%H_%M_%S")
filename = "WormJam" + timestamp + ".tar.gz"

#prepare files for sending
# prepare files for sending
report_file = {"Report.html": open("Report.html", "rb")}
packaged_model_file = {filename: open("WormJam.tar.gz", "rb")}

#construct embed to send to discord
#This embed is used for both messages
# construct embed to send to discord
# This embed is used for both messages
payload_json = {
"embeds": [
{
"title": "WormJam CI Report",
"color": 2132223, #this is github action colour
"color": 2132223, # this is github action colour
"description": "Model Build from [%s](%s) on branch %s"
% (GITHUB_REPO_SLUG, "https://github.com/" + GITHUB_REPO_SLUG,GITHUB_REPO_BRANCH),
% (
GITHUB_REPO_SLUG,
"https://github.com/" + GITHUB_REPO_SLUG,
GITHUB_REPO_BRANCH,
),
"fields": [
{"name": "Build Number", "value": str(GITHUB_BUILD_NUMBER)},
{
Expand All @@ -36,21 +42,21 @@
},
],
"thumbnail": {
"url": "https://avatars1.githubusercontent.com/u/44036562?s=280&v=4" #github actions logo
"url": "https://avatars1.githubusercontent.com/u/44036562?s=280&v=4" # github actions logo
},
"timestamp": str(datetime.datetime.now().isoformat()),
}
]
}
#Send the report
# Send the report
r = requests.post(
DISCORD_ENDPOINT,
data=json.dumps(payload_json),
headers={"Content-Type": "application/json"},
)
r2 = requests.post(DISCORD_ENDPOINT, files=report_file)
print(r, r2)
#send the model
# send the model
r3 = requests.post(
DISCORD_ENDPOINT_2,
data=json.dumps(payload_json),
Expand Down
26 changes: 13 additions & 13 deletions .github/tests/support/annotation.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from lxml import etree

#debugging
# debugging
from xml.etree import ElementTree

#if no database SBtab, then db_dict is an empty dict
# if no database SBtab, then db_dict is an empty dict


def _annotate(db_dict, ref):
"""Function to access reference links, and handle when those links are not in DB table
Takes a dict of databases and a database name"""
Takes a dict of databases and a database name"""
if ref in db_dict:
return db_dict[ref]["!IdentifiersOrgPrefix"]
else:
Expand All @@ -25,12 +26,11 @@ def _check_db_type(db_dict, ref):

def gen_annotation_tree(metaid, db_dict, data, NS_MAP):

annotation_tree = etree.SubElement(
etree.SubElement(
etree.Element("annotation"), "{%s}" % NS_MAP["rdf"] + "RDF"
),
"{%s}" % NS_MAP["rdf"] + "Description",
attrib={"{%s}" % NS_MAP["rdf"] + "about": "#" + metaid},
annotation_tree = etree.Element("annotation")

description = etree.SubElement(etree.SubElement(annotation_tree, "{%s}" % NS_MAP["rdf"] + "RDF"),
"{%s}" % NS_MAP["rdf"] + "Description",
attrib={"{%s}" % NS_MAP["rdf"] + "about": "#" + metaid},
)
# get a list of which DBs are annotated for this entry, as well as what type of DB they are
annotated_dbs = [
Expand All @@ -46,12 +46,12 @@ def gen_annotation_tree(metaid, db_dict, data, NS_MAP):
bqbiol_occurs_in_and_rdf_bag = False
if "Is" in db_types:
bqbiol_is_and_rdf_bag = etree.SubElement(
etree.SubElement(annotation_tree, "{%s}" % NS_MAP["bqbiol"] + "is"),
etree.SubElement(description, "{%s}" % NS_MAP["bqbiol"] + "is"),
"{%s}" % NS_MAP["rdf"] + "Bag",
)
if "In" in db_types:
bqbiol_occurs_in_and_rdf_bag = etree.SubElement(
etree.SubElement(annotation_tree, "{%s}" % NS_MAP["bqbiol"] + "isPartOf"),
etree.SubElement(description, "{%s}" % NS_MAP["bqbiol"] + "isPartOf"),
"{%s}" % NS_MAP["rdf"] + "Bag",
)
for db in annotated_dbs:
Expand Down Expand Up @@ -82,4 +82,4 @@ def gen_annotation_tree(metaid, db_dict, data, NS_MAP):
},
)

return annotation_tree
return annotation_tree
8 changes: 5 additions & 3 deletions .github/tests/tsv_to_sbml.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pyparsing as pp
from lxml import etree

#debugging
# debugging
from xml.etree import ElementTree

from support.helper_classes import ModelSystem
Expand Down Expand Up @@ -204,7 +204,9 @@ def genID():
"{%s}" % NS_MAP["fbc"] + "geneProduct",
attrib=attribs,
)
fbc_gene_prod.append(gen_annotation_tree(attribs["metaid"], db_dict, val, NS_MAP))
fbc_gene_prod.append(
gen_annotation_tree(attribs["metaid"], db_dict, val, NS_MAP)
)

#
# Pathways
Expand Down Expand Up @@ -527,7 +529,7 @@ def quick(frag):
+ val[i]
)

reaction_field.append(gen_annotation_tree(metaid,db_dict,val,NS_MAP))
reaction_field.append(gen_annotation_tree(metaid, db_dict, val, NS_MAP))
try:
reaction_field.append(process_gene_association(val["!GeneAssociation"]))
except Exception as e:
Expand Down

0 comments on commit 9fa6ecb

Please sign in to comment.