Skip to content

Commit

Permalink
update to viash 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Jul 2, 2024
1 parent 646a7e5 commit bdfdd87
Show file tree
Hide file tree
Showing 38 changed files with 1,304 additions and 1,407 deletions.
119 changes: 10 additions & 109 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,120 +1,21 @@
name: build
name: Build

on:
push:
branches: [ 'main' ]
workflow_dispatch:
inputs:
target_branch:
description: 'Branch to deploy to. If not specified, `build-${BRANCH_NAME}` will be used.'
required: false
version:
description: 'Version name to use for the build. If not specified, `build-${BRANCH_NAME}` will be used.'
description: |
The version of the project to build. Example: `1.0.3`.
If not provided, a development build with a version name
based on the branch name will be built. Otherwise, a release
build with the provided version will be built.
required: false

jobs:
# phase 1
list:
runs-on: ubuntu-latest

outputs:
target_branch: ${{ steps.defaults.outputs.target_branch }}
version: ${{ steps.defaults.outputs.version }}
component_matrix: ${{ steps.set_matrix.outputs.matrix }}

steps:
- uses: actions/checkout@v4

- uses: viash-io/viash-actions/setup@v5

- name: Determine version tag from branch name
id: defaults
run: |
BRANCH_NAME=$(echo $GITHUB_REF | sed 's/refs\/heads\///')
VERSION=${{ github.event.inputs.version }}
if [ -z "$VERSION" ]; then
VERSION="build-$BRANCH_NAME"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
TARGET_BRANCH=${{ github.event.inputs.target_branch }}
if [ -z "$TARGET_BRANCH" ]; then
TARGET_BRANCH="build-$BRANCH_NAME"
fi
echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT
- name: Remove target folder from .gitignore
run: |
# allow publishing the target folder
sed -i '/^target.*/d' .gitignore
- uses: viash-io/viash-actions/ns-build@v5
with:
config_mod: .functionality.version := '${{ steps.defaults.outputs.version }}'
parallel: true

- name: Deploy to target branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .
publish_branch: ${{ steps.defaults.outputs.target_branch }}

- id: ns_list
uses: viash-io/viash-actions/ns-list@v5
with:
platform: docker
src: src
format: json

- id: set_matrix
run: |
echo "matrix=$(jq -c '[ .[] |
{
"name": (.functionality.namespace + "/" + .functionality.name),
"dir": .info.config | capture("^(?<dir>.*\/)").dir
}
]' ${{ steps.ns_list.outputs.output_file }} )" >> $GITHUB_OUTPUT
# phase 2
build:
needs: list

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
component: ${{ fromJson(needs.list.outputs.component_matrix) }}

steps:
# Remove unnecessary files to free up space. Otherwise, we get 'no space left on device.'
- uses: data-intuitive/reclaim-the-bytes@v2

- uses: actions/checkout@v4

- uses: viash-io/viash-actions/setup@v5

- name: Build container
uses: viash-io/viash-actions/ns-build@v5
with:
config_mod: .functionality.version := '${{ needs.list.outputs.version }}'
platform: docker
src: ${{ matrix.component.dir }}
setup: build

- name: Login to container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GTHB_USER }}
password: ${{ secrets.GTHB_PAT }}

- name: Push container
uses: viash-io/viash-actions/ns-build@v5
with:
config_mod: .functionality.version := '${{ needs.list.outputs.version }}'
platform: docker
src: ${{ matrix.component.dir }}
setup: push
uses: openproblems-bio/actions/.github/workflows/build.yml@main
with:
version: ${{ github.event.inputs.version }}
106 changes: 4 additions & 102 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,107 +1,9 @@
name: test
name: Test

on:
pull_request:
push:
branches: [ '**' ]
pull_request:

jobs:
run_ci_check_job:
runs-on: ubuntu-latest
outputs:
run_ci: ${{ steps.github_cli.outputs.check }}
steps:
- name: 'Check if branch has an existing pull request and the trigger was a push'
id: github_cli
run: |
pull_request=$(gh pr list -R ${{ github.repository }} -H ${{ github.ref_name }} --json url --state open --limit 1 | jq '.[0].url')
# If the branch has a PR and this run was triggered by a push event, do not run
if [[ "$pull_request" != "null" && "$GITHUB_REF_NAME" != "main" && "${{ github.event_name == 'push' }}" == "true" && "${{ !contains(github.event.head_commit.message, 'ci force') }}" == "true" ]]; then
echo "check=false" >> $GITHUB_OUTPUT
else
echo "check=true" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.GTHB_PAT }}

# phase 1
list:
needs: run_ci_check_job
env:
s3_bucket: s3://openproblems-bio/public/neurips-2023-competition/workflow-resources/
runs-on: ubuntu-latest
if: ${{ needs.run_ci_check_job.outputs.run_ci == 'true' }}

outputs:
matrix: ${{ steps.set_matrix.outputs.matrix }}
cache_key: ${{ steps.cache.outputs.cache_key }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: viash-io/viash-actions/setup@v5

- uses: viash-io/viash-actions/project/sync-and-cache-s3@v5
id: cache
with:
s3_bucket: $s3_bucket
dest_path: resources
cache_key_prefix: resources__

- id: ns_list
uses: viash-io/viash-actions/ns-list@v5
with:
platform: docker
format: json

- id: ns_list_filtered
uses: viash-io/viash-actions/project/detect-changed-components@v5
with:
input_file: "${{ steps.ns_list.outputs.output_file }}"

- id: set_matrix
run: |
echo "matrix=$(jq -c '[ .[] |
{
"name": (.functionality.namespace + "/" + .functionality.name),
"config": .info.config
}
]' ${{ steps.ns_list_filtered.outputs.output_file }} )" >> $GITHUB_OUTPUT
# phase 2
viash_test:
needs: list
if: ${{ needs.list.outputs.matrix != '[]' && needs.list.outputs.matrix != '' }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
component: ${{ fromJson(needs.list.outputs.matrix) }}

steps:
# Remove unnecessary files to free up space. Otherwise, we get 'no space left on device.'
- uses: data-intuitive/reclaim-the-bytes@v2

- uses: actions/checkout@v4

- uses: viash-io/viash-actions/setup@v5

# use cache
- name: Cache resources data
uses: actions/cache@v4
timeout-minutes: 10
with:
path: resources
key: ${{ needs.list.outputs.cache_key }}

- name: Run test
timeout-minutes: 30
run: |
VIASH_TEMP=$RUNNER_TEMP/viash viash test \
"${{ matrix.component.config }}" \
--cpus 2 \
--memory "5gb"
build:
uses: openproblems-bio/actions/.github/workflows/test.yml@main
34 changes: 22 additions & 12 deletions _viash.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
viash_version: 0.8.6
name: task_perturbation_prediction
version: 1.1.0

source: src
target: target
# package metadata
description: |
Predicting how small molecules change gene expression in different cell types.
license: MIT
keywords: [single-cell, perturbation prediction, perturbation, openproblems, benchmark]
links:
issue_tracker: https://github.com/openproblems-bio/task_perturbation_prediction/issues
repository: https://github.com/openproblems-bio/task_perturbation_prediction
docker_registry: ghcr.io

# technical settings
organization: openproblems-bio
viash_version: 0.9.0-RC6
info:
test_resources:
- type: s3
path: s3://openproblems-data/resources/perturbation_prediction
dest: resources

# set default labels
config_mods: |
.functionality.version := 'dev'
.functionality.arguments[.multiple == true].multiple_sep := ';'
.platforms[.type == 'docker'].target_registry := 'ghcr.io'
.platforms[.type == 'docker'].target_organization := 'openproblems-bio/task_perturbation_prediction'
.platforms[.type == 'docker'].target_image_source := 'https://github.com/openproblems-bio/task_perturbation_prediction'
.platforms[.type == "nextflow"].directives.tag := "$id"
.platforms[.type == "nextflow"].auto.simplifyOutput := false
.platforms[.type == "nextflow"].config.labels := { lowmem : "memory = 20.Gb", midmem : "memory = 50.Gb", highmem : "memory = 100.Gb", lowcpu : "cpus = 5", midcpu : "cpus = 15", highcpu : "cpus = 30", lowtime : "time = 1.h", midtime : "time = 4.h", hightime : "time = 8.h", veryhightime : "time = 24.h" }
.platforms[.type == "nextflow"].config.script := "process.errorStrategy = 'ignore'"
.runners[.type == "nextflow"].config.labels := { lowmem : "memory = 20.Gb", midmem : "memory = 50.Gb", highmem : "memory = 100.Gb", lowcpu : "cpus = 5", midcpu : "cpus = 15", highcpu : "cpus = 30", lowtime : "time = 1.h", midtime : "time = 4.h", hightime : "time = 8.h", veryhightime : "time = 24.h" }
2 changes: 2 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
process.container = 'nextflow/bash:latest'

process.errorStrategy = "ignore"
48 changes: 48 additions & 0 deletions scripts/script.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
library(tidyverse)

# aws s3 sync s3://openproblems-data/resources/perturbation_prediction/results output/benchmark_results

df <- yaml::read_yaml("output/benchmark_results/kaggle_2024-06-02_22-27-09/score_uns.yaml") %>%
map_dfr(as.data.frame) %>%
as_tibble

df %>% filter(metric_ids == "mean_rowwise_rmse") %>% arrange(metric_values) %>% select(method_id, metric_values)

# method_id metric_values
# <chr> <dbl>
# 1 ground_truth 0
# 2 nn_retraining_with_pseudolabels 1.29
# 3 scape 1.31
# 4 pyboost 1.32
# 5 jn_ap_op2 1.34
# 6 lgc_ensemble 1.41
# 7 mean_across_compounds 1.47
# 8 transformer_ensemble 1.55
# 9 zeros 1.57
# 10 mean_outcome 1.57
# 11 mean_across_celltypes 2.50
# 12 sample 3.02

#######

df <- yaml::read_yaml("output/benchmark_results/run_2024-06-02_22-27-09/score_uns.yaml") %>%
map_dfr(as.data.frame) %>%
as_tibble

df %>% filter(metric_ids == "mean_rowwise_rmse") %>% arrange(metric_values) %>% select(method_id, metric_values)

# # A tibble: 12 × 2
# method_id metric_values
# <chr> <dbl>
# 1 ground_truth 0
# 2 nn_retraining_with_pseudolabels 0.757
# 3 scape 0.775
# 4 pyboost 0.795
# 5 lgc_ensemble 0.802
# 6 mean_across_celltypes 0.892
# 7 jn_ap_op2 0.894
# 8 transformer_ensemble 0.897
# 9 mean_outcome 0.899
# 10 zeros 0.918
# 11 mean_across_compounds 0.943
# 12 sample 1.36
4 changes: 3 additions & 1 deletion src/common/create_component/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ functionality:
- type: python_script
path: script.py
- path: read_and_merge_yaml.py
platforms:
engines:
- type: docker
image: python:3.10-slim
setup:
- type: python
pypi: ruamel.yaml
- type: native
runners:
- type: executable
- type: nextflow


4 changes: 3 additions & 1 deletion src/common/create_component/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def create_config(par, component_type, pretty_name, script_path) -> str:
| # This platform allows running the component natively
| - type: native
| # Allows turning the component into a Nextflow module / pipeline.
| - type: nextflow
|runners:
- type: executable
- type: nextflow
| directives:
| label: [midtime,midmem,midcpu]
|'''
Expand Down
4 changes: 3 additions & 1 deletion src/common/sync_test_resources/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ functionality:
resources:
- type: bash_script
path: script.sh
platforms:
engines:
- type: docker
image: "amazon/aws-cli:2.7.12"
- type: native
runners:
- type: executable
- type: nextflow
Loading

0 comments on commit bdfdd87

Please sign in to comment.