Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ersilia-os/ersilia
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelduranfrigola committed May 7, 2024
2 parents 4dc14b1 + f83ce42 commit f548a27
Show file tree
Hide file tree
Showing 61 changed files with 905 additions and 475 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ✍️ Outreachy Winter 23
description: Track your contribution period to Outreachy 2023
name: ✍️ Outreachy Summer 24
description: Track your contribution period to Outreachy 2024
title: "✍️ Contribution period: <your_name> "
labels: [internship]

Expand All @@ -18,35 +18,37 @@ body:
required: false
- label: Install the Ersilia Model Hub and test the simplest model
required: false
- label: Install Docker if needed, and test another model
required: false
- label: Write a motivation statement to work at Ersilia
required: false
- label: Submit your first contribution to the Outreachy site
required: false
- type: checkboxes
attributes:
label: Week 2 - Install and run an ML model
label: Week 2 - Get Familiar with Machine Learning for Chemistry
description: Please complete the following tasks and mark them once finished
options:
- label: Select a model from the suggested list
- label: Select a model from the list suggested in GitBook
required: false
- label: Install the model in your system
- label: Download and serve the model via the Ersilia Model Hub to ensure it works
required: false
- label: Run predictions for the EML
- label: Open a repository on your GitHub user with all the necessary files
required: false
- label: Compare results with the Ersilia Model Hub implementation!
- label: Select and clean a dataset of 1000 molecules (example notebook 1)
required: false
- label: Install and run Docker!
- label: Run predictions for the molecules on the selected model and evaluate the results
required: false
- type: checkboxes
attributes:
label: Week 3 - Propose new models
label: Week 3 - Validate a Model in the Wild
description: Please complete the following tasks and mark them once finished
options:
- label: Suggest a new model and document it (1)
- label: Find a suitable dataset with sufficient experimental results
required: false
- label: Suggest a new model and document it (2)
- label: Clean and standardize the dataset
required: false
- label: Suggest a new model and document it (3)
- label: Run predictions and calculate metrics.
required: false
- type: checkboxes
attributes:
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/project-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ body:
- Initiative 🐋
- Epic 🐅
- Batch 🐕
- Task 🐈
- type: textarea
id: objectives
attributes:
Expand Down
35 changes: 0 additions & 35 deletions .github/scripts/convert_airtable_to_csv.py

This file was deleted.

40 changes: 40 additions & 0 deletions .github/scripts/convert_airtable_to_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os
import json
import logging
import boto3
from botocore.exceptions import ClientError, NoCredentialsError
import requests

AIRTABLE_MODEL_HUB_BASE_ID = "appgxpCzCDNyGjWc8"
AIRTABLE_TABLE_ID = 'tblZGe2a2XeBxrEHP'
AWS_ACCOUNT_REGION = "eu-central-1"
ERSILIA_MODEL_HUB_S3_BUCKET= 'ersilia-model-hub'

def convert_airtable_to_json(airtable_api_key, aws_access_key_id, aws_secret_access_key):

headers = {'Authorization': f'Bearer {airtable_api_key}'}
response= requests.get(f'https://api.airtable.com/v0/{AIRTABLE_MODEL_HUB_BASE_ID}/{AIRTABLE_TABLE_ID}', headers=headers)

data=response.json()
records_models= [record['fields'] for record in data['records']]
models_json=json.dumps(records_models, indent=4)

#Load JSON in AWS S3 bucket
s3 = boto3.client('s3',aws_access_key_id=aws_access_key_id,aws_secret_access_key=aws_secret_access_key,region_name=AWS_ACCOUNT_REGION)
try:
s3.put_object(Body=models_json, Bucket=ERSILIA_MODEL_HUB_S3_BUCKET, Key='models.json', ACL='public-read')
print("file models.json uploaded")
except NoCredentialsError:
logging.error("Unable to upload tracking data to AWS: Credentials not found")
except ClientError as e:
logging.error(e)

if __name__ == "__main__":

print("Getting environmental variables")
airtable_api_key = os.environ.get('AIRTABLE_API_KEY')
aws_access_key_id = os.environ.get('AWS_ACCESS_KEY_ID')
aws_secret_access_key = os.environ.get('AWS_SECRET_ACCESS_KEY')

print("Converting AirTable base to JSON file")
convert_airtable_to_json(airtable_api_key, aws_access_key_id, aws_secret_access_key)
5 changes: 3 additions & 2 deletions .github/scripts/place_a_dockerfile_in_current_eos_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil

model_id = sys.argv[1]
build_version = sys.argv[2] if len(sys.argv) > 2 else "v2"

if os.path.exists("Dockerfile"):
shutil.move("Dockerfile", "Dockerfile_legacy")
Expand All @@ -14,7 +15,7 @@ def download_file(url, filename):
open(filename, "wb").write(r.content)


url = "https://raw.githubusercontent.com/ersilia-os/ersilia/master/dockerfiles/model-deploy/model/Dockerfile"
url = f"https://raw.githubusercontent.com/ersilia-os/ersilia/master/dockerfiles/model-deploy-{build_version}/model/Dockerfile"
filename = "Dockerfile"
download_file(url, filename)

Expand All @@ -24,4 +25,4 @@ def download_file(url, filename):
text = text.replace("eos_identifier", model_id)

