Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
Add logging to app, temporarily disable schedule, add todos
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarupilla committed Dec 29, 2020
1 parent 17b433c commit d5a71fa
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 48 deletions.
65 changes: 36 additions & 29 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: CI

on:
# push:
# branches:
# - dev
schedule:
- cron: "0 20 * * 1"
push:
branches:
- dev
# schedule:
# - cron: "0 20 * * 1"

jobs:
build:
Expand Down Expand Up @@ -34,31 +34,38 @@ jobs:
working-directory: ${{runner.workspace}}/test_suite
run: |
zip -r report_"`date +"%m_%d_%Y"`" \
report_generation/files/logs \
report_generation/files/results \
report_generation/files/bmdb_models \
report.txt
report_generation/files/logs \
report_generation/files/results \
report_generation/files/bmdb_models \
report.txt
- name: Create Release and Upload
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
tag_name: report_${{steps.date.outputs.format}}
release_name: report_${{steps.date.outputs.format}}
draft: false
prerelease: false
upload_url_type: application/zip
# - name: Create Release and Upload
# id: create_release
# uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.PAT }}
# with:
# tag_name: report_${{steps.date.outputs.format}}
# release_name: report_${{steps.date.outputs.format}}
# draft: false
# prerelease: false
# upload_url_type: application/zip

# - name: Upload Release Asset
# id: upload-release-asset
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.PAT }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./report_${{steps.date.outputs.format}}.zip
# asset_name: report_${{steps.date.outputs.format}}.zip
# asset_content_type: application/zip

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: 'Upload artifacts'
uses: actions/upload-artifact@v2
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./report_${{steps.date.outputs.format}}.zip
asset_name: report_${{steps.date.outputs.format}}.zip
asset_content_type: application/zip
name: comparison_report
path: artifact_${{steps.date.outputs.format}}.zip
if-no-files-found: warn

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,6 @@ report_generation/files/results/vcell/*
report_generation/files/results/copasi/*
!report_generation/files/results/copasi/.gitkeep

report.txt
report.txt

script.sh
5 changes: 3 additions & 2 deletions report_generation/combine/files_list.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from report_generation.config import Config
from logzero import logger

omex_path = Config.OMEX_FILE_PATH
sedml_doc_path = Config.SEDML_DOC_PATH
Expand All @@ -19,9 +20,9 @@ def sbml_file_list(self, path=model_files_path):
sbml_file = sbml_file.split('.')[0]
sbml_file_list.append(sbml_file)
elif sbml_file.split('.')[1] != 'xml':
print(f"{sbml_file} is not a model file\n")
logger.warning(f"{sbml_file} is not a model file\n")
else:
print(
logger.error(
f"No model files found in the directory {os.path.join(os.path.join(model_files_path))}\n")
return sbml_file_list

Expand Down
5 changes: 3 additions & 2 deletions report_generation/combine/omex_maker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from libcombine import *
from report_generation.combine.files_list import FilesList
from report_generation.config import Config
from logzero import logger

omex_path = Config.OMEX_FILE_PATH
sedml_doc_path = Config.SEDML_DOC_PATH
Expand Down Expand Up @@ -57,8 +58,8 @@ def create_omex_archive(sbml_name, sedml_name, simulator):
out_file = os.path.abspath(os.path.join(
omex_path, simulator, f"{sbml_name.split('.')[0]}.omex"))
archive.writeToFile(out_file)

print('Archive created:', out_file.split('/')[-1])
out_file_name = out_file.split('/')[-1]
logger.info(f'Archive created: {out_file_name}')

class GenOmex:
def omex_gen_vcell(self):
Expand Down
20 changes: 16 additions & 4 deletions report_generation/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,35 @@
from report_generation.sedml.sedml_maker import gen_sedml
from report_generation.comparator.comparator import gen_report
import subprocess
from logzero import logger

logger.debug("Download starting...")
download_sbml()
logger.debug("Download finished...\n\n")

print("Starting to generate SED-ML")
logger.debug("Starting to generate SED-ML documents...")
gen_sedml()
print("SED-ML generation finished")
logger.debug("SED-ML generation finished...\n\n")

logger.debug("Creating OMEX archives...")
omex = GenOmex()
omex.omex_gen_copasi()
omex.omex_gen_vcell()
logger.debug("Archive generation finished...\n\n")


logger.debug("Running COPASI simulations...")
copasi_run = subprocess.run(["./report_generation/run_script/run_copasi_sim.sh"])
print("The exit code was: %d" % copasi_run.returncode)
logger.info("The exit code was: %d" % copasi_run.returncode)
logger.debug("COPASI simulations finished...\n\n")


logger.debug("Running VCell simulations...")
vcell_run = subprocess.run(
["./report_generation/run_script/run_vcell_sim.sh"])
print("The exit code was: %d" % vcell_run.returncode)
logger.info("The exit code was: %d" % vcell_run.returncode)
logger.debug("VCell simulations finished...\n\n")

logger.debug("Generating report...")
gen_report()
logger.debug("Report generated...")
2 changes: 1 addition & 1 deletion report_generation/run_script/run_copasi_sim.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
pwd

cd report_generation
cd files
cd omex_archives
Expand Down
1 change: 0 additions & 1 deletion report_generation/run_script/run_vcell_sim.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash

pwd
cd report_generation
cd files
cd omex_archives
Expand Down
7 changes: 4 additions & 3 deletions report_generation/sbml/sbml_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import urllib
from bs4 import BeautifulSoup
import requests
from logzero import logger

model_files_path = Config.MODEL_FILES_PATH

Expand Down Expand Up @@ -37,13 +38,13 @@ def soup_scraper(model, headers):
return preview_url

def download_sbml():
for model in create_model_list(1000, 0, -1):
for model in create_model_list(10, 0, -1):
try:
sbml_file_link = Config.BASE_URL + soup_scraper(model, headers=headers)
urllib.request.urlretrieve(sbml_file_link, os.path.join(
model_files_path, f'{model}.xml'))
print(f'Downloaded {model}.xml')
logger.info(f'Downloaded {model}.xml')
except IndexError as IE:
print(f"{model}.xml is not published yet.")
logger.info(f"{model}.xml is not published yet.")
continue

12 changes: 8 additions & 4 deletions report_generation/sedml/sedml_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from report_generation.config import Config
import libsbml
import libsedml
from logzero import logger


model_files_path = Config.MODEL_FILES_PATH
Expand Down Expand Up @@ -55,7 +56,8 @@ def create_sedml(filename, simulator,
elif simulator == 'vcell':
alg.setKisaoID(f'KISAO:0000019')
else:
print(f"{simulator} is still not supported to generate the SED-ML")
logger.warning(
f"{simulator} is still not supported to generate the SED-ML")

# create a task that uses the simulation and the model above
task = doc.createTask()
Expand Down Expand Up @@ -118,7 +120,8 @@ def create_sedml(filename, simulator,

# write the document
libsedml.writeSedML(doc, os.path.join(sedml_doc_path, simulator, f'{filename}.sedml'))
print(f"SED-ML Document created for {simulator} with filename {filename}.sedml")
logger.info(
f"SED-ML Document created for {simulator} with filename {filename}.sedml")

def gen_sedml():
global model_files
Expand All @@ -130,7 +133,8 @@ def gen_sedml():
create_sedml(model_name, 'vcell')
create_sedml(model_name, 'copasi')
elif sbml_model.split('.')[1] != 'xml':
print(f"{sbml_model} is not a model file\n")
logger.warning(f"{sbml_model} is not a model file\n")
else:
print(f"No SBML files found in the directory {os.path.join(model_files_path)}\n")
logger.error(
f"No SBML files found in the directory {os.path.join(model_files_path)}\n")

Empty file.
1 change: 1 addition & 0 deletions report_generation/utils/logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#TODO: Add logger here, replace logzero
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ lxml
docker
pkg_utils
pandas
docker
docker
logzero

0 comments on commit d5a71fa

Please sign in to comment.