Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • rshimoura/ebrains-spack-builds
  • hl11/ebrains-spack-builds
  • woodman/ebrains-spack-builds
  • filippomarchetti/ebrains-spack-builds
  • ziaee/ebrains-spack-builds
  • jkaiser/ebrains-spack-builds
  • dsegebarth/ebrains-spack-builds
  • mloshakov/ebrains-spack-builds
  • kozlov/ebrains-spack-builds
  • dsegebarth/ebrains-spack-builds-na-3
  • ansimsek/ebrains-spack-builds
  • lupoc/ebrains-spack-builds
  • hartmut/ebrains-spack-builds
  • ri/tech-hub/platform/esd/ebrains-spack-builds
  • lcalori0/ebrains-spack-builds
  • deepu/ebrains-spack-builds
  • noelp/ebrains-spack-builds
17 results
Show changes
Commits on Source (1768)
Showing
with 1299 additions and 126 deletions
__pycache__
*.pyc
*.err
*.out
.spack-env/
spack.lock
stages:
- deploy
- build
- test
variables:
OPENSHIFT_SERVER: https://okd-dev.hbp.eu
BUILD_ENV: test-build
OP: update
#SPACK_ENV_TAR_FILE: ebrains-spack-builds${CI_PIPELINE_ID}.tar.gz
SPACK_ENV_TAR_FILE: ebrains-spack-builds.tar.gz
deploy-build-environment:
stage: deploy
BUILD_ENV_DOCKER_IMAGE: docker-registry.ebrains.eu/ebrains-spack-build-env/base:devel
RUN_ENV_DOCKER_IMAGE: docker-registry.ebrains.eu/clb-jupyter-image/ebrains:dev-a7ab31be
SPACK_PATH_GITLAB: /mnt/spack_v0.23.1
SYSTEMNAME: ebrainslab
GIT_SUBMODULE_STRATEGY: recursive
GIT_CLEAN_FLAGS: -ffdxq
RUNNER_AFTER_SCRIPT_TIMEOUT: 20
# ===================================================================
# LAB DEPLOYMENTS
# ===================================================================
# start a k8s Job that will build the Spack environment
.deploy-build-environment:
variables:
OCI_CACHE_PREFIX: ""
UPDATE_SPACK_OCI_CACHES: false
stage: build
tags:
- docker-runner
- read-only
image: alpine:3.21.0
before_script:
- oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_TOKEN"
- tar czf ${SPACK_ENV_TAR_FILE} packages/ repo.yaml spack.yaml
- mkdir copy_folder
- mv ${SPACK_ENV_TAR_FILE} copy_folder
- apk add kubectl
script:
# use the site-specific kubectl context
- kubectl config use-context $KUBE_CONTEXT
# create job description file
- chmod a+x create_job.sh
- ./create_job.sh $BUILD_ENV $OP $SPACK_ENV_TAR_FILE $CI_PIPELINE_ID
- sh create_job.sh $CI_PIPELINE_ID $BUILD_ENV_DOCKER_IMAGE $INSTALLATION_ROOT $SPACK_ENV $CI_COMMIT_SHA $RELEASE_NAME $LAB_KERNEL_ROOT $UPDATE_SPACK_OCI_CACHES $OCI_CACHE_PREFIX
- cat simplejob.yml
# select the project in openshift
- oc project jupyterhub-int
# start the deploy job
- oc create -f simplejob.yml
## wait for job to finish https://stackoverflow.com/questions/5073453wait-for-kubernetes-job-to-complete-on-either-failure-success-using-command-line
- oc get job/simplejob${CI_PIPELINE_ID} -o=jsonpath='{.status}' -w && oc get job/simplejob${CI_PIPELINE_ID} -o=jsonpath='{.status.conditions[*].type}' | grep -i -E 'failed|complete' || echo 'Failed'
# wait for job's pod to become available so as to copy from the gitlab runner to the OpenShift pod
# the necessary files that define the environment that spack needs to build
- while true; do x=$(oc get pods |grep simplejob${CI_PIPELINE_ID}|awk '{ print $3}');if [ $x == "Running" ]; then break; fi; sleep 1; done
- pod=$(oc get pods |grep simplejob${CI_PIPELINE_ID}|awk '{ print $1}')
- oc rsync copy_folder $pod:/opt/app-root/src
# when build job finishes get the logs
- while true; do sleep 10; x=$(oc get pods |grep $pod|awk '{ print $3}');if [ $x != "Running" ]; then break; fi; done
- oc logs jobs/simplejob${CI_PIPELINE_ID} | tee log.txt
- kubectl create -f simplejob.yml
# wait for job to finish to get the logs
- while true; do sleep 300; x=$(kubectl get pods -l job-name=simplejob${CI_PIPELINE_ID} -o jsonpath='{.items[0].status.phase}'); if [ $x != "Running" ]; then break; fi; done
# # copy logs of failed packages locally, to keep as job artifacts
# - oc rsync $(oc get pods -l job-name=simplejob${CI_PIPELINE_ID} -o name):/tmp ./ --include="*/" --include="spack/spack-stage/*/*.txt" --exclude="*"
# - mv tmp/spack/spack-stage spack_logs
# # also copy the spec of the created kernel, to keep as job artifacts
# - LAB_KERNEL_PATH = $LAB_KERNEL_ROOT/$(echo "$RELEASE_NAME" | tr '[:upper:]' '[:lower:]')
# - oc rsync $(oc get pods -l job-name=simplejob${CI_PIPELINE_ID} -o name):$LAB_KERNEL_PATH ./
# - mv .$LAB_KERNEL_PATH kernel_specs
# if spack install has failed, fail the pipeline
- if [ $(cat log.txt |grep "Error:"|wc -l) -gt 0 ]; then exit 1;fi;
# delete the job from OpenShift as we have the logs here
- oc delete job simplejob${CI_PIPELINE_ID} || true
- kubectl logs jobs/simplejob${CI_PIPELINE_ID} | tee log.txt
- if [ $(kubectl get pods -l job-name=simplejob${CI_PIPELINE_ID} -o jsonpath='{.items[0].status.containerStatuses[0].state.terminated.exitCode}') -ne 0 ]; then exit 1; fi;
# delete the job, as we have the logs here
- kubectl delete job simplejob${CI_PIPELINE_ID} || true
after_script:
- kubectl config use-context $KUBE_CONTEXT
- sh create_job_widget_script.sh $CI_PIPELINE_ID $RUN_ENV_DOCKER_IMAGE $INSTALLATION_ROOT $SPACK_ENV $RELEASE_NAME $LAB_KERNEL_ROOT
- cat widget-script.yml
- kubectl create -f widget-script.yml
- while true; do sleep 300; x=$(kubectl get pods -l job-name=widget-script${CI_PIPELINE_ID} -o jsonpath='{.items[0].status.phase}'); if [ $x != "Running" ]; then break; fi; done
- kubectl logs jobs/widget-script${CI_PIPELINE_ID} | tee log.txt
- if [ $(kubectl get pods -l job-name=widget-script${CI_PIPELINE_ID} -o jsonpath='{.items[0].status.containerStatuses[0].state.terminated.exitCode}') -ne 0 ]; then exit 1; fi;
- kubectl delete job widget-script${CI_PIPELINE_ID} || true
# artifacts:
# paths:
# - spack_logs
# - kernel_specs
# when: always
# -------------------------------------------------------------------
# Lab deployment target environments: dev and prod Lab instances
# -------------------------------------------------------------------
# deploy to a dev lab environment
.deploy-dev-server:
extends: .deploy-build-environment
variables:
LAB_KERNEL_ROOT: /srv/jupyterlab_kernels/int
INSTALLATION_ROOT: /srv/test-build-2502
# deploy to a prod lab environment
.deploy-prod-server:
extends: .deploy-build-environment
variables:
LAB_KERNEL_ROOT: /srv/jupyterlab_kernels/prod
INSTALLATION_ROOT: /srv/main-spack-instance-2502
# deploy to the dev lab environment at CINECA
.deploy-dev-server-cineca:
extends: .deploy-dev-server
variables:
KUBE_CONTEXT: cineca-int
resource_group: shared-NFS-mount-dev-cineca
# deploy to the prod lab environment at JSC
.deploy-prod-server-jsc:
extends: .deploy-prod-server
variables:
KUBE_CONTEXT: jsc-prod
resource_group: shared-NFS-mount-prod-jsc
# deploy to the prod lab environment at CINECA
.deploy-prod-server-cineca:
extends: .deploy-prod-server
variables:
KUBE_CONTEXT: cineca-prod
resource_group: shared-NFS-mount-prod-cineca
# -------------------------------------------------------------------
# Release types: test, experimental and official releases
# -------------------------------------------------------------------
# deploy int release (latest changes) to dev env to be tested before release to production
.deploy-int-release:
variables:
SPACK_ENV: test
RELEASE_NAME: EBRAINS-test
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PROJECT_NAMESPACE =~ /platform\/esd/ && $CI_PIPELINE_SOURCE == "push"
# deploy the experimental release of tools once a week from latest working version of int release
.deploy-exp-release:
variables:
SPACK_ENV: experimental
RELEASE_NAME: EBRAINS-experimental
# deploy the experimental release to dev env
.deploy-exp-dev-release:
extends: .deploy-exp-release
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $DEPLOYMENT == "dev"
# deploy the experimental release to prod env
.deploy-exp-prod-release:
extends: .deploy-exp-release
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $DEPLOYMENT == "prod"
# deploy the production release of tools
.deploy-prod-release:
variables:
SPACK_ENV: ebrains-24-04
RELEASE_NAME: EBRAINS-24.04
rules:
- if: $CI_COMMIT_BRANCH =~ /^ebrains/
when: manual
# -------------------------------------------------------------------
# Lab deployment jobs
# -------------------------------------------------------------------
# deploy int release to dev environment at CINECA
deploy-int-release-dev-cineca:
extends:
- .deploy-int-release
- .deploy-dev-server-cineca
# deploy exp release to dev environment at CINECA
deploy-exp-release-dev-cineca:
extends:
- .deploy-exp-dev-release
- .deploy-dev-server-cineca
# deploy exp release to prod environment at JSC
deploy-exp-release-prod-jsc:
extends:
- .deploy-exp-prod-release
- .deploy-prod-server-jsc
# deploy exp release to prod environment at CINECA
deploy-exp-release-prod-cineca:
extends:
- .deploy-exp-prod-release
- .deploy-prod-server-cineca
# deploy prod release to prod environment at JSC
deploy-prod-release-prod-jsc:
extends:
- .deploy-prod-release
- .deploy-prod-server-jsc
# deploy prod release to prod environment at CINECA
deploy-prod-release-prod-cineca:
extends:
- .deploy-prod-release
- .deploy-prod-server-cineca
# ===================================================================
# GITLAB RUNNER DEPLOYMENTS
# ===================================================================
# run test build job on any gitlab runner, trying to build latest changes
# with persistent, read-only deployment as upstream
build-spack-env-on-runner:
stage: build
tags:
- shell-runner
- docker-runner
- read-only
image: $BUILD_ENV_DOCKER_IMAGE
variables:
SPACK_DEV_ENV: ebrains-dev
SPACK_JOBS: 2
OCI_CACHE_PREFIX: ""
UPDATE_SPACK_OCI_CACHES: false
script:
# deactivate environment views (we don't need them for the test build-job)
- >
echo " view: False" >> $CI_PROJECT_DIR/site-config/$SYSTEMNAME/spack.yaml
# run installation script
- bash install_spack_env.sh $SPACK_JOBS $CI_PROJECT_DIR $CI_PROJECT_DIR $SPACK_DEV_ENV $SPACK_PATH_GITLAB $UPDATE_SPACK_OCI_CACHES $OCI_CACHE_PREFIX
after_script:
- mkdir -p $CI_PROJECT_DIR/spack_logs/installed $CI_PROJECT_DIR/spack_logs/not_installed
# for succesfully installed packages: keep the spack logs for any package modified during this CI job
- . $CI_PROJECT_DIR/spack/share/spack/setup-env.sh
- cd $(spack-python -c "print(spack.store.parse_install_tree(spack.config.get('config'))[0])")
- find . -mindepth 4 -maxdepth 4 \( -name ".spack" -o -name ".build" \) -exec cp -r --parents "{}" $CI_PROJECT_DIR/spack_logs/installed \;
# for not succesfully installed packages: also keep the spack logs for any packages that failed
- if cd /tmp/$(whoami)/spack-stage/; then find . -maxdepth 2 \( -name "*.txt" -o -name ".install_time_tests" \) -exec cp -r --parents "{}" $CI_PROJECT_DIR/spack_logs/not_installed \;; fi
# - if [ -d /tmp/spack_tests ]; then mv /tmp/spack_tests $CI_PROJECT_DIR; fi
artifacts:
paths:
- spack_logs
# - spack_tests
when: always
timeout: 2 days
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# this one fills the spack caches and updates the ESD (ebrainslab-variant) images on harbor
sync-esd-image:
stage: build
tags:
- esd_image
image: docker-registry.ebrains.eu/esd/tmp:latest
variables:
CI_SPACK_ENV: esd
SPACK_JOBS: 4
# we access the branch-specific cache here (and also update it!)
OCI_CACHE_PREFIX: ${HARBOR_HOST}/${HARBOR_PROJECT}/${CI_COMMIT_BRANCH}
UPDATE_SPACK_OCI_CACHES: true
OCI_IMAGE_PREFIX: ${HARBOR_HOST}/${HARBOR_PROJECT}/${CI_COMMIT_BRANCH}/image
INSTALLATION_ROOT: /esd
SANDBOX_ROOT_RELATIVE: esd_image
SANDBOX_ROOT: ${CI_PROJECT_DIR}/${SANDBOX_ROOT_RELATIVE}
script:
# create a sandbox/image for performing an spack install inside based on some base image/install
- apptainer build --fix-perms --sandbox ${SANDBOX_ROOT}/ docker://${BUILD_ENV_DOCKER_IMAGE}
# run installation script inside future container environment
# => DAG concretization, subsequent cache access + fetching and actual build should be separate steps
- mkdir --mode=0777 -p ${SANDBOX_ROOT}/${INSTALLATION_ROOT}
- apptainer exec --writable --bind ${CI_PROJECT_DIR}:${INSTALLATION_ROOT} --cwd ${INSTALLATION_ROOT} ${SANDBOX_ROOT} bash ./install_spack_env.sh $SPACK_JOBS $INSTALLATION_ROOT ${INSTALLATION_ROOT} $CI_SPACK_ENV "" $UPDATE_SPACK_OCI_CACHES $OCI_CACHE_PREFIX
- echo "export SYSTEMNAME=${SYSTEMNAME}" >> ${SANDBOX_ROOT}/.singularity.d/env/90-environment.sh
- echo ". ${INSTALLATION_ROOT}/vendor/spack/var/spack/environments/${CI_SPACK_ENV}/load_env.sh" >> ${SANDBOX_ROOT}/.singularity.d/env/90-environment.sh
# preparing to assemble the image: move in the CI project contents...
- shopt -s dotglob
- find . -maxdepth 1 -and -not -name "." -and -not -name "${SANDBOX_ROOT_RELATIVE}" -exec mv -t ${SANDBOX_ROOT}/${INSTALLATION_ROOT} {} \;
# convert to SIF image file
- apptainer build latest.sif "${SANDBOX_ROOT}"
# upload SIF image as an artifact to OCI repo
- oras push --username $HARBOR_USERNAME --password $HARBOR_PASSWORD ${OCI_IMAGE_PREFIX}:lab_latest.sif latest.sif && oras_ret=$? || oras_ret=$?
# convert SIF image to OCI format and upload to OCI repo
- skopeo --insecure-policy copy --dest-creds=${HARBOR_USERNAME}:${HARBOR_PASSWORD} sif:latest.sif docker://${OCI_IMAGE_PREFIX}:lab_latest.oci && skopeo_ret=$? || skopeo_ret=$?
- exit $(expr $oras_ret + $skopeo_ret)
after_script:
- mkdir -p $CI_PROJECT_DIR/spack_logs/installed $CI_PROJECT_DIR/spack_logs/not_installed
# for succesfully installed packages: keep the spack logs for any package modified during this CI job
- PKG_DIR=${SANDBOX_ROOT}/${INSTALLATION_ROOT}/spack/opt/spack/**/linux-*/gcc-13.3.0
- if cd $PKG_DIR; then find . \( -name ".spack" -o -name ".build" \) -exec cp -r --parents "{}" $CI_PROJECT_DIR/spack_logs/installed \;; fi
# for not succesfully installed packages: also keep the spack logs for any packages that failed
- if cd /tmp/$(whoami)/spack-stage/; then find . -maxdepth 2 \( -name "*.txt" -o -name ".install_time_tests" \) -exec cp -r --parents "{}" $CI_PROJECT_DIR/spack_logs/not_installed \;; fi
artifacts:
paths:
- spack_logs
when: always
timeout: 2 days
resource_group: registry-esd-master-image
rules:
# branches that update the gitlab-runner upstream (read-only) installation and the spack OCI caches
- if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == "experimental_rel" || $CI_COMMIT_BRANCH =~ /^ebrains/) && $CI_PROJECT_PATH =~ /platform\/esd\/ebrains-spack-builds/ && $CI_PIPELINE_SOURCE == "push"
when: manual
# update gitlab-runner upstream (read-only) installation
sync-gitlab-spack-instance:
stage: build
tags:
- docker-runner
- read-write
image: $BUILD_ENV_DOCKER_IMAGE
variables:
SPACK_REPO_PATH: $SPACK_PATH_GITLAB/ebrains-spack-builds
SPACK_JOBS: 16
OCI_CACHE_PREFIX: ""
UPDATE_SPACK_OCI_CACHES: false
script:
- SPACK_NFS_ENV=${CI_COMMIT_BRANCH//./-}
# create spack dir if it doesn't exist
- mkdir -p $SPACK_PATH_GITLAB
# get latest state of EBRAINS repo
- if [ ! -d $SPACK_REPO_PATH ]; then git clone $CI_REPOSITORY_URL --recurse-submodules $SPACK_REPO_PATH; fi
- cd $SPACK_REPO_PATH
- git fetch origin
- git reset --hard $CI_COMMIT_SHA
- git submodule update --force
# run installation script
- bash install_spack_env.sh $SPACK_JOBS $SPACK_PATH_GITLAB $SPACK_REPO_PATH $SPACK_NFS_ENV "" $UPDATE_SPACK_OCI_CACHES $OCI_CACHE_PREFIX
# create kernel spec, so that the environment can be used in gitlab CI jobs
- RELEASE_NAME=$(case $CI_COMMIT_BRANCH in experimental_rel) echo ebrains-experimental;; ebrains*) echo ${CI_COMMIT_BRANCH:0:10}.${CI_COMMIT_BRANCH:11};; *) echo $CI_COMMIT_BRANCH;; esac);
- bash create_JupyterLab_kernel.sh $SPACK_PATH_GITLAB $SPACK_NFS_ENV $RELEASE_NAME /mnt/ebrains_env
after_script:
- mkdir -p $CI_PROJECT_DIR/spack_logs/installed $CI_PROJECT_DIR/spack_logs/not_installed
# for succesfully installed packages: keep the spack logs for any package modified during this CI job
# (we use repo.yaml, that is modified at each start of the pipeline, as a reference file)
- . $SPACK_PATH_GITLAB/spack/share/spack/setup-env.sh
- cd $(spack-python -c "print(spack.store.parse_install_tree(spack.config.get('config'))[0])")
- find . -mindepth 4 -maxdepth 4 -newer $SPACK_REPO_PATH/repo.yaml \( -name ".spack" -o -name ".build" \) -exec cp -r --parents "{}" $CI_PROJECT_DIR/spack_logs/installed \;
# for not succesfully installed packages: also keep the spack logs for any packages that failed
- if cd /tmp/$(whoami)/spack-stage/; then find . -maxdepth 2 \( -name "*.txt" -o -name ".install_time_tests" \) -exec cp -r --parents "{}" $CI_PROJECT_DIR/spack_logs/not_installed \;; fi
artifacts:
paths:
- spack_logs
when: always
rules:
# branches that update the gitlab-runner upstream (read-only) installation
- if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == "experimental_rel" || $CI_COMMIT_BRANCH =~ /^ebrains/) && $CI_PROJECT_NAMESPACE =~ /platform\/esd/ && $CI_PIPELINE_SOURCE == "push"
when: manual
# run (scheduled) standalone tests for environment
test-gitlab-spack-instance:
stage: test
tags:
- docker-runner
- read-write
image: $BUILD_ENV_DOCKER_IMAGE
variables:
SPACK_REPO_PATH: $SPACK_PATH_GITLAB/ebrains-spack-builds
SPACK_USER_CACHE_PATH: $SPACK_PATH_GITLAB/spack/.spack
SPACK_USER_CONFIG_PATH: $SPACK_PATH_GITLAB/spack/.spack
script:
- SPACK_NFS_ENV=${CI_COMMIT_BRANCH//./-}
- source $SPACK_PATH_GITLAB/spack/share/spack/setup-env.sh
- spack env activate $SPACK_NFS_ENV
# TODO: run all tests when test dependency issue is fixed
- spack test run -x wf-brainscales2-demos wf-multi-area-model
after_script:
- if [ -d /tmp/spack_tests ]; then mv /tmp/spack_tests $CI_PROJECT_DIR; fi
artifacts:
paths:
- spack_tests
when: always
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $TEST_DEPLOYMENT == "true"
<!-- Thanks for taking the time to report this build failure. To proceed with the report please:
1. Title the issue "Installation issue: <name-of-the-package>".
2. Provide the information required below.
We encourage you to try, as much as possible, to reduce your problem to the minimal example that still reproduces the issue. That would help us a lot in fixing it quickly and effectively! -->
### Summary
| | |
|---------------|-----------------------------------------------|
| Summary | Spack package build failure |
| Package info | <!-- Spack package name or entire spec --> |
| System | <!-- HPC cluster name/Collab Lab/other --> |
| Related | <!-- Other related issues (if applicable) --> |
### Steps to reproduce the issue
<!-- Fill in the console output from the exact spec you are trying to build. -->
```console
$ spack spec -I <spec>
...
$ spack install <spec>
...
```
### Error message
<!-- Please post the error message from spack inside the <details> tag below: -->
<details><summary>Error message</summary><pre><code>
(add error logs here)
</code></pre></details>
### Information on your system
<!-- Please include the output of `spack debug report` -->
<!-- If you have any relevant configuration detail (custom `packages.yaml` or `modules.yaml`, etc.) you can add that here as well. -->
### Additional information
<!-- Please upload the following files. They should be present in the stage directory of the failing build. Also upload any config.log or similar file if one exists. -->
* [spack-build-out.txt]()
* [spack-build-env.txt]()
/label ~build-error
<!-- Thanks for taking the time to report this test failure. To proceed with the report please:
1. Title the issue "Testing issue: <name-of-the-package>".
2. Provide the information required below.
We encourage you to try, as much as possible, to reduce your problem to the minimal example that still reproduces the issue. That would help us a lot in fixing it quickly and effectively! -->
### Summary
| | |
|---------------|-----------------------------------------------|
| Summary | Spack package test failure |
| Package info | <!-- Spack package name or entire spec --> |
| System | <!-- HPC cluster name/Collab Lab/other --> |
| Related | <!-- Other related issues (if applicable) --> |
### Steps to reproduce the issue
<!-- Fill in the console output from the exact spec you are trying to build and test. -->
```console
$ spack spec -I <spec>
...
$ spack spack install --test root <spec>
...
```
### Error message
<!-- Please post the error message from install-time-test-log.txt inside the <details> tag below: -->
The test error message (first 1000 lines) from install-time-test-log.txt is the following:
<details><summary>Error message</summary><pre><code>
(add error logs here)
</code></pre></details>
### Information on your system
<!-- Please include the output of `spack debug report` -->
### Additional information
<!-- Please upload the following files. They should be present in the stage directory of the failing build. Also upload any config.log or similar file if one exists. -->
* [spack-build-out.txt]()
* [spack-build-env.txt]()
* [install-time-test-log.txt]()
/label ~test-error
### Summary
| | |
|---------------|----------------------------------------|
| Package | <!-- Spack package name --> |
| Contact point | <!-- maintainer GitLab handle --> |
| KG entry | <!-- insert link --> |
### Checks
<!-- please download the EBRAINS Software Quality checklist, fill it and replace the file below -->
* [ ] Software Quality Checklist: [SQ-Checklist.pdf](https://drive.ebrains.eu/d/6061531326d048308823/files/?p=%2FSQ-Checklist.pdf) (level: <!-- passing, silver, gold -->)
* [ ] Current maintainer is listed first in `package.py`
* [ ] No pinned dependency versions
* [ ] Post-installation tests are defined
\ No newline at end of file
### Summary
| | |
|---------------|----------------------------------------|
| Package | <!-- Spack package name --> |
| Version added | <!-- version number --> |
| Contact point | <!-- maintainer GitLab handle --> |
| KG entry | <!-- insert link --> |
### Checks
<!-- please download the EBRAINS Software Quality checklist, fill it and replace the file below -->
* [ ] Software Quality Checklist: [SQ-Checklist.pdf](https://drive.ebrains.eu/d/6061531326d048308823/files/?p=%2FSQ-Checklist.pdf) (level: <!-- passing, silver, gold -->)
* [ ] Current maintainer is listed first in `package.py`
* [ ] No pinned dependency versions
* [ ] Post-installation tests are defined
\ No newline at end of file
[submodule "vendor/spack"]
path = vendor/spack
url = https://gitlab.ebrains.eu/ri/tech-hub/platform/esd/spack.git
shallow = true
[submodule "vendor/yashchiki"]
path = vendor/yashchiki
url = https://gitlab.ebrains.eu/ri/tech-hub/platform/esd/dedal
shallow = true
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
MIT License
Copyright (c) 2013-2023 LLNS, LLC and other Spack Project Developers.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# ebrains-spack-builds
Build and distribute software with Spack
Build and distribute EBRAINS software tools with Spack.
**Quickstart**
- Open a terminal at a running Collaboratory Lab Container and execute the following:
```
git clone https://gitlab.ebrains.eu/akarmas/ebrains-spack-builds.git
cd ebrains-spack-builds
source ./load_sim_tools.sh
```
- Then you can start python and import the available tools
- Currently installed:
arbor
neuron
nest
## Introduction
Building and deploying EBRAINS tools to make them available for direct use in the Collaboratory Lab environment is a challenging task, mainly due to the number of tools and the increasing complexity of resolving their dependency conflicts. To efficiently solve this problem, we have implemented a delivery strategy based on [Spack](https://spack.io/), a package manager specifically designed to simplify the installation and management of scientific software (more information [here](https://drive.ebrains.eu/f/73bcfe5acf924cef83cc/)).
Spack is highly customizable and flexible, allowing developers to create their own packages and specify their dependencies and custom build configurations. It supports a wide range of programming languages (Python, R, C, C++, Fortran etc), different hardware architectures and operating systems. All an EBRAINS developer needs to do is create a Spack package (simple description of the build logic of their software). Then Spack automatically handles downloading, building, and installing the entire EBRAINS environment, managing all their dependencies and other requirements.
## Gitlab CI/CD Enviromental variables
## Repository
The following variable(s) must be set up if not or re-configured if tokens expire.
OPENSHIFT_TOKEN: Token to login to OpenShift cluster (with the "gitlab" service account)
## Copy spack .yaml files and packages to the Openshift job pod that does the build
This repository is where the EBRAINS Spack packages are maintained. It contains:
- the EBRAINS [Spack repository](https://spack.readthedocs.io/en/latest/repositories.html), that contains all available EBRAINS Spack packages ([packages/](packages))
- the latest EBRAINS [Spack environment](https://spack.readthedocs.io/en/latest/environments.html) ([spack.yaml](spack.yaml)), a list of the specific versions of EBRAINS tools that are part of the software release
- a script ([install_spack_env.sh](install_spack_env.sh)) that can be used to install the latest spack environment on any machine (either install from scratch or update an existing installation)
- CI/CD pipelines configured for (a) testing the installation of new packages and (b) deploying the environment to the EBRAINS Collaboratory Lab.
- (WIP) all the site-specific configurations that have been used to install the EBRAINS Spack environment in different systems, such as the EBRAINS Lab and the Fenix HPC systems.
The gitlab runner copies the spack .yaml files and packages to the OpenShift job pod.
- The runner waits until the job's pod is running to start copying the files
- The pod (built from tc/ebrains-spack-build-env:latest image) waits until the necessary file(s) has finished copying so that it can continue the build process
## Contributing
## Bulding software binaries with Spack
HBP's developers/component owners that want their EBRAINS tools to be included in the official EBRAINS releases and deployed for direct use from the Lab environment should follow those steps:
**ToDo: The current build path needs to be automated with CI (e.g. gitlab runners)**
- Fork this repository
- Clone the forked repository to local machine (or use the Gitlab Web IDE)
- Create a new Spack package for your tool. For instructions on how to do this, see [the Spack documentation](https://spack.readthedocs.io/en/latest/packaging_guide.html) and the developer's section of [our documentation](https://drive.ebrains.eu/f/73bcfe5acf924cef83cc/). **Add the new package** to the repository, by creating a directory inside [packages/](./packages/) and copying the package recipe there. Also don't forget to **add a spec** to [spack.yaml](spack.yaml)
- Commit the new package and push to a new branch, e.g. `add-packagename`
- Create a Merge Request to merge your changes into the master branch of the original repository
- Check the results of the automated test build job and solve any issues
- Once the tests pass, wait for TC to approve and merge. Once merged, the package will be automatically built and deployed to the integration environment of the Collaboratory Lab (lab-int).
- As a reference you can find [here](https://spack.readthedocs.io/en/latest/command_index.html) the Spack commands list
- We will need to have different Spack environments to test specs (and build packages) and when tests are passing release specs from testing environments to production environment
## Installing the EBRAINS official Software release
- First of all we need to create an appropriate build environment (at a dedicated VM or container image or gitlab runner). The build environment must run on the same OS as the Collaboratory base container image and fulfill all Spack's pre-requisites ( [1](https://ashki23.github.io/spack.html), [2](https://spack.readthedocs.io/en/latest/getting_started.html) )
- The Spack installation folder at build time must (currently) be:
To install the EBRAINS Spack environment on a new machine, it is recommended to follow exactly the steps from [install_spack_env.sh](install_spack_env.sh), that installs or updates and tests the spack environment defined in this repository. In general, you need to:
Clone this repository. You can use the `ebrains-yy-mm` branches to install the EBRAINS official releases, the `experimental-rel` branch for the experimental release, or the `master` branch for the latest state:
```
/opt/app-root/src
git clone --branch {branch-name} https://gitlab.ebrains.eu/ri/tech-hub/platform/esd/ebrains-spack-builds.git
```
to match the Spack installation directory on the current Collab base container image
- At the build environment a recent version of gcc must be running. Install the most appropriate gcc version based on the OS of the build environment. Below you can find the instructions to install the appropriate gcc version for CentOS 7 (current OS of Collaboratory base image).
Instructions to install **"devtoolset-9"** [here](https://linuxize.com/post/how-to-install-gcc-compiler-on-centos-7/).
- Then we can start building and installing tools with Spack:
Clone Spack. We currently use version v0.23.1:
```
spack install arbor %gcc@9.3.1
spack install neuron %gcc@9.3.1
spack install nest %gcc@9.3.1 +python
git clone --depth 1 -c advice.detachedHead=false -c feature.manyFiles=true --branch v0.23.1 https://github.com/spack/spack
```
and perform tests for the installations:
https://docs.arbor-sim.org/en/stable/tutorial/single_cell_model.html
https://neuron.yale.edu/neuron/static/docs/neuronpython/firststeps.html
https://nest-simulator.readthedocs.io/en/nest-2.20.1/auto_examples/one_neuron.html
- (Potentially) fix any potential errors for shared libraries (info [1](https://github.com/cdr/code-server/issues/766), [2](https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html), [3](https://serverkurma.com/linux/how-to-install-and-update-gcc-on-centos-7/))
Activate Spack:
```
. spack/share/spack/setup-env.sh
```
## Delivery of the software binaries
Add the project repository to your Spack environment:
```
spack repo add ebrains-spack-builds
```
**ToDo:This methodology will change, and the delivery will be be implemented via Gitlab CI and use of the shared NFS drive**
Define your site-specific configurations:
```
export SYSTEMNAME=<your-system-name>
mkdir ebrains-spack-builds/site-config/$SYSTEMNAME
# copy any site-specific .yaml files inside the new dir
```
- After build is complete, we move on to zip the **"$SPACK_ROOT"** and the **~/.spack** folders of the build environment and transfer them to CSCS Object Storage (currently, in the future it will be a shared NFS drive)
- The artifacts that were built can now be used from the Collaboratory running containers to load and run the available simulation tools
Activate the environment and install:
```
spack env activate ebrains-spack-builds
spack install --fresh
```
## Activating software in the Collaboratory Lab containers
## Troubleshooting
- Currently to load the pre-built simulation tools in the Collaboratory Lab containers refer to **Quickstart** at the beggining of this file (currently the Object Storage at CSCS is used to download the pre-built software as a stop-gap measure until a shared NFS drive is available).
- This process will change in the future as all simulation tools will be available in the Collaboratory running containers from a shared NFS drive
If you encounter any issues with installing, testing, or using the EBRAINS Spack environment or a specific package, please [open an issue](https://gitlab.ebrains.eu/ri/tech-hub/platform/esd/ebrains-spack-builds/-/issues/new) using the provided templates, or contact the Technical Coordination team directly.
#!/bin/bash
# ===========================================================================================================
# title : create_JupyterLab_kernel.sh
# usage : ./create_JupyterLab_kernel.sh $INSTALLATION_ROOT $EBRAINS_SPACK_ENV $RELEASE_NAME $LAB_KERNEL_ROOT
# description : creates a spackified JupyterLab kernel conf and places it to the NFS where it can be
# loaded by all users.
# ===========================================================================================================
set -euo pipefail
INSTALLATION_ROOT=$1
EBRAINS_SPACK_ENV=$2
RELEASE_NAME=$3
LAB_KERNEL_ROOT=$4
# kernel name is lowercase release name
KERNEL_NAME=$(echo "$RELEASE_NAME" | tr '[:upper:]' '[:lower:]')
# kernel dir is a directory inside LAB_KERNEL_ROOT named after the kernel
KERNEL_PATH=$LAB_KERNEL_ROOT/$KERNEL_NAME
# prepare the base env.sh script required for the JupyterLab kernels:
mkdir -p $KERNEL_PATH/bin
# (1) create env.sh bash script
cat <<EOF > $KERNEL_PATH/bin/env.sh
#!/usr/bin/env bash
set -euxo pipefail
EOF
# (2) append the necessary env variables for spack env and tools
cat $INSTALLATION_ROOT/spack/var/spack/environments/$EBRAINS_SPACK_ENV/load_env.sh >> $KERNEL_PATH/bin/env.sh
# also copy the script so that it can be used independently:
cp $INSTALLATION_ROOT/spack/var/spack/environments/$EBRAINS_SPACK_ENV/load_env.sh $KERNEL_PATH/bin/
# (3) also add the user's .local locations to allow package installation at runtime,
# and the location of python modules installed in the base docker Collab image
cat <<EOF >> $KERNEL_PATH/bin/env.sh
export PATH=\$PATH:/opt/app-root/src/.local/bin
export PYTHONPATH=\$PYTHONPATH:/opt/conda/lib/python3.11/site-packages
export R_LIBS_USER=/opt/app-root/src/.local/lib/R/site-library
mkdir -p \$R_LIBS_USER
export R_LIBS=\$R_LIBS_USER:\$R_LIBS
EOF
# ... and set the SYSTEMNAME env var, to use Spack commands inside the kernel
cat <<EOF >> $KERNEL_PATH/bin/env.sh
export SYSTEMNAME=ebrainslab
EOF
# (4) create startup script for python kernel
cat $KERNEL_PATH/bin/env.sh > $KERNEL_PATH/bin/env_python.sh
echo "python -m ipykernel_launcher -f \$@" >> $KERNEL_PATH/bin/env_python.sh
chmod +x $KERNEL_PATH/bin/env_python.sh
# ... and the new kernel's configuration file
mkdir -p $KERNEL_PATH/$KERNEL_NAME
cat <<EOF > $KERNEL_PATH/$KERNEL_NAME/kernel.json
{
"argv": ["$KERNEL_PATH/bin/env_python.sh", "{connection_file}", "--profile=default"],
"display_name": "$RELEASE_NAME",
"language": "python",
"env": { "LAB_KERNEL_NAME": "$RELEASE_NAME", "LAB_KERNEL_RELEASE_DATE": "$(date +"%Y-%m-%d")" }
}
EOF
# ... and add EBRAINS logo to kernel
cp $(dirname ${BASH_SOURCE[0]})/etc/logo-64x64-python.png $KERNEL_PATH/$KERNEL_NAME/logo-64x64.png
# (5) create startup script for R kernel
cat $KERNEL_PATH/bin/env.sh > $KERNEL_PATH/bin/env_r.sh
echo "R --slave -e \"IRkernel::main()\" --args \$@" >> $KERNEL_PATH/bin/env_r.sh
chmod +x $KERNEL_PATH/bin/env_r.sh
# ... and the new R kernel's configuration file
mkdir -p $KERNEL_PATH/${KERNEL_NAME}-R
cat <<EOF > $KERNEL_PATH/${KERNEL_NAME}-R/kernel.json
{
"argv": ["$KERNEL_PATH/bin/env_r.sh", "{connection_file}"],
"display_name": "R-$RELEASE_NAME",
"language": "R",
"env": { "LAB_KERNEL_NAME": "R-$RELEASE_NAME", "LAB_KERNEL_RELEASE_DATE": "$(date +"%Y-%m-%d")" }
}
EOF
# ... and add EBRAINS logo and kernel.js to kernel
cp $(dirname ${BASH_SOURCE[0]})/etc/logo-64x64-R.png $KERNEL_PATH/${KERNEL_NAME}-R/logo-64x64.png
cp $(dirname ${BASH_SOURCE[0]})/etc/kernel.js $KERNEL_PATH/${KERNEL_NAME}-R/
#!/bin/bash
BUILD_ENV=$1
OP=$2
SPACK_ENV_TAR_FILE=$3
OC_JOB_ID=$4
# ===========================================================================================================
# title : create_job.sh
# usage : ./create_job.sh $OC_JOB_ID $BUILD_ENV_DOCKER_IMAGE $INSTALLATION_ROOT
# $SPACK_ENV $COMMIT_SHA $RELEASE_NAME $LAB_KERNEL_ROOT
# description : creates OKD job yaml file that builds/updates spack environment and creates Lab kernel
# ===========================================================================================================
OC_JOB_ID=$1
BUILD_ENV_DOCKER_IMAGE=$2
INSTALLATION_ROOT=$3
EBRAINS_SPACK_ENV=$4
COMMIT_SHA=$5
RELEASE_NAME=$6
LAB_KERNEL_ROOT=$7
UPDATE_SPACK_OCI_CACHES=$8
OCI_CACHE_PREFIX=$9
cat <<EOT >> simplejob.yml
apiVersion: batch/v1
......@@ -11,29 +23,88 @@ kind: Job
metadata:
name: simplejob${OC_JOB_ID}
spec:
parallelism: 1
parallelism: 1
completions: 1
backoffLimit: 0
template:
backoffLimit: 0
template:
metadata:
name: testjob
spec:
#securityContext:
# supplementalGroups: [1000410000]
# seLinuxOptions:
# level: s0:c25,c10
containers:
- name: simplejob
image: docker-registry.ebrains.eu/tc/ebrains-spack-build-env:latest
securityContext:
runAsUser: 1000410000
image: ${BUILD_ENV_DOCKER_IMAGE}
imagePullPolicy: Always
resources:
limits:
cpu: '8'
memory: '32Gi'
requests:
cpu: '4'
memory: '20Gi'
volumeMounts:
- name: sharedbin
mountPath: /srv
command: ["/usr/local/bin/deploy-build-env.sh", "$BUILD_ENV", "$OP", "$SPACK_ENV_TAR_FILE"]
- name: tmp
mountPath: /tmp
command:
- /bin/bash
- -c
- |
# create root dir if it doesn't exist
mkdir -p \$INSTALLATION_ROOT
# reset spack repository dir by cloning the selected version
if [ ! -d \$EBRAINS_REPO_PATH ]; then git clone ${CI_PROJECT_URL} --recurse-submodules \$EBRAINS_REPO_PATH; fi
cd \$EBRAINS_REPO_PATH
git fetch origin
git reset --hard \$COMMIT_SHA
git submodule update --force
# reset build error log dir (delete previous logs to save space)
rm -rf \$BUILD_LOGS_DIR
mkdir -p \$BUILD_LOGS_DIR
cd \$BUILD_LOGS_DIR
# run installation script
bash \$EBRAINS_REPO_PATH/install_spack_env.sh \$SPACK_JOBS \$INSTALLATION_ROOT \$EBRAINS_REPO_PATH \$EBRAINS_SPACK_ENV "" \$UPDATE_SPACK_OCI_CACHES \$OCI_CACHE_PREFIX
if [ \$? -eq 0 ]
then
# build process succeeded - create or update kernel on the NFS based on the current spack environment
bash \$EBRAINS_REPO_PATH/create_JupyterLab_kernel.sh \$INSTALLATION_ROOT \$EBRAINS_SPACK_ENV \$RELEASE_NAME \$LAB_KERNEL_ROOT && exit 0
else
# build process failed - keep spack build logs and fail the pipeline
cp -r /tmp/spack/spack-stage/* \$BUILD_LOGS_DIR
exit 1
fi
env:
- name: SYSTEMNAME
value: ebrainslab
- name: INSTALLATION_ROOT
value: $INSTALLATION_ROOT
- name: EBRAINS_SPACK_ENV
value: $EBRAINS_SPACK_ENV
- name: UPDATE_SPACK_OCI_CACHES
value: '$UPDATE_SPACK_OCI_CACHES'
- name: OCI_CACHE_PREFIX
value: $OCI_CACHE_PREFIX
- name: COMMIT_SHA
value: $COMMIT_SHA
- name: RELEASE_NAME
value: $RELEASE_NAME
- name: LAB_KERNEL_ROOT
value: $LAB_KERNEL_ROOT
- name: BUILD_LOGS_DIR
value: /srv/build_logs/$EBRAINS_SPACK_ENV
- name: EBRAINS_REPO_PATH
value: $INSTALLATION_ROOT/ebrains-spack-builds
- name: SPACK_JOBS
value: '6'
volumes:
- name: sharedbin
persistentVolumeClaim:
claimName: shared-binaries
restartPolicy: Never
- name: tmp
emptyDir: {}
restartPolicy: Never
EOT
#!/bin/bash
# ===========================================================================================================
# title : create_job_widget_script.sh
# usage : ./create_job_widget_script.sh $OC_JOB_ID $RUN_ENV_DOCKER_IMAGE $INSTALLATION_ROOT
# $SPACK_ENV $RELEASE_NAME $LAB_KERNEL_ROOT
# description : creates job file that generates a script to load the jupyter extensions for a given env
# ===========================================================================================================
OC_JOB_ID=$1
RUN_ENV_DOCKER_IMAGE=$2
INSTALLATION_ROOT=$3
EBRAINS_SPACK_ENV=$4
RELEASE_NAME=$5
LAB_KERNEL_ROOT=$6
cat <<EOT >> widget-script.yml
apiVersion: batch/v1
kind: Job
metadata:
name: widget-script${OC_JOB_ID}
spec:
parallelism: 1
completions: 1
backoffLimit: 0
template:
spec:
containers:
- name: widget-script
image: ${RUN_ENV_DOCKER_IMAGE}
imagePullPolicy: Always
resources:
limits:
cpu: '1'
memory: '1Gi'
requests:
cpu: '0.5'
memory: '500Mi'
volumeMounts:
- name: sharedbin
mountPath: /srv
command:
- /bin/bash
- -c
- |
. \$INSTALLATION_ROOT/spack/share/spack/setup-env.sh
spack env activate --without-view \$EBRAINS_SPACK_ENV
KERNEL_PATH=\$LAB_KERNEL_ROOT/\$(echo "\$RELEASE_NAME" | tr '[:upper:]' '[:lower:]')
spack load --sh py-tvb-ext-bucket py-tvb-ext-unicore py-tvb-ext-xircuits > \$KERNEL_PATH/bin/widget_activation.sh
env:
- name: SYSTEMNAME
value: ebrainslab
- name: SPACK_DISABLE_LOCAL_CONFIG
value: "true"
- name: INSTALLATION_ROOT
value: "$INSTALLATION_ROOT"
- name: EBRAINS_SPACK_ENV
value: "$EBRAINS_SPACK_ENV"
- name: RELEASE_NAME
value: "$RELEASE_NAME"
- name: LAB_KERNEL_ROOT
value: "$LAB_KERNEL_ROOT"
volumes:
- name: sharedbin
persistentVolumeClaim:
claimName: shared-binaries
restartPolicy: Never
EOT
const cmd_key = /Mac/.test(navigator.platform) ? 'Cmd' : 'Ctrl'const edit_actions = [
{
name: 'R Assign',
shortcut: 'Alt--',
icon: 'fa-long-arrow-left',
help: 'R: Inserts the left-assign operator (<-)',
handler(cm) {
cm.replaceSelection(' <- ')
},
},
{
name: 'R Pipe',
shortcut: `Shift-${cmd_key}-M`,
icon: 'fa-angle-right',
help: 'R: Inserts the magrittr pipe operator (%>%)',
handler(cm) {
cm.replaceSelection(' %>% ')
},
},
{
name: 'R Help',
shortcut: 'F1',
icon: 'fa-book',
help: 'R: Shows the manpage for the item under the cursor',
handler(cm, cell) {
const {anchor, head} = cm.findWordAt(cm.getCursor())
const word = cm.getRange(anchor, head)
const callbacks = cell.get_callbacks()
const options = {silent: false, store_history: false, stop_on_error: true}
cell.last_msg_id = cell.notebook.kernel.execute(`help(\`${word}\`)`, callbacks, options)
},
},
]
const prefix = 'irkernel'
function add_edit_shortcut(notebook, actions, keyboard_manager, edit_action) {
const {name, shortcut, icon, help, handler} = edit_action
const action = {
icon, help,
help_index : 'zz',
handler: () => {
const cell = notebook.get_selected_cell()
handler(cell.code_mirror, cell)
},
}
const full_name = actions.register(action, name, prefix)
Jupyter.keyboard_manager.edit_shortcuts.add_shortcut(shortcut, full_name)
}
function render_math(pager, html) {
if (!html) return
const $container = pager.pager_element.find('#pager-container')
$container.find('p[style="text-align: center;"]').map((i, e) =>
e.outerHTML = `\\[${e.querySelector('i').innerHTML}\\]`)
$container.find('i').map((i, e) =>
e.outerHTML = `\\(${e.innerHTML}\\)`)
MathJax.Hub.Queue(['Typeset', MathJax.Hub, $container[0]])
}
define(['base/js/namespace'], ({
notebook,
actions,
keyboard_manager,
pager,
}) => ({
onload() {
edit_actions.forEach(a => add_edit_shortcut(notebook, actions, keyboard_manager, a))
pager.events.on('open_with_text.Pager', (event, {data: {'text/html': html}}) =>
render_math(pager, html))
},
}))
etc/logo-64x64-R.png

14.4 KiB

etc/logo-64x64-python.png

14 KiB

etc/logo-64x64.png

12.3 KiB

#!/bin/bash
# =========================================================================================================================================
# title : install_spack_env.sh
# usage : ./install_spack_env.sh $SPACK_JOBS $INSTALLATION_ROOT $EBRAINS_REPO $EBRAINS_SPACK_ENV $UPSTREAM_INSTANCE \
# $UPDATE_SPACK_OCI_CACHES $OCI_CACHE_PREFIX
# description : installs or updates the spack environment defined in the EBRAINS spack repo
# (if the specified spack instance doesn't exist, it also creates it)
# =========================================================================================================================================
set -eo pipefail
SPACK_JOBS=$1 # number of jobs
INSTALLATION_ROOT=$2 # where to set up the installation
EBRAINS_REPO=$3 # location of ebrains-spack-builds repository
EBRAINS_SPACK_ENV=$4 # name of EBRAINS Spack environment to be created/updated
UPSTREAM_INSTANCE=$5 # path to Spack instance to use as upstream (optional)
UPDATE_SPACK_OCI_CACHES=$6 # "true" enables updating the OCI cache for spack sources and build results
export OCI_CACHE_PREFIX=$7
# make sure spack uses the symlinked folder as path
export CI_SPACK_ROOT=${INSTALLATION_ROOT}/spack
# disable local configuration and cache directories
export SPACK_DISABLE_LOCAL_CONFIG=true
export SPACK_USER_CACHE_PATH=/tmp/spack
# define SYSTEMNAME variable in sites where it's not already defined
export SYSTEMNAME=${SYSTEMNAME:-${HPC_SYSTEM:-$BSC_MACHINE}}
# cache related variables
export CACHE_SPECFILE=${CACHE_SPECFILE:-"env_specfile.yaml"}
export YASHCHIKI_HOME=${EBRAINS_REPO}/vendor/yashchiki
export SPACK_CACHE_SOURCE=${SPACK_CACHE_SOURCE:-${CI_SPACK_ROOT}/var/spack/cache}
export SPACK_CACHE_BUILD=${SPACK_CACHE_BUILD:-${CI_SPACK_ROOT}/var/spack/cache}
if [ ! -d ${INSTALLATION_ROOT} ]; then
mkdir -p ${INSTALLATION_ROOT}
fi
# initial setup: use spack submodule if spack dir doesn't already exist
SPACK_ROOT_EXISTED=1
if [ ! -d ${CI_SPACK_ROOT} ]; then
ln -s ${EBRAINS_REPO}/vendor/spack ${CI_SPACK_ROOT}
SPACK_ROOT_EXISTED=0
fi
# activate Spack
source ${CI_SPACK_ROOT}/share/spack/setup-env.sh
if [[ $UPSTREAM_INSTANCE ]]; then
UPSTREAM_PREFIX=$(find $UPSTREAM_INSTANCE/spack/opt/spack/ -type d -name ".spack-db" 2>/dev/null | xargs -I {} dirname {})
spack config add upstreams:upstream-spack-instance:install_tree:$UPSTREAM_PREFIX
fi
if [ "${SPACK_ROOT_EXISTED}" -eq 0 ]; then
# for caching purposes it's nice if we can relocate into long paths, but we
# can't do that for existing installations -> else path
# ECM (2025-01-23) true seems to yield too large paths for some packages (e.g., gcc)
spack config add config:install_tree:padded_length:128
fi
# add repo if it does not exist
if [[ ! $(spack repo list | grep ebrains-spack-builds$) ]]
then
spack repo add $EBRAINS_REPO
fi
# make sure all fetching/clingo stuff happens before anything else
spack spec aida
# rebuild spack's database (could be an debugging session)
spack reindex
# add local mirror if it does not exist
if [[ ! $(spack mirror list | grep local_cache) ]]; then
# TODO for newer spack versions, add: --autopush --unsigned, drop create cache command below
# (Note: spack expects `build_cache/` below the folder we specify here
spack mirror add local_cache ${SPACK_CACHE_BUILD}
fi
spack compiler find
# create environment if it does not exist
if [ ! -d "${CI_SPACK_ROOT}/var/spack/environments/$EBRAINS_SPACK_ENV" ]
then
spack env create $EBRAINS_SPACK_ENV
fi
# update environment site-configs
rm -rf ${CI_SPACK_ROOT}/var/spack/environments/$EBRAINS_SPACK_ENV/site-config && cp -r $EBRAINS_REPO/site-config ${CI_SPACK_ROOT}/var/spack/environments/$EBRAINS_SPACK_ENV
# update spack.yaml: merge top-level and site-specific spack.yaml files
spack-python $EBRAINS_REPO/site-config/ymerge.py $EBRAINS_REPO/spack.yaml $EBRAINS_REPO/site-config/$SYSTEMNAME/spack.yaml > /tmp/spack.yaml
cp /tmp/spack.yaml ${CI_SPACK_ROOT}/var/spack/environments/$EBRAINS_SPACK_ENV/
# activate environment
spack env activate --without-view $EBRAINS_SPACK_ENV
spack concretize --force --fresh --test root
# dump dag to file
spack spec -y > "${CACHE_SPECFILE}"
if [ -n "${OCI_CACHE_PREFIX}" ]; then
# fetch missing sources (if packages not yet installed)
python3 ${YASHCHIKI_HOME}/fetch_cached_sources.py \
--local-cache=${SPACK_CACHE_SOURCE} \
--remote-cache-type=oci \
--remote-cache=${OCI_CACHE_PREFIX}/source_cache \
--yashchiki-home=${YASHCHIKI_HOME} \
/tmp/missing_paths_sources.dat ${CACHE_SPECFILE}
# fetch missing build results (if packages not yet installed)
python3 ${YASHCHIKI_HOME}/fetch_cached_buildresults.py \
--local-cache=${SPACK_CACHE_BUILD}/build_cache \
--remote-cache-type=oci \
--remote-cache=${OCI_CACHE_PREFIX}/build_cache \
--yashchiki-home=${YASHCHIKI_HOME} \
/tmp/missing_paths_buildresults.dat ${CACHE_SPECFILE}
fi
spack-python -c "exit(not len(spack.environment.active_environment().uninstalled_specs()))" && (
# fetch all sources but delay exit code handling
spack fetch --dependencies --missing && ret=$? || ret=$?;
if [ -n "${OCI_CACHE_PREFIX}" ] && [ "${UPDATE_SPACK_OCI_CACHES:-false}" = "true" ]; then
# push freshly fetched sources to remote cache
echo "Performing update of the source cache"
python3 ${YASHCHIKI_HOME}/update_cached_sources.py \
--local-cache=${SPACK_CACHE_SOURCE} \
--remote-cache-type=oci \
--remote-cache=${OCI_CACHE_PREFIX}/source_cache \
/tmp/missing_paths_sources.dat;
else
echo "Updating of the source cache disabled."
fi
if [ "$ret" -ne 0 ]; then
(exit $ret)
fi
)
if [ -n "${OCI_CACHE_PREFIX}" ]; then
# record the state of installed/uninstalled packages before actually installing them
dag_hashes_pre_install=$(spack-python ${YASHCHIKI_HOME}/specfile_dag_hash.py ${CACHE_SPECFILE})
fi
# install the environment, use 2 jobs to reduce the amount of required RAM
# delay exit code until we have updated the cache below
spack install --no-check-signature -y -j$SPACK_JOBS --fresh --test root && spack_install_ret=$? || spack_install_ret=$?
# no need to update the local cache nor the remote cache if we don't want to update
if [ -n "${OCI_CACHE_PREFIX}" ] && [ "${UPDATE_SPACK_OCI_CACHES:-false}" = "true" ]; then
# push previously missing (but now installed) packages to the local cache
for dag_hash in $dag_hashes_pre_install; do
spack buildcache create --unsigned --only package ${SPACK_CACHE_BUILD} /${dag_hash} && ret=$? || ret=$?
if [ $ret -ne 0 ]; then
echo "Failed to push ${dag_hash}, trying to call spack find on it:"
spack find -Lvp /${dag_hash} || true
fi
done
# upload packages from local to remote cache
echo "Performing update of the build cache"
python3 ${YASHCHIKI_HOME}/update_cached_buildresults.py \
--local-cache=${SPACK_CACHE_BUILD}/build_cache \
--remote-cache-type=oci \
--remote-cache=${OCI_CACHE_PREFIX}/build_cache \
/tmp/missing_paths_buildresults.dat
else
echo "Updating of the build cache disabled."
fi
# propagate spack install exit code
if [ $spack_install_ret -ne 0 ]; then
(exit "$spack_install_ret")
fi
# remove local cache content
if [ -d ${SPACK_CACHE_BUILD} ]; then
spack mirror destroy --mirror-name local_cache
fi
# TODO: when using spack remote OCI build caches require an index file
#spack mirror add ebrains oci://docker-registry.ebrains.eu/esd/build_cache
#spack buildcache list -a ebrains && ret=$? || ret=$?
# rebuild spack's database
spack reindex
# create load script that when sourced activates and loads the installed spack environment, using views
# this needs deactivating the environment first:
spack env deactivate
unset SPACK_LD_LIBRARY_PATH
spack env activate --sh $EBRAINS_SPACK_ENV > ${CI_SPACK_ROOT}/var/spack/environments/$EBRAINS_SPACK_ENV/load_env.sh
# create modules files with spack
# spack module tcl refresh -y
# create loads script that when sourced activates and loads the installed spack environment, using modules
# spack env loads -r
#!/bin/bash
#title :load_sim_tools.sh
#description :Script to load simulation software on the Collaboratory Lab containers from the Object Storage at CSCS.
#author :Athanasios Karmas
#date :20210601
#usage :source ./load_sim_tools.sh
#==============================================================================
echo "Setting up environment..."
cp -r /srv/test-build/spack/.spack ~
source /srv/test-build/spack/share/spack/setup-env.sh
cd /srv/test-build/
spack repo add ebrains-spack-builds
cd ~
echo "Loading packages..."
spack load -r python %gcc@10.3.0
spack load -r py-numpy %gcc@10.3.0
spack load -r py-pip %gcc@10.3.0
spack load -r arbor %gcc@10.3.0
spack load -r neuron %gcc@10.3.0
spack load -r nest@2.20.0 %gcc@10.3.0
spack load -r py-pynn %gcc@10.3.0
echo "Everything ready!"
#echo "Starting Python..."
#python
# ensure compatability with Spack v0.18.0
try:
from spack.package_base import PackageStillNeededError
except:
from spack.package import PackageStillNeededError
needed = set()
# keep packages that are part of an environment
for e in spack.environment.all_environments():
needed.update(e.all_hashes())
# also keep packages that provide compilers (and their dependencies)
for c in spack.compilers.all_compiler_specs():
pkg_spec = spack.compilers.pkg_spec_for_compiler(c)
needed.update([dep.dag_hash() for pkg in spack.store.db.query(pkg_spec) for dep in pkg.traverse()])
installed = {spec.dag_hash(): spec for spec in spack.store.db.query()}
to_remove = set(installed) - needed
# this will try to uninstall ANY package that is not part of an environment
# including test dependencies
# for a list of all the packages that will be uninstalled:
print('The following packages will be uninstalled:')
print('\n'.join(sorted([installed[h].short_spec+' ('+h+')' for h in to_remove])))
# iteratively uninstall packages with no dependents
while to_remove:
# print('New iteration')
for hash in to_remove.copy():
spec = installed[hash]
try:
spec.package.do_uninstall()
to_remove.discard(hash)
except PackageStillNeededError:
pass
# print('Not ready to remove', spec.short_spec, 'in this iteration')