Skip to content
Snippets Groups Projects
Commit 56733b55 authored by Eleni Mathioulaki's avatar Eleni Mathioulaki
Browse files

Merge branch 'fix-wf-tests' into 'master'

fix wf notebook tests

See merge request technical-coordination/project-internal/devops/platform/ebrains-spack-builds!453
parents 8dfd10c9 2d5b404e
No related branches found
No related tags found
No related merge requests found
...@@ -180,9 +180,9 @@ build-spack-env-on-runner: ...@@ -180,9 +180,9 @@ build-spack-env-on-runner:
- mkdir -p $CI_PROJECT_DIR/spack_logs/installed $CI_PROJECT_DIR/spack_logs/not_installed - 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 # for succesfully installed packages: keep the spack logs for any package modified during this CI job
- PKG_DIR=$CI_PROJECT_DIR/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-10.3.0 - PKG_DIR=$CI_PROJECT_DIR/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-10.3.0
- if cd $PKG_DIR; then find . \( -name ".spack" -o -name ".build" -o -name ".spack_test_results" \) -exec cp -r --parents "{}" $CI_PROJECT_DIR/spack_logs/installed \;; fi - 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 # 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" -exec cp --parents "{}" $CI_PROJECT_DIR/spack_logs/not_installed \;; fi - 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 # - if [ -d /tmp/spack_tests ]; then mv /tmp/spack_tests $CI_PROJECT_DIR; fi
artifacts: artifacts:
paths: paths:
...@@ -215,9 +215,9 @@ sync-gitlab-spack-instance: ...@@ -215,9 +215,9 @@ sync-gitlab-spack-instance:
# for succesfully installed packages: keep the spack logs for any package modified during this CI job # 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) # (we use repo.yaml, that is modified at each start of the pipeline, as a reference file)
- PKG_DIR=$SPACK_PATH_GITLAB/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-10.3.0 - PKG_DIR=$SPACK_PATH_GITLAB/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-10.3.0
- if cd $PKG_DIR; then find . -newer $SPACK_REPO_PATH/repo.yaml \( -name ".spack" -o -name ".spack_test_results" -o -name ".build" \) -exec cp -r --parents "{}" $CI_PROJECT_DIR/spack_logs/installed \;; fi - if cd $PKG_DIR; then find . -newer $SPACK_REPO_PATH/repo.yaml \( -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 # 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" -exec cp --parents "{}" $CI_PROJECT_DIR/spack_logs/not_installed \;; fi - 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: artifacts:
paths: paths:
- spack_logs - spack_logs
......
...@@ -39,20 +39,30 @@ class WfBrainscales2Demos(Package): ...@@ -39,20 +39,30 @@ class WfBrainscales2Demos(Package):
def install(self, spec, prefix): def install(self, spec, prefix):
install_tree(".", join_path(prefix, "notebooks")) install_tree(".", join_path(prefix, "notebooks"))
def _nbconvert(self, nb, nb_out):
jupyter = Executable("jupyter")
args = [
"nbconvert",
"--ExecutePreprocessor.kernel_name=python3",
"--execute",
"--to",
"notebook",
nb,
"--output",
nb_out
]
try:
# execute notebook and save
jupyter(*args)
except Exception as e:
# if the above fails, re-run notebook to produce output with error
jupyter(*(args+["--allow-errors"]))
raise
def _run_notebooks(self, output_dir): def _run_notebooks(self, output_dir):
mkdirp(output_dir) mkdirp(output_dir)
# execute notebook and save
jupyter = Executable("jupyter")
for fn in glob(join_path(prefix, "notebooks", "ts*.ipynb")) + glob(join_path(prefix, "notebooks", "tp*.ipynb")): for fn in glob(join_path(prefix, "notebooks", "ts*.ipynb")) + glob(join_path(prefix, "notebooks", "tp*.ipynb")):
jupyter("nbconvert", self._nbconvert(fn, join_path(output_dir, os.path.basename(fn)))
"--ExecutePreprocessor.kernel_name=python3",
"--execute",
"--allow-errors",
"--to",
"notebook",
fn,
"--output",
join_path(output_dir, os.path.basename(fn)))
def _set_collab_things(self): def _set_collab_things(self):
# enable "EBRAINS lab" mode # enable "EBRAINS lab" mode
...@@ -66,7 +76,8 @@ class WfBrainscales2Demos(Package): ...@@ -66,7 +76,8 @@ class WfBrainscales2Demos(Package):
def installcheck(self): def installcheck(self):
self._set_collab_things() self._set_collab_things()
# TODO (ECM): Provide a selection of notebooks that perform local-only tests. # TODO (ECM): Provide a selection of notebooks that perform local-only tests.
#self._run_notebooks(join_path(self.prefix, ".spack_test_results")) # self._run_notebooks(join_path(self.stage.path, ".install_time_tests"))
# copy_tree(join_path(self.stage.path, ".install_time_tests"), join_path(self.prefix, '.build'))
def test_notebooks(self): def test_notebooks(self):
self._set_collab_things() self._set_collab_things()
......
...@@ -33,24 +33,35 @@ class WfMultiAreaModel(Package): ...@@ -33,24 +33,35 @@ class WfMultiAreaModel(Package):
def install(self, spec, prefix): def install(self, spec, prefix):
install_tree(".", join_path(prefix, "notebooks")) install_tree(".", join_path(prefix, "notebooks"))
def _run_notebooks(self, output_dir): def _nbconvert(self, nb, nb_out):
mkdirp(output_dir)
# execute notebook and save
jupyter = Executable("jupyter") jupyter = Executable("jupyter")
jupyter("nbconvert", args = [
"nbconvert",
"--ExecutePreprocessor.kernel_name=python3", "--ExecutePreprocessor.kernel_name=python3",
"--execute", "--execute",
"--allow-errors",
"--to", "--to",
"notebook", "notebook",
join_path(self.prefix, "notebooks", "multi-area-model.ipynb"), nb,
"--output", "--output",
join_path(output_dir, "multi-area-model.ipynb")) nb_out
]
try:
# execute notebook and save
jupyter(*args)
except Exception as e:
# if the above fails, re-run notebook to produce output with error
jupyter(*(args+["--allow-errors"]))
raise
def _run_notebooks(self, output_dir):
mkdirp(output_dir)
self._nbconvert(join_path(self.prefix, "notebooks", "multi-area-model.ipynb"), join_path(output_dir, "multi-area-model.ipynb"))
@run_after("install") @run_after("install")
@on_package_attributes(run_tests=True) @on_package_attributes(run_tests=True)
def installcheck(self): def installcheck(self):
self._run_notebooks(join_path(self.prefix, ".spack_test_results")) self._run_notebooks(join_path(self.stage.path, ".install_time_tests"))
copy_tree(join_path(self.stage.path, ".install_time_tests"), join_path(self.prefix, '.build'))
def test_notebook(self): def test_notebook(self):
self._run_notebooks(join_path(self.test_suite.stage, self.spec.format("out-{name}-{version}-{hash:7}"))) self._run_notebooks(join_path(self.test_suite.stage, self.spec.format("out-{name}-{version}-{hash:7}")))
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment