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

Sleepers version 2.2.0 #155

Merged
Merged
Show file tree
Hide file tree
Changes from 20 commits
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: 10 additions & 13 deletions .github/workflows/sleeper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,22 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python: [3.8]
python: [3.11]
os: [ubuntu-22.04]
node: [10]
node: [16]
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: setup python environment
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: "pip"
cache-dependency-path: "**/requirements.txt"
- name: install uv
uses: yezz123/setup-uv@v1
- name: show versions
run: ./ci/helpers/show_system_versions.bash
- uses: actions/cache@v2
name: getting cached data
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: set owner variable
run: echo "OWNER=${GITHUB_REPOSITORY%/*}" >> $GITHUB_ENV
- name: set docker image tag
Expand Down Expand Up @@ -74,13 +71,13 @@ jobs:
make push-version
- name: set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: setup docker buildx
id: buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3
with:
version: ${{ matrix.docker_buildx }}
driver: docker-container # a must for multi-arch buildsplatform
Expand Down
2 changes: 1 addition & 1 deletion services/sleeper/.cookiecutterrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ default_context:
project_slug: "sleeper"
project_type: "computational"
release_date: "2020"
version: "2.1.6"
version: "2.2.0"
12 changes: 5 additions & 7 deletions services/sleeper/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,22 @@ LOCAL_REGISTRY = ${LOCAL_REGISTRY_HOST}/${COMP_ITIS_PATH}
# ENVIRON ----------------------------------
.PHONY: devenv
.venv:
python3 -m venv $@
uv venv $@
# upgrading package managers
$@/bin/pip3 install --upgrade \
uv pip install --upgrade \
pip \
wheel \
setuptools
# tooling
$@/bin/pip3 install pip-tools

requirements.txt: .venv requirements.in
# freezes requirements
$</bin/pip-compile --upgrade --build-isolation --output-file $@ $(word2, $^)
uv pip compile --upgrade --build-isolation $(word 2, $^) --output-file $@

devenv: .venv requirements.txt ## create a python virtual environment with tools to dev, run and tests cookie-cutter
# installing extra tools
@$</bin/pip3 install -r $(word 2,$^)
uv pip install -r $(word 2,$^)
# your dev environment contains
@$</bin/pip3 list
@$</bin/pip list
@echo "To activate the virtual environment, run 'source $</bin/activate'"


Expand Down
2 changes: 1 addition & 1 deletion services/sleeper/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.6
2.2.0
8 changes: 5 additions & 3 deletions services/sleeper/docker-compose-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
dockerfile: docker/custom/Dockerfile
target: production
args:
BASE_IMAGE: python:3.9-slim-buster
BASE_IMAGE: python:3.11-slim

sleeper-gpu:
image: local/${DOCKER_IMAGE_NAME}-gpu:${DOCKER_BUILD_TARGET}
Expand All @@ -16,12 +16,14 @@ services:
dockerfile: docker/custom/Dockerfile
target: production
args:
BASE_IMAGE: nvidia/cuda:10.0-base-ubuntu18.04
INSTALL_EXTRAS: true
BASE_IMAGE: nvidia/cuda:12.3.1-base-ubuntu22.04
sleeper-mpi:
image: local/${DOCKER_IMAGE_NAME}-mpi:${DOCKER_BUILD_TARGET}
build:
context: ./
dockerfile: docker/custom/Dockerfile
target: production
args:
BASE_IMAGE: nvidia/cuda:10.0-base-ubuntu18.04
INSTALL_EXTRAS: true
BASE_IMAGE: nvidia/cuda:12.3.1-base-ubuntu22.04
86 changes: 56 additions & 30 deletions services/sleeper/docker-compose-meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,27 @@ services:
io.simcore.authors: '{"authors": [{"name": "Manuel Guidon", "email": "[email protected]",
"affiliation": "IT''IS Foundation"}, {"name": "Odei Maiz", "email": "[email protected]",
"affiliation": "IT''IS Foundation"}, {"name": "Andrei Neagu", "email": "[email protected]",
"affiliation": "IT''IS Foundation"}]}'
"affiliation": "IT''IS Foundation"}, {"name": "Sylvain Anderegg", "email":
"[email protected]", "affiliation": "IT''IS Foundation"}]}'
io.simcore.contact: '{"contact": "[email protected]"}'
io.simcore.description: '{"description": "A service which awaits for time
to pass, two times."}'
io.simcore.inputs: '{"inputs": {"input_1": {"displayOrder": 1, "label": "File
with int number", "description": "Pick a file containing only one integer",
"type": "data:text/plain", "fileToKeyMap": {"single_number.txt": "input_1"}},
"input_2": {"displayOrder": 2, "label": "Sleep interval", "description":
"Choose an amount of time to sleep in range [0-65]", "defaultValue": 2,
"Choose an amount of time to sleep in range [0-900]", "defaultValue": 2,
sanderegg marked this conversation as resolved.
Show resolved Hide resolved
"type": "ref_contentSchema", "contentSchema": {"title": "Sleep interval",
"type": "integer", "x_unit": "second", "minimum": 0, "maximum": 65}}, "input_3":
"type": "integer", "x_unit": "second", "minimum": 0, "maximum": 900}}, "input_3":
{"displayOrder": 3, "label": "Fail after sleep", "description": "If set
to true will cause service to fail after it sleeps", "type": "boolean",
"defaultValue": false}, "input_4": {"displayOrder": 4, "label": "Distance
to bed", "description": "It will first walk the distance to bed", "defaultValue":
0, "type": "ref_contentSchema", "contentSchema": {"title": "Distance to
bed", "type": "integer", "x_unit": "meter"}}}}'
bed", "type": "integer", "x_unit": "meter"}}, "input_5": {"displayOrder":
5, "label": "Dream of the night", "description": "It will dream a big dream",
"defaultValue": 0, "type": "ref_contentSchema", "contentSchema": {"title":
"Dream of the night", "type": "integer", "x_unit": "bytes"}}}}'
io.simcore.integration-version: '{"integration-version": "1.0.0"}'
io.simcore.key: '{"key": "simcore/services/comp/itis/sleeper"}'
io.simcore.name: '{"name": "sleeper"}'
Expand All @@ -31,9 +35,11 @@ services:
"output_1"}}, "output_2": {"displayOrder": 2, "label": "Random sleep interval",
"description": "Interval is generated in range [1-9]", "type": "ref_contentSchema",
"contentSchema": {"title": "Random sleep interval", "type": "integer", "x_unit":
"second"}}}}'
"second"}}, "output_3": {"displayOrder": 3, "label": "Dream output", "description":
"Contains some random data representing a dream", "type": "data:text/plain",
"fileToKeyMap": {"dream.txt": "output_3"}}}}'
io.simcore.type: '{"type": "computational"}'
io.simcore.version: '{"version": "2.1.6"}'
io.simcore.version: '{"version": "2.2.0"}'
org.label-schema.build-date: ${BUILD_DATE}
org.label-schema.schema-version: '1.0'
org.label-schema.vcs-ref: ${VCS_REF}
Expand All @@ -47,31 +53,41 @@ services:
io.simcore.authors: '{"authors": [{"name": "Manuel Guidon", "email": "[email protected]",
"affiliation": "IT''IS Foundation"}, {"name": "Odei Maiz", "email": "[email protected]",
"affiliation": "IT''IS Foundation"}, {"name": "Andrei Neagu", "email": "[email protected]",
"affiliation": "IT''IS Foundation"}]}'
io.simcore.contact: '{"contact": "[email protected]"}'
"affiliation": "IT''IS Foundation"}, {"name": "Sylvain Anderegg", "email":
"[email protected]", "affiliation": "IT''IS Foundation"}]}'
io.simcore.contact: '{"contact": "[email protected]"}'
io.simcore.description: '{"description": "A service which awaits for time
to pass."}'
to pass, two times."}'
io.simcore.inputs: '{"inputs": {"input_1": {"displayOrder": 1, "label": "File
with int number", "description": "Pick a file containing only one integer",
"type": "data:text/plain", "fileToKeyMap": {"single_number.txt": "input_1"}},
"input_2": {"displayOrder": 2, "label": "Sleep interval", "description":
"Choose an amount of time to sleep", "type": "integer", "unit": "second",
"defaultValue": 2}, "input_3": {"displayOrder": 3, "label": "Fail after
sleep", "description": "If set to true will cause service to fail after
it sleeps", "type": "boolean", "defaultValue": false}, "input_4": {"displayOrder":
4, "label": "Distance to bed", "description": "It will first walk the distance
to bed", "type": "integer", "unit": "meter", "defaultValue": 0}}}'
"Choose an amount of time to sleep in range [0-900]", "defaultValue": 2,
"type": "ref_contentSchema", "contentSchema": {"title": "Sleep interval",
"type": "integer", "x_unit": "second", "minimum": 0, "maximum": 900}}, "input_3":
{"displayOrder": 3, "label": "Fail after sleep", "description": "If set
to true will cause service to fail after it sleeps", "type": "boolean",
"defaultValue": false}, "input_4": {"displayOrder": 4, "label": "Distance
to bed", "description": "It will first walk the distance to bed", "defaultValue":
0, "type": "ref_contentSchema", "contentSchema": {"title": "Distance to
bed", "type": "integer", "x_unit": "meter"}}, "input_5": {"displayOrder":
5, "label": "Dream of the night", "description": "It will dream a big dream",
"defaultValue": 0, "type": "ref_contentSchema", "contentSchema": {"title":
"Dream of the night", "type": "integer", "x_unit": "bytes"}}}}'
io.simcore.integration-version: '{"integration-version": "1.0.0"}'
io.simcore.key: '{"key": "simcore/services/comp/itis/sleeper-gpu"}'
io.simcore.name: '{"name": "sleeper-gpu"}'
io.simcore.outputs: '{"outputs": {"output_1": {"displayOrder": 1, "label":
"File containing one random integer", "description": "Integer is generated
in range [1-9]", "type": "data:text/plain", "fileToKeyMap": {"single_number.txt":
"output_1"}}, "output_2": {"displayOrder": 2, "label": "Random sleep interval",
"description": "Interval is generated in range [1-9]", "type": "integer",
"unit": "second"}}}'
"description": "Interval is generated in range [1-9]", "type": "ref_contentSchema",
"contentSchema": {"title": "Random sleep interval", "type": "integer", "x_unit":
"second"}}, "output_3": {"displayOrder": 3, "label": "Dream output", "description":
"Contains some random data representing a dream", "type": "data:text/plain",
"fileToKeyMap": {"dream.txt": "output_3"}}}}'
io.simcore.type: '{"type": "computational"}'
io.simcore.version: '{"version": "2.1.4"}'
io.simcore.version: '{"version": "2.2.0"}'
org.label-schema.build-date: ${BUILD_DATE}
org.label-schema.schema-version: '1.0'
org.label-schema.vcs-ref: ${VCS_REF}
Expand All @@ -87,31 +103,41 @@ services:
io.simcore.authors: '{"authors": [{"name": "Manuel Guidon", "email": "[email protected]",
"affiliation": "IT''IS Foundation"}, {"name": "Odei Maiz", "email": "[email protected]",
"affiliation": "IT''IS Foundation"}, {"name": "Andrei Neagu", "email": "[email protected]",
"affiliation": "IT''IS Foundation"}]}'
io.simcore.contact: '{"contact": "[email protected]"}'
"affiliation": "IT''IS Foundation"}, {"name": "Sylvain Anderegg", "email":
"[email protected]", "affiliation": "IT''IS Foundation"}]}'
io.simcore.contact: '{"contact": "[email protected]"}'
io.simcore.description: '{"description": "A service which awaits for time
to pass."}'
to pass, two times."}'
io.simcore.inputs: '{"inputs": {"input_1": {"displayOrder": 1, "label": "File
with int number", "description": "Pick a file containing only one integer",
"type": "data:text/plain", "fileToKeyMap": {"single_number.txt": "input_1"}},
"input_2": {"displayOrder": 2, "label": "Sleep interval", "description":
"Choose an amount of time to sleep", "type": "integer", "unit": "second",
"defaultValue": 2}, "input_3": {"displayOrder": 3, "label": "Fail after
sleep", "description": "If set to true will cause service to fail after
it sleeps", "type": "boolean", "defaultValue": false}, "input_4": {"displayOrder":
4, "label": "Distance to bed", "description": "It will first walk the distance
to bed", "type": "integer", "unit": "meter", "defaultValue": 0}}}'
"Choose an amount of time to sleep in range [0-900]", "defaultValue": 2,
"type": "ref_contentSchema", "contentSchema": {"title": "Sleep interval",
"type": "integer", "x_unit": "second", "minimum": 0, "maximum": 900}}, "input_3":
{"displayOrder": 3, "label": "Fail after sleep", "description": "If set
to true will cause service to fail after it sleeps", "type": "boolean",
"defaultValue": false}, "input_4": {"displayOrder": 4, "label": "Distance
to bed", "description": "It will first walk the distance to bed", "defaultValue":
0, "type": "ref_contentSchema", "contentSchema": {"title": "Distance to
bed", "type": "integer", "x_unit": "meter"}}, "input_5": {"displayOrder":
5, "label": "Dream of the night", "description": "It will dream a big dream",
"defaultValue": 0, "type": "ref_contentSchema", "contentSchema": {"title":
"Dream of the night", "type": "integer", "x_unit": "bytes"}}}}'
io.simcore.integration-version: '{"integration-version": "1.0.0"}'
io.simcore.key: '{"key": "simcore/services/comp/itis/sleeper-mpi"}'
io.simcore.name: '{"name": "sleeper-mpi"}'
io.simcore.outputs: '{"outputs": {"output_1": {"displayOrder": 1, "label":
"File containing one random integer", "description": "Integer is generated
in range [1-9]", "type": "data:text/plain", "fileToKeyMap": {"single_number.txt":
"output_1"}}, "output_2": {"displayOrder": 2, "label": "Random sleep interval",
"description": "Interval is generated in range [1-9]", "type": "integer",
"unit": "second"}}}'
"description": "Interval is generated in range [1-9]", "type": "ref_contentSchema",
"contentSchema": {"title": "Random sleep interval", "type": "integer", "x_unit":
"second"}}, "output_3": {"displayOrder": 3, "label": "Dream output", "description":
"Contains some random data representing a dream", "type": "data:text/plain",
"fileToKeyMap": {"dream.txt": "output_3"}}}}'
io.simcore.type: '{"type": "computational"}'
io.simcore.version: '{"version": "2.1.4"}'
io.simcore.version: '{"version": "2.2.0"}'
org.label-schema.build-date: ${BUILD_DATE}
org.label-schema.schema-version: '1.0'
org.label-schema.vcs-ref: ${VCS_REF}
Expand Down
90 changes: 73 additions & 17 deletions services/sleeper/docker/custom/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,63 @@

ARG BASE_IMAGE="nvidia/cuda:10.0-base-ubuntu18.04"
# syntax=docker/dockerfile:1
ARG BASE_IMAGE="nvidia/cuda:12.0.0-base-ubuntu22.04"
FROM ${BASE_IMAGE} as base
#
# USAGE:
# cd services/sleeper
# docker build -f Dockerfile -t sleeper:prod --target production ../../
# docker run sleeper:prod
# docker run sleeper:prod
#

LABEL maintainer="Andrei Neagu <[email protected]>"
LABEL maintainer=sanderegg

# simcore-user uid=8004(${SC_USER_NAME}) gid=8004(${SC_USER_NAME}) groups=8004(${SC_USER_NAME})
ENV SC_USER_ID 8004
ENV SC_USER_NAME scu
RUN adduser --uid ${SC_USER_ID} --disabled-password --gecos "" --shell /bin/sh --home /home/${SC_USER_NAME} ${SC_USER_NAME}

RUN apt-get update --fix-missing && \
apt-get install -y wget bzip2 ca-certificates curl git python3 python3-pip jq && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV SC_USER_ID=8004 \
SC_USER_NAME=scu \
SC_BUILD_TARGET=base

RUN adduser \
--uid ${SC_USER_ID} \
--disabled-password \
--gecos "" \
--shell /bin/sh \
--home /home/${SC_USER_NAME} ${SC_USER_NAME}

# Sets utf-8 encoding for Python et al
ENV LANG=C.UTF-8

# Turns off writing .pyc files; superfluous on an ephemeral container.
ENV PYTHONDONTWRITEBYTECODE=1 \
VIRTUAL_ENV=/home/scu/.venv

# Ensures that the python and pip executables used in the image will be
# those from our virtualenv.
ENV PATH="${VIRTUAL_ENV}/bin:$PATH"

RUN --mount=type=cache,target=/var/cache/apt,mode=0755,sharing=private \
--mount=type=cache,target=/var/lib/apt,mode=0755,sharing=private \
set -eux \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
jq \
gosu \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
# verify that the binary works
&& gosu nobody true

# Define an argument that dictates whether to run the installation commands
ARG INSTALL_EXTRAS=false
RUN --mount=type=cache,target=/var/cache/apt,mode=0755,sharing=private \
--mount=type=cache,target=/var/lib/apt,mode=0755,sharing=private \
if [ "$INSTALL_EXTRAS" = "true" ]; then \
set -eux \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
python3 \
python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*; \
fi

# for ARM architecture this helps a lot VS building packages
ENV PIP_EXTRA_INDEX_URL=https://www.piwheels.org/simple
Expand All @@ -33,10 +72,21 @@ ENV PIP_EXTRA_INDEX_URL=https://www.piwheels.org/simple

FROM base as build

ENV SC_BUILD_TARGET build
ENV SC_BUILD_TARGET=build

# NOTE: install https://github.com/astral-sh/uv ultra-fast rust-based pip replacement
RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \
pip install uv~=0.1

# Instlling python
RUN pip3 install --upgrade pip wheel setuptools
# NOTE: python virtualenv is used here such that installed
# packages may be moved to production image easily by copying the venv
RUN uv venv "${VIRTUAL_ENV}"

RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \
uv pip install --upgrade \
sanderegg marked this conversation as resolved.
Show resolved Hide resolved
pip~=24.0 \
wheel \
setuptools

# ------------------------------------------------------------------------------------

Expand All @@ -61,14 +111,20 @@ RUN cp -R src/sleeper/* /build/bin
#
FROM base as production

ENV SC_BUILD_TARGET production
ENV SC_BOOT_MODE production
ENV SC_BUILD_TARGET=production \
SC_BOOT_MODE=production

ENV PYTHONOPTIMIZE=TRUE


ENV INPUT_FOLDER="/input" \
OUTPUT_FOLDER="/output"

WORKDIR /home/${SC_USER_NAME}
# ensure home folder is read/writable for user scu
RUN chown -R ${SC_USER_NAME} /home/${SC_USER_NAME}
# Starting from clean base image, copies pre-installed virtualenv from prod-only-deps
COPY --chown=${SC_USER_NAME}:${SC_USER_NAME} --from=build ${VIRTUAL_ENV} ${VIRTUAL_ENV}

# copy docker bootup scripts
COPY --chown=${SC_USER_NAME}:${SC_USER_NAME} docker/custom/*.sh docker/
Expand Down
Loading