Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine CWL and modular CWL into a single container image #251

Merged
merged 11 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .github/workflows/build_docker_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,3 @@ jobs:
push: true
tags: ${{ env.REGISTRY }}/${{ env.SPS_DOCKER_CWL }}:${{ env.TAG }}
labels: ${{ steps.metascheduler.outputs.labels }}
build-sps-docker-cwl-modular:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for SPS Docker CWL modular image
id: metascheduler
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.SPS_DOCKER_CWL_MODULAR }}
- name: Build and push SPS Docker CWL modular image
uses: docker/build-push-action@v5
with:
context: ./airflow/docker/cwl
file: airflow/docker/cwl/Dockerfile_modular
push: true
tags: ${{ env.REGISTRY }}/${{ env.SPS_DOCKER_CWL_MODULAR }}:${{ env.TAG }}
labels: ${{ steps.metascheduler.outputs.labels }}
7 changes: 4 additions & 3 deletions airflow/dags/cwl_dag_modular.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
from airflow import DAG

# Task constants
STAGE_IN_WORKFLOW = "https://raw.githubusercontent.com/unity-sds/unity-sps-workflows/refs/heads/220-stage-in-task/demos/cwl_dag_modular_stage_in.cwl"
STAGE_OUT_WORKFLOW = "https://raw.githubusercontent.com/unity-sds/unity-sps-workflows/refs/heads/220-stage-in-task/demos/cwl_dag_modular_stage_out.cwl"
STAGE_IN_WORKFLOW = "https://raw.githubusercontent.com/unity-sds/unity-sps-workflows/refs/heads/main/demos/cwl_dag_modular_stage_in.cwl"
STAGE_OUT_WORKFLOW = "https://raw.githubusercontent.com/unity-sds/unity-sps-workflows/refs/heads/main/demos/cwl_dag_modular_stage_out.cwl"
LOCAL_DIR = "/shared-task-data"

# The path of the working directory where the CWL workflow is executed
Expand Down Expand Up @@ -217,11 +217,12 @@ def setup(ti=None, **context):
task_id="cwl_task_processing",
namespace=unity_sps_utils.POD_NAMESPACE,
name="cwl-task-pod",
image=unity_sps_utils.SPS_DOCKER_CWL_IMAGE_MODULAR,
image=unity_sps_utils.SPS_DOCKER_CWL_IMAGE,
service_account_name="airflow-worker",
in_cluster=True,
get_logs=True,
startup_timeout_seconds=1800,
cmds=["/usr/share/cwl/docker_cwl_entrypoint_modular.sh"],
arguments=[
"-i",
STAGE_IN_WORKFLOW,
Expand Down
7 changes: 5 additions & 2 deletions airflow/docker/cwl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM docker:25.0.3-dind

# install Python
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN apk add gcc musl-dev linux-headers python3-dev
RUN apk add gcc musl-dev linux-headers python3-dev jq
RUN apk add --no-cache python3 py3-pip
RUN apk add vim

Expand All @@ -13,13 +13,16 @@ RUN mkdir /usr/share/cwl \
&& cd /usr/share/cwl \
&& python -m venv venv \
&& source venv/bin/activate \
&& pip install cwltool cwl-runner docker boto3 awscli
&& pip install cwltool cwl-runner docker boto3 awscli pyyaml

# install nodejs to parse Javascript in CWL files
RUN apk add --no-cache nodejs npm

# script to execute a generic CWL workflow with arguments
COPY docker_cwl_entrypoint.sh /usr/share/cwl/docker_cwl_entrypoint.sh

# script to execute a generic CWL workflow with stage in, process, and stage out tasks
COPY docker_cwl_entrypoint_modular.sh /usr/share/cwl/docker_cwl_entrypoint_modular.sh

WORKDIR /usr/share/cwl
ENTRYPOINT ["/usr/share/cwl/docker_cwl_entrypoint.sh"]
25 changes: 0 additions & 25 deletions airflow/docker/cwl/Dockerfile_modular

This file was deleted.

7 changes: 5 additions & 2 deletions airflow/plugins/unity_sps_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
Module containing common utilities for the Unity Science Processing System.
"""

from datetime import datetime

from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
from kubernetes.client import models as k8s

# Shared constants
POD_NAMESPACE = "sps" # The Kubernetes namespace within which the Pod is run (it must already exist)
POD_LABEL = "cwl_task"
POD_LABEL = "cwl_task" + datetime.now().strftime(
"%Y%m%d_%H%M%S_%f"
) # unique pod label to assure each job runs on its own pod
SPS_DOCKER_CWL_IMAGE = "ghcr.io/unity-sds/unity-sps/sps-docker-cwl:2.4.0"
SPS_DOCKER_CWL_IMAGE_MODULAR = "ghcr.io/unity-sds/unity-sps/sps-docker-cwl-mod:2.4.0"

NODE_POOL_DEFAULT = "airflow-kubernetes-pod-operator"
NODE_POOL_HIGH_WORKLOAD = "airflow-kubernetes-pod-operator-high-workload"
Expand Down
Loading