with open("Dockerfile", "w") as f:
f.write(text)
f.write(text)
8 changes: 7 additions & 1 deletion .github/scripts/update_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ def populate_metadata(self):
if self.metadata["Title"] == "":
self.metadata["Title"] = self.json_input["model_name"]
if self.metadata["Description"] == "":
self.metadata["Description"] = self.json_input["model_description"]
# Check if model_description is a list
if isinstance(self.json_input["model_description"], list):
# Join the list elements into a single string separated by commas
self.metadata["Description"] = ", ".join(self.json_input["model_description"])
else:
# If it's already a string, just assign it directly
self.metadata["Description"] = self.json_input["model_description"]
if self.metadata["Publication"] == "":
self.metadata["Publication"] = self.json_input["publication"]
if self.metadata["Source Code"] == "":
Expand Down
8 changes: 4 additions & 4 deletions .github/scripts/update_model_workflows_from_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"git clone https://github.com/ersilia-os/{0}.git".format(model_repo), shell=True
).wait()

workflows_folder = os.path.join("{0}/.github/workflows".format(model_repo))
github_folder = os.path.join("{0}/.github/".format(model_repo))

if os.path.exists(workflows_folder):
shutil.rmtree(workflows_folder)
if os.path.exists(github_folder):
shutil.rmtree(github_folder)

shutil.copytree("eos-template/.github/workflows", workflows_folder)
shutil.copytree("eos-template/.github/", github_folder)

subprocess.Popen(
"cd {0};git add .; git commit -m 'updated workflow files'; git push; cd ..".format(
Expand Down
45 changes: 0 additions & 45 deletions .github/workflows/airtable_to_csv.yml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/airtable_to_json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Convert Back-end Airtable to JSON file

on:
workflow_dispatch:

schedule:
- cron: '0 2 * * *'

jobs:
convert-airtable-to-json:
runs-on: ubuntu-latest

steps:
- name: Checkout persist credentials
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # pin@v3.5.3
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

- name: Install dependencies
run:
pip install airtable-python-wrapper
pip install boto3

- name: Convert to backend of Airtable to JSON FILE
env:
AIRTABLE_API_KEY: ${{ secrets.AIRTABLE_API_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
python .github/scripts/convert_airtable_to_json.py $AIRTABLE_API_KEY $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY
14 changes: 7 additions & 7 deletions .github/workflows/approve-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin@v3.5.3
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # pin@v3.5.3

# construct the url to this workflow run
- name: workflow url
Expand All @@ -23,7 +23,7 @@ jobs:
# parse the issue body from free form text to a structured JSON object
- name: parse issue
uses: GrantBirki/issue-template-parser@v7.0.0
uses: GrantBirki/issue-template-parser@v7.0.2
id: issue-parser
with:
body: ${{ github.event.client_payload.github.payload.issue.body }}
Expand All @@ -36,7 +36,7 @@ jobs:

# setup python
- name: setup python
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # pin@v5.0.0
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # pin@v5.1.0
with:
python-version: "3.10"
# cache: 'pip' # caching pip dependencies
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
# upload git-lfs object
- name: checkout persist credentials
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin@v3.5.3
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # pin@v3.5.3
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
git lfs ls-files
- name: commit and push changes
uses: actions-js/push@156f2b10c3aa000c44dbe75ea7018f32ae999772 # pin@v1.4
uses: actions-js/push@5a7cbd780d82c0c937b5977586e641b2fd94acc5 # pin@v1.5
with:
author_name: "ersilia-bot"
author_email: "ersilia-bot@users.noreply.github.com"
Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
# comment on the issue comment with further instructions for the user
- name: comment
uses: GrantBirki/comment@7016e89e8f225b0f18f1fbb7fd10263df2772a05 # pin@v2.0.8
uses: GrantBirki/comment@d5cdf0243751ca01060946b2cae3722e508b7b16 # pin@v2.0.9
with:
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
file: .github/templates/new-model.md
Expand All @@ -171,7 +171,7 @@ jobs:
# steps to run if the workflow fails for any reason
- name: comment on failure
if: failure()
uses: GrantBirki/comment@7016e89e8f225b0f18f1fbb7fd10263df2772a05 # pin@v2.0.8
uses: GrantBirki/comment@d5cdf0243751ca01060946b2cae3722e508b7b16 # pin@v2.0.9
with:
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
file: .github/templates/approve-workflow-failed.md
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/ersilia-base-image-to-dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@ on:
types:
- completed

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

inputs:
build_version:
description: 'Docker build version (v2 is default; v1 - single stage build and v2 - multi stage build)'
required: false
type: string
default: v2

env:
BUILD_VERSION: ${{ github.event.inputs.build_version }}

jobs:
upload_ersilia_base_to_dockerhub:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -41,15 +51,15 @@ jobs:
- name: Copy Dockerfile to base directory
run: |
cp dockerfiles/model-deploy/base/* .
cp dockerfiles/model-deploy-${{ env.BUILD_VERSION }}/base/* .
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ersiliaos/base
ersiliaos/base-${{ env.BUILD_VERSION }}
# Docker tags based on the following events/attributes
tags: |
type=raw,value=latest
Expand Down
Loading

0 comments on commit f548a27

Please sign in to comment.