Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mpsd-software-manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MPSD Computational Science
mpsd-software-manager
Commits
5be2d8ea
Commit
5be2d8ea
authored
1 year ago
by
Ashwin Kumar Karnad
Browse files
Options
Downloads
Patches
Plain Diff
install and test a fake toolchain
parent
6a159917
No related branches found
No related tags found
2 merge requests
!19
Move linux-debian11 into main
,
!1
Resolve "First draft for user interface for top level install command"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
install-mpsd-software-environment.py
+4
-2
4 additions, 2 deletions
install-mpsd-software-environment.py
tests.py
+59
-1
59 additions, 1 deletion
tests.py
with
63 additions
and
3 deletions
install-mpsd-software-environment.py
+
4
−
2
View file @
5be2d8ea
...
@@ -129,7 +129,7 @@ def prepare_environment(mpsd_release, script_dir):
...
@@ -129,7 +129,7 @@ def prepare_environment(mpsd_release, script_dir):
return
available_toolchains
return
available_toolchains
def
install_environment
(
mpsd_release
,
toolchains
,
script_dir
,
force_reinstall
,
skip_build_cache
):
def
install_environment
(
mpsd_release
,
toolchains
,
script_dir
,
force_reinstall
=
False
,
skip_build_cache
=
False
):
print
(
f
"
Installing release
{
mpsd_release
}
with toolchains
{
toolchains
}
to
{
script_dir
}
"
)
print
(
f
"
Installing release
{
mpsd_release
}
with toolchains
{
toolchains
}
to
{
script_dir
}
"
)
# Set required variables
# Set required variables
...
@@ -137,6 +137,7 @@ def install_environment(mpsd_release, toolchains, script_dir, force_reinstall, s
...
@@ -137,6 +137,7 @@ def install_environment(mpsd_release, toolchains, script_dir, force_reinstall, s
mpsd_os
=
os
.
environ
.
get
(
"
MPSD_OS
"
,
"
UNKNOWN_OS
"
)
mpsd_os
=
os
.
environ
.
get
(
"
MPSD_OS
"
,
"
UNKNOWN_OS
"
)
mpsd_microarch
=
os
.
environ
.
get
(
"
MPSD_MICROARCH
"
,
"
UNKNOWN_MICROARCH
"
)
mpsd_microarch
=
os
.
environ
.
get
(
"
MPSD_MICROARCH
"
,
"
UNKNOWN_MICROARCH
"
)
toolchain_dir
=
release_base_dir
/
mpsd_microarch
toolchain_dir
=
release_base_dir
/
mpsd_microarch
toolchain_dir
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
spack_setup_script
=
release_base_dir
/
"
spack-environments
"
/
"
spack_setup.sh
"
spack_setup_script
=
release_base_dir
/
"
spack-environments
"
/
"
spack_setup.sh
"
install_flags
=
[]
install_flags
=
[]
if
skip_build_cache
:
if
skip_build_cache
:
...
@@ -155,8 +156,9 @@ def install_environment(mpsd_release, toolchains, script_dir, force_reinstall, s
...
@@ -155,8 +156,9 @@ def install_environment(mpsd_release, toolchains, script_dir, force_reinstall, s
for
toolchain
in
toolchains
:
for
toolchain
in
toolchains
:
# Set the install log file name to config_vars["install_log_file"]
# Set the install log file name to config_vars["install_log_file"]
# and replace _toolchains_ with the toolchain name and _mpsd_spack_ver_ with mpsd_release
# and replace _toolchains_ with the toolchain name and _mpsd_spack_ver_ with mpsd_release
print
(
f
"
Installing toolchain
{
toolchain
}
to
{
toolchain_dir
}
"
)
install_log_file
=
(
install_log_file
=
(
config_vars
[
"
install
_log_file
"
]
config_vars
[
"
build
_log_file
"
]
.
replace
(
"
_toolchain_
"
,
f
"
_
{
toolchain
}
_
"
)
.
replace
(
"
_toolchain_
"
,
f
"
_
{
toolchain
}
_
"
)
.
replace
(
"
_mpsd_spack_ver_
"
,
f
"
_
{
mpsd_release
}
_
"
)
.
replace
(
"
_mpsd_spack_ver_
"
,
f
"
_
{
mpsd_release
}
_
"
)
)
)
...
...
This diff is collapsed.
Click to expand it.
tests.py
+
59
−
1
View file @
5be2d8ea
...
@@ -4,6 +4,7 @@ import importlib
...
@@ -4,6 +4,7 @@ import importlib
import
subprocess
import
subprocess
import
time
import
time
import
shutil
import
shutil
from
pathlib
import
Path
mod
=
importlib
.
import_module
(
"
install-mpsd-software-environment
"
)
mod
=
importlib
.
import_module
(
"
install-mpsd-software-environment
"
)
...
@@ -96,6 +97,9 @@ def test_setup_log_cmd(tmp_path):
...
@@ -96,6 +97,9 @@ def test_setup_log_cmd(tmp_path):
def
test_install_environment
(
tmp_path
):
def
test_install_environment
(
tmp_path
):
# Test the installation part
# This is a long test, its handy to test this with print statements printed to stdout, use:
# pytest -s
# Expect an Exception when wrong toolchains are provided
# Expect an Exception when wrong toolchains are provided
with
pytest
.
raises
(
Exception
):
with
pytest
.
raises
(
Exception
):
mod
.
install_environment
(
mod
.
install_environment
(
...
@@ -110,4 +114,58 @@ def test_install_environment(tmp_path):
...
@@ -110,4 +114,58 @@ def test_install_environment(tmp_path):
toolchains
=
[
"
foss2021a-mpi
"
],
toolchains
=
[
"
foss2021a-mpi
"
],
script_dir
=
(
tmp_path
),
script_dir
=
(
tmp_path
),
)
)
# prepare a test of global generic with only zlib to test the installation
\ No newline at end of file
# prepare dev-23a release
# script_dir = tmp_path / "test_global_generic"
# for actaual installation avoid tmp_path as the lenght of the path is too long and spack complains
script_dir
=
Path
(
'
/tmp/test_global_generic
'
)
script_dir
.
mkdir
(
exist_ok
=
True
,
parents
=
True
)
spack_environments
=
"
spack-environments
"
mpsd_release_to_test
=
"
dev-23a
"
mpsd_microarch
=
os
.
getenv
(
"
MPSD_MICROARCH
"
,
'
UNKNOWN_MICROARCH
'
)
release_base_dir
=
script_dir
/
mpsd_release_to_test
prepare_result
=
mod
.
prepare_environment
(
mpsd_release
=
mpsd_release_to_test
,
script_dir
=
(
script_dir
)
)
# Patch the spack environments to create a fake global_generic
# create a test toolchain
toolchain_src_dir
=
release_base_dir
/
"
spack-environments
"
/
"
toolchains
"
# with mod.os_chdir(toolchain_src_dir):
# subprocess.run(
# "cp -r foss2021a-mpi fuss1999a", shell=True, capture_output=True
# )
# add zlib as a spec to global_generic
with
open
(
toolchain_src_dir
/
"
global_generic
"
/
"
global_packages.list
"
,
"
w
"
)
as
f
:
f
.
write
(
"
zlib@1.2.13
\n
"
)
# add zlib to whitelist of module creation file by replacing anaconda3%gcc@10.2.1 with zlib@1.2.13
# in release_base_dir / "spack-environments/spack_overlay/etc/spack/modules.yaml"
module_file
=
release_base_dir
/
"
spack-environments/spack_overlay/etc/spack/modules.yaml
"
with
open
(
module_file
,
'
r
'
)
as
f
:
lines
=
f
.
read
().
replace
(
'
anaconda3%gcc@10.2.1
'
,
'
zlib@1.2.13
'
)
with
open
(
module_file
,
'
w
'
)
as
f
:
f
.
write
(
lines
)
# Replace gcc@10.2.1 with gcc#13.1.1 for testing on laptop
setup_file
=
release_base_dir
/
"
spack-environments/spack_setup.sh
"
with
open
(
setup_file
,
'
r
'
)
as
f
:
lines
=
f
.
read
().
replace
(
'
system_compiler=
"
gcc@10.2.1
"'
,
'
system_compiler=
"
gcc@13.1.1
"'
)
with
open
(
setup_file
,
'
w
'
)
as
f
:
f
.
write
(
lines
)
# install global_generic toolchain
install_result
=
mod
.
install_environment
(
mpsd_release
=
"
dev-23a
"
,
toolchains
=
[
"
global_generic
"
],
script_dir
=
script_dir
,
skip_build_cache
=
True
)
# assert that log files exists
assert
os
.
path
.
exists
(
release_base_dir
/
'
install.log
'
)
assert
os
.
path
.
exists
(
release_base_dir
/
mpsd_microarch
)
assert
os
.
path
.
exists
(
release_base_dir
/
mpsd_microarch
/
'
lmod
'
)
# assert that lmod/module-index.yaml contains zlib
with
open
(
release_base_dir
/
mpsd_microarch
/
'
lmod
'
/
'
module-index.yaml
'
,
'
r
'
)
as
f
:
lines
=
f
.
read
()
assert
'
zlib
'
in
lines
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment