-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8c3fec0
Showing
24 changed files
with
3,499 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import sys | ||
import os | ||
import requests | ||
|
||
from ersilia_pack.parsers import DockerfileInstallParser, YAMLInstallParser | ||
|
||
REPO_PATH = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../..")) | ||
PY_VERSION_MAP = { | ||
'3.8': 'py38', | ||
'3.9': 'py39', | ||
'3.10': 'py310', | ||
'3.11': 'py311', | ||
'3.12': 'py312' | ||
} | ||
model_id = sys.argv[1] | ||
def resolve_parser(): | ||
if os.path.exists(os.path.abspath(os.path.join(REPO_PATH, "Dockerfile"))): | ||
return DockerfileInstallParser(file_dir=REPO_PATH) | ||
elif os.path.exists(os.path.join(REPO_PATH, "install.yml")): | ||
return YAMLInstallParser(file_dir=REPO_PATH) | ||
else: | ||
raise ValueError("No install file found") | ||
|
||
def resolve_python_version(parser): | ||
return parser._get_python_version() | ||
|
||
def read_dockerfile(parser): | ||
commands = parser._get_commands() | ||
has_conda = parser._has_conda(commands) | ||
if has_conda: | ||
file_url = "https://raw.githubusercontent.com/ersilia-os/ersilia/master/dockerfiles/dockerize-ersiliapack/model/Dockerfile.conda" | ||
else: | ||
file_url = "https://raw.githubusercontent.com/ersilia-os/ersilia/master/dockerfiles/dockerize-ersiliapack/model/Dockerfile.pip" | ||
response = requests.get(file_url) | ||
return response.text | ||
|
||
def write_version_and_model_id(file_content, python_version): | ||
python_version = PY_VERSION_MAP[python_version] | ||
file_content = file_content.replace("eos_identifier", model_id) | ||
lines = file_content.split("\n") | ||
lines[0] = lines[0].replace("VERSION", python_version) | ||
with open(os.path.join(REPO_PATH, "../", "Dockerfile"), "w") as f: | ||
f.write("\n".join(lines)) | ||
|
||
if __name__ == "__main__": | ||
parser = resolve_parser() | ||
python_version = resolve_python_version(parser) | ||
dockerfile = read_dockerfile(parser) | ||
write_version_and_model_id(dockerfile, python_version) |
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,27 @@ | ||
import csv | ||
|
||
def check_non_null_outcomes_in_output_csv(csv_file_path): | ||
with open(csv_file_path, 'r') as csv_file: | ||
csv_reader = csv.reader(csv_file) | ||
header = next(csv_reader) | ||
row = next(csv_reader) | ||
for val in row[2:]: # Skip the first two columns (Inchikey and input) | ||
if val not in ['', None]: # Returns if even one outcome is not null | ||
return False | ||
return True | ||
|
||
if __name__ == '__main__': | ||
# Read file path from command line | ||
import sys | ||
if len(sys.argv) < 2: | ||
print('Usage: python verify_model_output.py <output_csv_file>') | ||
exit(1) | ||
|
||
output_csv_file = sys.argv[1] | ||
|
||
if check_non_null_outcomes_in_output_csv(output_csv_file): | ||
# If there are null outcomes, exit with status code 1 | ||
print('All outcomes are null') | ||
else: | ||
print('Some outcomes are not null') | ||
|
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,18 @@ | ||
name: json syntax check | ||
|
||
on: | ||
push: | ||
paths: | ||
- "**.json" | ||
pull_request: | ||
|
||
jobs: | ||
json-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # pin@v3.5.2 | ||
|
||
- name: json syntax check | ||
id: json-yaml-validate | ||
uses: GrantBirki/json-yaml-validate@87b2d309a02f4942c5e602183eeea11008a640f9 # pin@v1.4.0 |
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,20 @@ | ||
name: Call post model upload actions | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Call test model image"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
call-post-upload-actions: | ||
if: github.event.workflow_run.conclusion == 'success' | ||
uses: ersilia-os/ersilia-model-workflows/.github/workflows/post-model-upload.yml@main | ||
with: | ||
repo_name: ${{ github.event.repository.name }} | ||
secrets: | ||
AIRTABLE_API_KEY: ${{ secrets.AIRTABLE_API_KEY }} | ||
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} |
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,17 @@ | ||
name: Send Slack message | ||
on: | ||
issues: | ||
types: [opened] | ||
|
||
jobs: | ||
slack: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: post slack | ||
uses: slackapi/slack-github-action@v1.23.0 | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }} | ||
with: | ||
slack-message: | | ||
"new issue: https://github.com/${{ github.repository }}/issues/${{ github.event.issue.number }} created." | ||
channel-id: ${{ secrets.SLACK_CHANNEL_TESTER }} |
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,17 @@ | ||
name: Call test model image | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Upload model to dockerhub"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
test-model: | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
uses: ersilia-os/ersilia-model-workflows/.github/workflows/test-model-image.yml@main | ||
with: | ||
repo_name: ${{ github.event.repository.name }} | ||
secrets: | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} |
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,71 @@ | ||
# This workflow only tests the model on PRs, not on every push to the main branch. | ||
# TODO(@dhanshree): Test ersilia in all supported Python versions | ||
name: Model Test on PR | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
if: github.repository != 'ersilia-os/eos-template' | ||
runs-on: ubuntu-latest | ||
steps: | ||
# This might stop working in the future, so we need to keep an eye on it | ||
- name: Free Disk Space (Ubuntu) | ||
uses: jlumbroso/free-disk-space@main | ||
with: | ||
# this might remove tools that are actually needed, | ||
# if set to "true" but frees about 6 GB | ||
tool-cache: true | ||
|
||
# all of these default to true, but feel free to set to | ||
# "false" if necessary for your workflow | ||
android: true | ||
dotnet: true | ||
haskell: true | ||
large-packages: true | ||
swap-storage: true | ||
|
||
- uses: actions/checkout@v4.2.2 | ||
with: | ||
lfs: true | ||
- uses: conda-incubator/setup-miniconda@v3 | ||
with: | ||
auto-update-conda: true | ||
python-version: "3.10.10" | ||
|
||
- name: Install dependencies | ||
run: | | ||
conda install git-lfs -c conda-forge | ||
git-lfs install | ||
conda install gh -c conda-forge | ||
python -m pip install 'ersilia[test]' | ||
# TODO(@dhanshree) We can potentially restore the retries. | ||
# TODO(@dhanshree) Correct the test command as needed | ||
- name: Test model | ||
env: | ||
MODEL_ID: ${{ github.event.repository.name }} | ||
run: | | ||
ersilia -v test $MODEL_ID --shallow > test.log | ||
# Remove mock.txt if it exists | ||
- name: Cleanup | ||
run: | | ||
if [ -f "mock.txt" ]; then | ||
echo "Removing mock.txt file" | ||
rm "mock.txt" | ||
else | ||
echo "mock.txt not found, skipping removal" | ||
fi | ||
# Upload EOS logs and test logs | ||
- name: Upload log output | ||
if: always() | ||
uses: actions/upload-artifact@v4.5.0 | ||
with: | ||
name: debug-logs | ||
retention-days: 14 | ||
path: | | ||
/home/runner/eos/*.log | ||
./*.log |
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,19 @@ | ||
name: Call test model source | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
call-model-test: | ||
if: github.repository != 'ersilia-os/eos-template' | ||
uses: ersilia-os/ersilia-model-workflows/.github/workflows/test-model-source.yml@main | ||
with: | ||
branch: "main" | ||
repo_name: ${{ github.event.repository.name }} | ||
secrets: | ||
AIRTABLE_API_KEY: ${{ secrets.AIRTABLE_API_KEY }} | ||
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
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,43 @@ | ||
name: Upload model to dockerhub | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Call upload model to s3"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
# Ersilia Pack Build | ||
upload-ersilia-pack: | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
uses: ersilia-os/ersilia-model-workflows/.github/workflows/upload-ersilia-pack.yml@main | ||
with: | ||
repo_name: ${{ github.event.repository.name }} | ||
secrets: | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
# BentoML Multistage Build (runs if Ersilia Pack fails) | ||
upload-bentoml-multistage: | ||
needs: upload-ersilia-pack | ||
if: ${{ needs.upload-ersilia-pack.result == 'failure' }} | ||
uses: ersilia-os/ersilia-model-workflows/.github/workflows/upload-bentoml.yml@main | ||
with: | ||
repo_name: ${{ github.event.repository.name }} | ||
version: multistage-condapack | ||
secrets: | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
# BentoML Legacy Build (runs only if both previous jobs fail) | ||
upload-bentoml-legacy: | ||
needs: [upload-ersilia-pack, upload-bentoml-multistage] | ||
if: ${{ needs.upload-ersilia-pack.result == 'failure' && needs.upload-bentoml-multistage.result == 'failure' }} | ||
uses: ersilia-os/ersilia-model-workflows/.github/workflows/upload-bentoml.yml@main | ||
with: | ||
repo_name: ${{ github.event.repository.name }} | ||
version: legacy | ||
secrets: | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
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,19 @@ | ||
name: Call upload model to s3 | ||
|
||
on: | ||
workflow_dispatch: | ||
workflow_run: | ||
workflows: ["Call test model source"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
upload: | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
uses: ersilia-os/ersilia-model-workflows/.github/workflows/upload-model-to-s3.yml@main | ||
with: | ||
repo_name: ${{ github.event.repository.name }} | ||
secrets: | ||
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
AIRTABLE_API_KEY: ${{ secrets.AIRTABLE_API_KEY }} |
Oops, something went wrong.