Skip to content

Commit

Permalink
Merge pull request #64 from AlexVCaron/docs/prototyping
Browse files Browse the repository at this point in the history
Add documentation and devcontainer for pipeline prototyping
  • Loading branch information
arnaudbore authored Dec 12, 2024
2 parents 83edced + 32b4f7f commit 318a2fe
Show file tree
Hide file tree
Showing 22 changed files with 773 additions and 211 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "NF-NEURO development container",
"name": "devops",
"build": {
"dockerfile": "Dockerfile",
"args": {
Expand All @@ -8,8 +8,8 @@
}
},
"forwardPorts": [3000],
"onCreateCommand": "bash .devcontainer/onCreateCommand.sh",
"updateContentCommand": "bash .devcontainer/updateContentCommand.sh",
"onCreateCommand": "bash .devcontainer/devops/onCreateCommand.sh",
"updateContentCommand": "bash .devcontainer/devops/updateContentCommand.sh",
"postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
"containerEnv": {
"WORKSPACE": "${containerWorkspaceFolder}"
Expand Down
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions .devcontainer/prototyping/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM scilus/scilus:2.0.2

ARG POETRY_VERSION

ENV POETRY_VERSION=${POETRY_VERSION:-1.8.*}

RUN apt update && apt install -y \
curl \
git \
openjdk-17-jre \
python3-venv \
wget \
&& rm -rf /var/lib/apt/lists/*

RUN python3 -m pip install pipx && \
python3 -m pipx ensurepath && \
pipx install poetry==${POETRY_VERSION}
77 changes: 77 additions & 0 deletions .devcontainer/prototyping/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"name": "prototyping",
"build": {
"dockerfile": "Dockerfile",
"args": {
"POETRY_VERSION": "1.8.*"
}
},
"forwardPorts": [3000],
"initializeCommand": "bash .devcontainer/prototyping/initializeCommand.sh",
"onCreateCommand": "bash .devcontainer/prototyping/onCreateCommand.sh",
"updateContentCommand": "bash .devcontainer/prototyping/updateContentCommand.sh",
"postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
"containerEnv": {
"WORKSPACE": "${containerWorkspaceFolder}"
},
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers-contrib/features/apt-get-packages:1": {},
"ghcr.io/robsyme/features/nextflow:1": {},
"ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {},
"ghcr.io/devcontainers-contrib/features/tmux-apt-get:1": {},
"ghcr.io/devcontainers-contrib/features/wget-apt-get:1": {}
},
"mounts": [
{
"source": "nf-proto-${devcontainerId}-venv",
"target": "${containerWorkspaceFolder}/.venv",
"type": "volume"
},
{
"target": "/tmp",
"type": "volume"
},
{
"source": "nf-proto-${devcontainerId}-profile",
"target": "/root",
"type": "volume"
},
{
"target": "/root/.vscode-server",
"type": "volume"
}
],
"customizations": {
"vscode": {
"settings": {
"python": {
"analysis.exclude": [
"${containerWorkspaceFolder}/.vscode",
"${containerWorkspaceFolder}/.venv",
"**/__pycache__",
"${containerWorkspaceFolder}/.git"
],
"analysis.ignore": [
"${containerWorkspaceFolder}/.vscode",
"${containerWorkspaceFolder}/.venv",
"**/__pycache__",
"${containerWorkspaceFolder}/.git"
],
"createEnvironment.trigger": "off",
"interpreter.infoVisibility": "always",
"poetryPath": "/root/.local/bin/poetry",
"defaultInterpreterPath": "${containerWorkspaceFolder}/.venv",
"terminal.activateEnvironment": true,
"terminal.activateEnvInCurrentTerminal": true,
"terminal.focusAfterLaunch": true
}
},
"extensions": ["nf-neuro.nf-neuro-extensionpack"]
}
},
"init": true,
"privileged": true
}
13 changes: 13 additions & 0 deletions .devcontainer/prototyping/initializeCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

# The prototyping environment must not be started in the nf-neuro repository.

if [[ $PWD =~ .*/nf-neuro$ ]]
then

