Skip to content

Commit

Permalink
Merge pull request #11 from esl-epfl/pr-yaml
Browse files Browse the repository at this point in the history
Add schema definition
  • Loading branch information
cmdoret authored Oct 24, 2024
2 parents ca64df5 + aedd2f4 commit 409caf1
Show file tree
Hide file tree
Showing 5 changed files with 979 additions and 17 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/docker-publish-algo-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Publish algorithm checker container

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
branches: [ "main" ]
paths: "config/algo-checks.Dockerfile"
pull_request:
branches: [ "main" ]
paths: "config/algo-checks.Dockerfile"

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}-algo-checks

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
with:
cosign-release: 'v2.2.4'

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: ./evaluation
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: config/algo-checks.Dockerfile

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

46 changes: 35 additions & 11 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,55 @@
name: PR checks for algorithm submission
name: PR checks fon algorithm submission

on:
pull_request:
paths:
- 'algorithms/*.yaml'

env:
IMAGE_NAME: ${{ github.repository }}-evaluator
push:
paths:
- 'algorithms/*.yaml'

jobs:

check_yaml:
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ env.IMAGE_NAME }}
image: ghcr.io/${{ github.repository }}-algo-checks:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
steps:

- name: Convert yaml
run: yq -o json FILE.yaml > FILE.json

- name: Validate jsonschema
run: jsonschema-cli -i FILE.json SCHEMA.json
- name: find algorithm files
run: |
{
echo 'FILELIST<<EOF'
find ./algorithms -name '*.yaml' -print
echo EOF
} >> "$GITHUB_ENV"
- name: Convert and validate using jsonschema
run: |
for algo in ${FILELIST}; do
yq -o json $algo > algo.json \
&& jsonschema-cli -i algo.json "config/schema.json"
done
rm algo.json
check_image:
runs-on: ubuntu-latest
steps:

- name: find algorithm files
run: |
{
echo 'FILELIST<<EOF'
find ./algorithms -name '*.yaml' -print
echo EOF
} >> "$GITHUB_ENV"
- name: Pull image
run: docker pull $(sed 's/^image: \(.*\)$' FILE.yaml)
run: |
for algo in ${FILELIST}; do
docker pull $(sed 's/^image: \+\(.*\)$/\1/' $algo)
done
13 changes: 7 additions & 6 deletions algorithms/algorithm.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
---
# Description of a seizure detection algorithm
title: My Research Software
repository-code: "https://github.com/citation-file-format/my-research-software"
image: "ghcr.io/username/image-name:tag"
authors:
- family-names: Druskat
given-names: Stephan
orcid: "https://orcid.org/1234-5678-9101-1121"
- name: "The Research Software project"
version: 0.11.2
date-released: "2024-10-24"
description: This algorithm performs random detection of epileptic seizures. On each epoch of 1 second it assigns a 30% probability of being a seizure.
abstract: This algorithm performs random detection of epileptic seizures. On each epoch of 1 second it assigns a 30% probability of being a seizure.
license: Apache-2.0
repository: https://github.com/
message: If you use this software, please cite it using these metadata.

# List all datasets that were used to train this algorithm
Dataset:
- title: Physionet CHB-MIT Scalp EEG Database
license: ODC-By v1.0
license: CC-BY-1.0
identifiers:
- description: Zenodo BIDS standardized version of CHB-MIT Scalp EEG database
type: doi
value: "10.5281/zenodo.123456"
- title: TUH EEG Seizure Corpus
license: Private
license: https://isip.piconepress.com/projects/nedc/forms/tuh_eeg.pdf
identifiers:
- description: Temple University Seizure Corpus
type: url
value: "https://isip.piconepress.com/projects/nedc/html/tuh_eeg/#c_tusz"
- title: Siena Scalp EEG
license: ODC-By v1.0
license: CC-BY-1.0
identifiers:
- description: Zenodo BIDS standardized version of Siena Scalp EEG database
type: doi
value: "10.5281/zenodo.10640762"
- title: SeizeIT1
license: Custom KU Leuven
license: https://www.kuleuven.be/rdm/en/rdr/custom-kuleuven
identifiers:
- description: KU Lueven SeizeIT1 dataset
type: doi
Expand Down
1 change: 1 addition & 0 deletions config/algo-checks.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Dockerfile
# Provides dependencies to verify algorithm definition files
# and validate them against schema

Expand Down
Loading

0 comments on commit 409caf1

Please sign in to comment.