Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mpsd-software-manager-2
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
Package registry
Model registry
Operate
Environments
Terraform modules
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-2
Commits
41f54ef6
Commit
41f54ef6
authored
1 month ago
by
Martin Lang
Browse files
Options
Downloads
Patches
Plain Diff
Record intel modules to patch and always patch all intel modules
parent
65721572
No related branches found
No related tags found
1 merge request
!1
Code review of main
Pipeline
#582736
failed
1 month ago
Stage: linting
Stage: static-code-analysis
Stage: tests
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mpsd_software_manager/spack.py
+40
-13
40 additions, 13 deletions
src/mpsd_software_manager/spack.py
with
40 additions
and
13 deletions
src/mpsd_software_manager/spack.py
+
40
−
13
View file @
41f54ef6
...
...
@@ -15,6 +15,7 @@ from pathlib import Path
from
typing
import
Any
,
Callable
import
jinja2
import
yaml
from
.config
import
Config
from
.util
import
abort
...
...
@@ -307,6 +308,9 @@ def spack_install_package(package: str) -> None:
def
refresh_modules
(
compilers
:
dict
[
str
,
Any
]
|
None
=
None
)
->
None
:
"""
Create lmod modules and change family of intel compiler modules.
"""
CLASSIC_FAMILY
=
"
intel_classic_compiler
"
ONEAPI_FAMILY
=
"
intel_oneapi_compiler
"
logger
.
info
(
"
refreshing lmod modules
"
)
try
:
spack
(
"
module lmod refresh -y
"
,
log_callback
=
logger
.
debug
)
...
...
@@ -317,16 +321,25 @@ def refresh_modules(compilers: dict[str, Any] | None = None) -> None:
# - to allow loading gcc and intel compiler simultaneously, we replace
# 'family("compiler")' in the intel/oneapi lmod files
# - add gcc as dependent module to intel compilers
to_patch_file
=
Config
().
spack_root
/
"
etc
"
/
"
mpsd_intel_module_patching.yaml
"
# record new intel module(s) to patch
if
compilers
and
"
intel
"
in
compilers
[
"
default
"
][
"
package
"
]:
try
:
with
open
(
to_patch_file
)
as
f
:
modules_to_patch
=
yaml
.
load
(
f
,
Loader
=
yaml
.
Loader
)
except
FileNotFoundError
:
modules_to_patch
=
{}
intel_module
=
(
compilers
[
"
default
"
][
"
package
"
].
split
(
"
%
"
)[
0
].
replace
(
"
@
"
,
"
/
"
)
+
"
.lua
"
)
gcc_module
=
compilers
[
"
fallback
"
][
"
package
"
].
split
(
"
%
"
)[
0
].
replace
(
"
@
"
,
"
/
"
)
module_file
=
Config
().
lmod_root
/
"
Core
"
/
intel_module
CLASSIC_FAMILY
=
"
intel_classic_compiler
"
ONEAPI_FAMILY
=
"
intel_oneapi_compiler
"
family
=
CLASSIC_FAMILY
if
"
classic
"
in
intel_module
else
ONEAPI_FAMILY
patch_intel_module
(
module_file
,
gcc_module
,
family
)
modules_to_patch
[
module_file
]
=
{
"
family
"
:
family
,
"
gcc_module
"
:
gcc_module
}
if
family
==
"
intel_classic_compiler
"
:
# We need to also patch the intel module, which is loaded as a dependency of
# the intel classic module. We read the module name from the intel classic
...
...
@@ -338,26 +351,40 @@ def refresh_modules(compilers: dict[str, Any] | None = None) -> None:
# match.group(1) will fail should we not find the line (should never happen)
oneapi_module
=
match
.
group
(
1
)
+
"
.lua
"
oneapi_module_file
=
Config
().
lmod_root
/
"
Core
"
/
oneapi_module
patch_intel_module
(
oneapi_module_file
,
gcc_module
,
ONEAPI_FAMILY
)
modules_to_patch
[
oneapi_module_file
]
=
{
"
family
"
:
ONEAPI_FAMILY
,
"
gcc_module
"
:
gcc_module
,
}
with
open
(
to_patch_file
,
"
w
"
)
as
f
:
yaml
.
dump
(
modules_to_patch
,
f
)
# patch all intel modules
try
:
with
open
(
to_patch_file
)
as
f
:
modules_to_patch
=
yaml
.
load
(
f
)
except
FileNotFoundError
:
logger
.
debug
(
"
No intel modules to patch
"
)
return
for
module_file
in
modules_to_patch
:
gcc_module
=
modules_to_patch
[
"
module_file
"
][
"
gcc_module
"
]
family
=
modules_to_patch
[
"
module_file
"
][
"
family
"
]
patch_intel_module
(
module_file
,
gcc_module
,
family
)
def
patch_intel_module
(
module_file
:
Path
,
gcc_module
:
str
,
family
:
str
)
->
None
:
"""
Make intel modules depend on gcc and change family.
"""
logger
.
debug
(
"
Updating family(...) in
'
%s
'"
,
module_file
,
)
if
not
module_file
.
exists
():
logger
.
warning
(
"
Module
'
%s
'
does not exist; skipping
"
,
module_file
)
logger
.
debug
(
"
Updating family(...) in
'
%s
'"
,
module_file
)
content
=
module_file
.
read_text
()
content
=
content
.
replace
(
'
family(
"
compiler
"
)
'
,
f
'
family(
"
{
family
}
"
)
'
)
# Insert gcc as dependency before other dependencies and before modifying
# MODULE_PATH.
# This function can be called multiple times, so only insert if not yet present.
if
f
'
depends_on(
"
{
gcc_module
}
"
)
\n
'
not
in
content
:
logger
.
debug
(
"
Inserting dependency on
'
%s
'
in
'
%s
'"
,
gcc_module
,
module_file
,
)
logger
.
debug
(
"
Inserting dependency on
'
%s
'
in
'
%s
'"
,
gcc_module
,
module_file
)
insertion_point
=
min
(
content
.
find
(
"
depends_on(
"
),
content
.
find
(
'
prepend_path(
"
MODULEPATH
"'
)
)
...
...
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