echo "You cannot open a prototyping environment in the nf-neuro repository."
echo "Please, locate yourself elsewhere, outside the nf-neuro tree if possible."

exit 1

fi
32 changes: 32 additions & 0 deletions .devcontainer/prototyping/onCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

# Setup for NF-CORE

mkdir -p $XDG_CONFIG_HOME/nf-neuro
touch $XDG_CONFIG_HOME/nf-neuro/.env
echo "source $XDG_CONFIG_HOME/nf-neuro/.env" >> ~/.bashrc

# Try to download nf-neuro setup with poetry. If it fails, we defer to pip
{
NFNEURO_RAW_REPOSITORY=https://raw.githubusercontent.com/scilus/nf-neuro/main
NFCORE_VERSION=2.14.1
wget -N $NFNEURO_RAW_REPOSITORY/pyproject.toml \
$NFNEURO_RAW_REPOSITORY/poetry.toml \
$NFNEURO_RAW_REPOSITORY/poetry.lock
} || {
echo "Failed to download nf-neuro base project configuration. Creating requirements.txt for pip"
echo "nf-core==$NFCORE_VERSION" > requirements.txt
}

# Try to download VSCode settings from nf-neuro
{
NFNEURO_RAW_REPOSITORY=https://raw.githubusercontent.com/scilus/nf-neuro/main
mkdir -p .vscode
wget -N -P .vscode $NFNEURO_RAW_REPOSITORY/.vscode/settings.json
} || {
echo "Could not fetch default extension settings from nf-neuro"
}

# Initial setup for a pipeline prototyping environment
# - nf-core requires a .nf-core.yml file present, else it bugs out (issue nfcore/tools#3340)
touch .nf-core.yml
33 changes: 33 additions & 0 deletions .devcontainer/prototyping/updateContentCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash


maxmem=$(grep MemTotal /proc/meminfo | awk '{print $2}')

cat <<EOF > $XDG_CONFIG_HOME/nf-neuro/.env
# This file is used to store environment variables for the project.
# It is sourced by the shell on startup of every terminals.
export PROFILE=docker
export NFCORE_MODULES_GIT_REMOTE=https://github.com/scilus/nf-neuro.git
export NFCORE_MODULES_BRANCH=main
export NFCORE_SUBWORKFLOWS_GIT_REMOTE=https://github.com/scilus/nf-neuro.git
export NFCORE_SUBWORKFLOWS_BRANCH=main
export DEVCONTAINER_RAM_LIMIT_GB=$((maxmem / 1024 / 1024))
export DEVCONTAINER_CPU_LIMIT=$(grep -c ^processor /proc/cpuinfo)
EOF

unset maxmem
NFCORE_VERSION=2.14.1

if [ -f poetry.lock ] && [ -f pyproject.toml ]
then
poetry install --no-root
elif [ -f requirements.txt ]
then
python3 -m pip install -r requirements.txt
else
echo "No requirements file found, installing nf-core to version $NFCORE_VERSION using pip"
python3 -m pip install nf-core==$NFCORE_VERSION
fi
4 changes: 4 additions & 0 deletions .vscode/extension-package/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [1.0.2] - 2024-12-10

- Add `errorlens` to packages

## [1.0.1] - 2024-09-16

- Upgrade extension list
Expand Down
6 changes: 3 additions & 3 deletions .vscode/extension-package/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions .vscode/extension-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"url": "https://github.com/scilus/nf-neuro.git"
},
"icon": "icon.avif",
"version": "1.0.1",
"version": "1.0.2",
"publisher": "nf-neuro",
"engines": {
"vscode": "^1.84.0"
"vscode": "^1.95.0"
},
"categories": [
"Extension Packs"
Expand Down Expand Up @@ -50,6 +50,7 @@
"ryu1kn.annotator",
"trond-snekvik.simple-rst",
"twxs.cmake",
"usernamehw.errorlens",
"yahyabatulu.vscode-markdown-alert",
"yzhang.markdown-all-in-one"
]
Expand Down
Loading

0 comments on commit 318a2fe

Please sign in to comment.