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
b4f6543c
Commit
b4f6543c
authored
2 years ago
by
Ashwin Kumar Karnad
Browse files
Options
Downloads
Patches
Plain Diff
remove invoke wrappers
parent
0c0d5827
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
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
install-mpsd-software-environment.py
+33
-24
33 additions, 24 deletions
install-mpsd-software-environment.py
with
33 additions
and
24 deletions
install-mpsd-software-environment.py
+
33
−
24
View file @
b4f6543c
#!/usr/bin/python3
#!/usr/bin/
env
python3
import
os
import
subprocess
import
time
import
invoke
import
argparse
# Helper class to change directory via context manager
class
os_chdir
:
def
__init__
(
self
,
new_dir
):
self
.
new_dir
=
new_dir
self
.
saved_dir
=
os
.
getcwd
()
def
__enter__
(
self
):
os
.
chdir
(
self
.
new_dir
)
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
os
.
chdir
(
self
.
saved_dir
)
@invoke.task
(
help
=
{
"
mpsd_spack_ver
"
:
"
MPSD Software stack version (defaults to current branch name)
"
,
"
toolchain_list
"
:
"
Comma separated list of toolchains to build (defaults to all toolchains)
"
,
"
toolchain_base_dir
"
:
"
Base directory to install the toolchains (defaults to
'
/opt_mpsd/
'
)
"
,
"
skip_build_cache
"
:
"
Skip building the spack cache (defaults to False)
"
,
"
skip_dir_check
"
:
"
Skip checking if toolchains exists ( usefull when restarting after an error)
"
,
}
)
def
build_toolchains
(
c
,
mpsd_spack_ver
=
None
,
toolchain_list
=
None
,
toolchain_base_dir
=
"
/opt_mpsd/
"
,
...
...
@@ -25,7 +28,7 @@ def build_toolchains(
"""
Build toolchains using Spack.
This
task
builds toolchains for toolchains at the appropriate directory for the current system architecture
This
function
builds toolchains for toolchains at the appropriate directory for the current system architecture
and MPSD software stack version.
The toolchains are built using the bash script spack_setup.sh, and the results are logged.
"""
...
...
@@ -38,13 +41,18 @@ def build_toolchains(
.
stdout
.
decode
()
.
strip
()
)
current_commit_hash
=
(
subprocess
.
run
(
[
"
git
"
,
"
rev-parse
"
,
"
--short
"
,
"
HEAD
"
],
stdout
=
subprocess
.
PIPE
)
)
current_dir
=
os
.
getcwd
()
# Checks
## Check that some mpsd_spack_ver is passed.
if
mpsd_spack_ver
is
None
:
raise
invoke
.
Exit
(
raise
ValueError
(
"
Error: MPSD_SPACK_VER not passed. Please pass the MPSD Software stack version.
"
)
## Check if toolchains directory exists
...
...
@@ -54,14 +62,14 @@ def build_toolchains(
os
.
makedirs
(
toolchains_path
)
else
:
if
not
skip_dir_check
:
raise
invoke
.
Exit
(
raise
ValueError
(
f
"
Error: Toolchains directory
{
toolchains_path
}
already exists.
\n\
Please remove it and try again.
"
)
### Clone spack-env repo at spack_env_path
with
c
.
cd
(
spack_env_path
+
"
/spack-environments
"
):
c
.
run
(
"
git clone git@gitlab.gwdg.de:mpsd-cs/spack-environments.git .
"
)
c
.
run
(
f
"
git checkout
{
mpsd_spack_ver
}
"
)
with
os
.
chdir
(
spack_env_path
+
"
/spack-environments
"
):
subprocess
.
run
(
"
git clone git@gitlab.gwdg.de:mpsd-cs/spack-environments.git .
"
,
shell
=
True
,
check
=
True
)
subprocess
.
run
(
f
"
git checkout
{
mpsd_spack_ver
}
"
,
shell
=
True
,
check
=
True
)
## Check if TOOLCHAIN_LIST is valid
available_toolchains
=
os
.
listdir
(
"
toolchains
"
)
...
...
@@ -77,7 +85,7 @@ def build_toolchains(
# if not set(toolchains)<=set(available_toolchains):
for
toolchain
in
toolchains
:
if
toolchain
not
in
available_toolchains
:
raise
invoke
.
Exit
(
raise
ValueError
(
f
"
Error: Toolchain
'
{
toolchain
}
'
not found in toolchains directory.
\n\
Please check the toolchain argument and try again.
"
)
...
...
@@ -87,10 +95,11 @@ def build_toolchains(
log_file
=
f
"
build_toolchains_
{
mpsd_spack_ver
}
_
{
time
.
strftime
(
'
%Y%m%d-%H%M%S
'
)
}
.log
"
print
(
f
"
Building at
{
toolchains_path
}
...
"
)
for
toolchain
in
toolchains
:
with
c
.
cd
(
toolchains_path
):
c
.
run
(
f
"
echo
'
>>>> Building
{
toolchain
}
...
'
| tee -a
{
log_file
}
"
)
c
.
run
(
f
"
bash
{
spack_env_path
}
/spack-environments/spack_setup.sh
{
flags
}
{
toolchain
}
|tee -a
{
log_file
}
2>&1
"
with
os_chdir
(
toolchains_path
):
print
(
f
"
>>>> Building
{
toolchain
}
...
"
)
subprocess
.
run
(
f
"
bash
{
spack_env_path
}
/spack-environments/spack_setup.sh
{
flags
}
{
toolchain
}
|tee -a
{
log_file
}
2>&1
"
,
shell
=
True
,
check
=
True
)
# copy the octopus configs to the toolchain directory
#
c
.run(f"cp -r {current_dir}/octopus
{toolchains_path}")
#
subprocess
.run(f"cp -r {current_dir}/octopus
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