Skip to content
Snippets Groups Projects

Draft: feat(wf-unicore-examples): add initial version

3 unresolved threads
Compare and
2 files
+ 71
0
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 70
0
 
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
 
# Spack Project Developers. See the top-level COPYRIGHT file for details.
 
#
 
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
 
 
from spack import *
 
 
 
class WfUnicoreExamples(Package):
 
"""Meta-package to collect all dependencies of the UNICORE Examples."""
 
 
homepage="https://www.unicore.eu/"
 
git = "https://gitlab.ebrains.eu/terhorst/supercomputers-via-unicore"
 
maintainer = ["bschuller"]
 
 
version("0.1.0", tag="v0.1.0")
 
version("master", branch="master")
 
 
depends_on("py-pyunicore@1.0.0:", type=("run", "test"))
 
 
def install(self, spec, prefix):
 
install_tree(".", join_path(prefix, ""))
 
 
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):
 
mkdirp(output_dir)
 
for nbname in [
 
'1-Basics 1 - REST API.ipynb',
 
'1-Basics 2 - PyUNICORE.ipynb',
 
'2-Jobs 1 - Running jobs.ipynb',
 
'2-Jobs 2 - Pre and post processing.ipynb',
 
'3-Data 1 - Storages and files.ipynb',
 
'3-Data 2 - Data transfer.ipynb',
 
'4-Workflows 1 - Getting started.ipynb',
 
'4-Workflows 2 - Data handling.ipynb',
 
'5-Hands-On - JUSUF.ipynb',
 
'5-Hands-On - No HPC access.ipynb',
 
]:
 
self._nbconvert(
 
join_path(self.prefix, nbname),
 
join_path(output_dir, nbname.replace(".ipynb", " - output"))
 
)
 
 
@run_after("install")
 
@on_package_attributes(run_tests=True)
 
def installcheck(self):
 
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):
 
self._run_notebooks(join_path(self.test_suite.stage, self.spec.format("out-{name}-{version}-{hash:7}")))