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
041cf7b0
Commit
041cf7b0
authored
1 year ago
by
Ashwin Kumar Karnad
Browse files
Options
Downloads
Patches
Plain Diff
remove the class
parent
6b2cd035
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
+3
-121
3 additions, 121 deletions
install-mpsd-software-environment.py
with
3 additions
and
121 deletions
install-mpsd-software-environment.py
+
3
−
121
View file @
041cf7b0
...
@@ -16,6 +16,7 @@ The toolchains are built using the bash script spack_setup.sh, and the results a
...
@@ -16,6 +16,7 @@ The toolchains are built using the bash script spack_setup.sh, and the results a
"""
"""
config_vars
=
{
config_vars
=
{
"
cmd_log_file
"
:
"
logs/install-software-environment.log
"
,
"
cmd_log_file
"
:
"
logs/install-software-environment.log
"
,
"
build_log_file
"
:
f
"
build_toolchains_mpsd_spack_ver_
{
time
.
strftime
(
'
%Y%m%d-%H%M%S
'
)
}
.log
"
,
# TODO: modify toolchains,mpsd_spack_ver when the variable is available
"
spack_environments_repo
"
:
"
https://gitlab.gwdg.de/mpsd-cs/spack-environments.git
"
,
"
spack_environments_repo
"
:
"
https://gitlab.gwdg.de/mpsd-cs/spack-environments.git
"
,
}
}
...
@@ -26,6 +27,7 @@ shared_var ={
...
@@ -26,6 +27,7 @@ shared_var ={
"
spe_commit_hash
"
:
None
,
"
spe_commit_hash
"
:
None
,
"
available_toolchains
"
:
None
,
"
available_toolchains
"
:
None
,
"
toolchain_base_dir
"
:
None
,
"
toolchain_base_dir
"
:
None
,
}
}
# Helper class to change directory via context manager
# Helper class to change directory via context manager
...
@@ -40,7 +42,7 @@ class os_chdir:
...
@@ -40,7 +42,7 @@ class os_chdir:
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
os
.
chdir
(
self
.
saved_dir
)
os
.
chdir
(
self
.
saved_dir
)
def
setup_log_cmd
(
shared_var
):
def
setup_log_cmd
(
shared_var
,
msg
=
None
):
# Create log directory if it doesn't exist
# Create log directory if it doesn't exist
if
not
os
.
path
.
exists
(
"
logs
"
):
if
not
os
.
path
.
exists
(
"
logs
"
):
os
.
makedirs
(
"
logs
"
)
os
.
makedirs
(
"
logs
"
)
...
@@ -65,126 +67,6 @@ def setup_log_cmd(shared_var):
...
@@ -65,126 +67,6 @@ def setup_log_cmd(shared_var):
)
)
class
builder
:
def
__init__
(
self
,
release
,
cmd
,
toolchain_list
=
None
,
target_dir
=
None
,
skip_build_cache
=
False
)
->
None
:
# Variables taken from cli arguments
self
.
mpsd_os
=
os
.
getenv
(
"
MPSD_OS
"
,
"
UNKNOWN_OS
"
)
self
.
mpsd_microarch
=
os
.
getenv
(
"
MPSD_MICROARCH
"
,
"
UNKNOWN_MICROARCH
"
)
self
.
mpsd_spack_ver
=
release
self
.
toolchain_list
=
toolchain_list
if
target_dir
==
"
DEFAULT
"
or
target_dir
is
None
:
target_dir
=
(
f
"
/opt_mpsd/
{
self
.
mpsd_os
}
/
{
self
.
mpsd_spack_ver
}
/
{
self
.
mpsd_microarch
}
"
)
self
.
toolchain_base_dir
=
Path
(
target_dir
)
self
.
skip_build_cache
=
skip_build_cache
self
.
skip_dir_check
=
False
self
.
current_dir
=
os
.
getcwd
()
self
.
run_mode
=
cmd
# Spack environments related variables
self
.
spe_branch
=
None
# To be set after cloning the spack-environments repo
self
.
spe_commit_hash
=
(
None
# To be set after cloning the spack-environments repo
)
# script related variables
self
.
script_branch
=
(
subprocess
.
run
(
[
"
git
"
,
"
rev-parse
"
,
"
--abbrev-ref
"
,
"
HEAD
"
],
stdout
=
subprocess
.
PIPE
)
.
stdout
.
decode
()
.
strip
()
)
self
.
script_commit_hash
=
(
subprocess
.
run
(
[
"
git
"
,
"
rev-parse
"
,
"
--short
"
,
"
HEAD
"
],
stdout
=
subprocess
.
PIPE
)
.
stdout
.
decode
()
.
strip
()
)
# Two log files, one for logging commands and the other for logging the build process
self
.
cmd_log_file
=
"
logs/install-software-environment.log
"
self
.
build_log_file
=
f
"
build_toolchains_
{
self
.
mpsd_spack_ver
}
_
{
time
.
strftime
(
'
%Y%m%d-%H%M%S
'
)
}
.log
"
# run the script
# self.run() # better to call this seperately after creating the object
def
run
(
self
):
if
self
.
run_mode
==
"
remove
"
:
pass
# self.remove_toolchains()
elif
self
.
run_mode
==
"
start_new
"
:
pass
# self.start_new_env()
elif
self
.
run_mode
==
"
install
"
:
pass
# self.build_toolchains()
else
:
self
.
prepare_env
()
def
prepare_env
(
self
):
# ensure required arguments are not None
if
self
.
toolchain_base_dir
is
None
:
raise
ValueError
(
"
Error: Please specify the target directory
"
)
if
self
.
mpsd_spack_ver
is
None
:
raise
ValueError
(
"
Error: Please specify the release version to install
"
)
if
self
.
toolchain_base_dir
is
None
:
raise
ValueError
(
"
Error: Please specify the target directory for installation
"
)
if
not
os
.
path
.
exists
(
self
.
toolchain_base_dir
):
os
.
makedirs
(
self
.
toolchain_base_dir
)
else
:
if
not
self
.
skip_dir_check
:
raise
ValueError
(
f
"
Error: Target directory
{
self
.
toolchain_base_dir
}
already exists.
\n\
Please remove it and try again.
"
)
with
os_chdir
(
self
.
toolchain_base_dir
):
subprocess
.
run
(
[
"
git
"
,
"
clone
"
,
"
https://gitlab.gwdg.de/mpsd-cs/spack-environments.git
"
,
]
)
with
os_chdir
(
"
spack-environments
"
):
subprocess
.
run
([
"
git
"
,
"
checkout
"
,
self
.
mpsd_spack_ver
])
self
.
spe_branch
=
subprocess
.
run
(
[
"
git
"
,
"
rev-parse
"
,
"
--abbrev-ref
"
,
"
HEAD
"
],
stdout
=
subprocess
.
PIPE
,
).
stdout
.
decode
()
self
.
spe_commit_hash
=
subprocess
.
run
(
[
"
git
"
,
"
rev-parse
"
,
"
--short
"
,
"
HEAD
"
],
stdout
=
subprocess
.
PIPE
).
stdout
.
decode
()
# keep the available toolchains in current spack-environments branch
self
.
available_toolchains
=
os
.
listdir
(
"
toolchains
"
)
# Setup the log file for commands
self
.
setup_log_cmd
()
def
build_toolchains
(
self
,
release
,
install
,
target_dir
,
force_reinstall
,
skip_build_cache
,
skip_dir_check
,
):
# ensure required arguments are not None
if
self
.
toolchain_list
is
None
:
raise
ValueError
(
"
Error: Please specify the toolchains to install
"
)
self
.
prepare_env
()
def
start_new_env
(
set_up
,
from_release
):
pass
def
remove_toolchain
(
release
,
remove
):
pass
def
main
():
def
main
():
...
...
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