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
6a159917
Commit
6a159917
authored
1 year ago
by
Ashwin Kumar Karnad
Browse files
Options
Downloads
Patches
Plain Diff
update and test logging
parent
062bb997
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
+39
-39
39 additions, 39 deletions
install-mpsd-software-environment.py
tests.py
+16
-9
16 additions, 9 deletions
tests.py
with
55 additions
and
48 deletions
install-mpsd-software-environment.py
+
39
−
39
View file @
6a159917
...
...
@@ -15,7 +15,7 @@ for given system architecture and MPSD software stack version.\n
The toolchains are built using the bash script spack_setup.sh, and the results are logged.
"""
config_vars
=
{
"
cmd_log_file
"
:
"
logs/
install
-software-environment
.log
"
,
"
cmd_log_file
"
:
"
install.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
"
,
}
...
...
@@ -34,44 +34,44 @@ class os_chdir:
os
.
chdir
(
self
.
saved_dir
)
def
setup_log_cmd
(
msg
=
None
,
*
args
,
**
kwargs
):
# Create log directory if it doesn't exist
if
not
os
.
path
.
exists
(
"
logs
"
):
os
.
makedirs
(
"
logs
"
)
# Write to the log file with the following format
# --------------------------------------------------
# 2023-02-29T23:32:01, install-software-environment.py --release dev-23a --install ALL
# Software environment installer branch: script_branch (commit hash: script_commit_hash)
# Spack environments branch: dev-23a (commit hash: spe_commit_hash)
# MSGs
with
open
(
config_vars
[
"
cmd_log_file
"
],
"
a
"
)
as
f
:
if
msg
:
# Write the message to the log file
f
.
write
(
msg
+
"
\n
"
)
else
:
# Write the header
f
.
write
(
"
-
"
*
50
+
"
\n
"
)
# Gather data to log
# call statement:
cmd_line
=
"
"
.
join
(
sys
.
argv
)
# script branch and commit hash
script_branch
=
(
subprocess
.
run
([
"
git
"
,
"
rev-parse
"
,
"
--abbrev-ref
"
,
"
HEAD
"
],
stdout
=
subprocess
.
PIPE
)
.
stdout
.
decode
()
.
strip
()
)
script_commit_hash
=
(
subprocess
.
run
([
"
git
"
,
"
rev-parse
"
,
"
--short
"
,
"
HEAD
"
],
stdout
=
subprocess
.
PIPE
).
stdout
.
decode
().
strip
()
)
# spack-environments branch and commit hash from kwargs
spe_branch
=
kwargs
.
get
(
"
spe_branch
"
,
None
)
spe_commit_hash
=
kwargs
.
get
(
"
spe_commit_hash
"
,
None
)
def
setup_log_cmd
(
mpsd_release
,
script_dir
,
msg
=
None
,
*
args
,
**
kwargs
):
release_base_dir
=
script_dir
/
mpsd_release
with
os_chdir
(
release_base_dir
):
# Write to the log file with the following format
# --------------------------------------------------
# 2023-02-29T23:32:01, install-software-environment.py --release dev-23a --install ALL
# Software environment installer branch: script_branch (commit hash: script_commit_hash)
# Spack environments branch: dev-23a (commit hash: spe_commit_hash)
# MSGs
with
open
(
config_vars
[
"
cmd_log_file
"
],
"
a
"
)
as
f
:
if
msg
:
# Write the message to the log file
f
.
write
(
msg
+
"
\n
"
)
else
:
# Write the header
f
.
write
(
"
-
"
*
50
+
"
\n
"
)
# Gather data to log
# call statement:
cmd_line
=
"
"
.
join
(
sys
.
argv
)
# script branch and commit hash
script_branch
=
(
subprocess
.
run
([
"
git
"
,
"
rev-parse
"
,
"
--abbrev-ref
"
,
"
HEAD
"
],
stdout
=
subprocess
.
PIPE
)
.
stdout
.
decode
()
.
strip
()
)
script_commit_hash
=
(
subprocess
.
run
([
"
git
"
,
"
rev-parse
"
,
"
--short
"
,
"
HEAD
"
],
stdout
=
subprocess
.
PIPE
).
stdout
.
decode
().
strip
()
)
# spack-environments branch and commit hash from kwargs
spe_branch
=
kwargs
.
get
(
"
spe_branch
"
,
None
)
spe_commit_hash
=
kwargs
.
get
(
"
spe_commit_hash
"
,
None
)
# Write to log file
f
.
write
(
f
"
{
datetime
.
datetime
.
now
().
isoformat
()
}
,
{
cmd_line
}
\n
"
)
f
.
write
(
f
"
Software environment installer branch:
{
script_branch
}
(commit hash:
{
script_commit_hash
}
)
\n
"
)
f
.
write
(
f
"
Spack environments branch:
{
spe_branch
}
(commit hash:
{
spe_commit_hash
}
)
\n
"
)
# Write to log file
f
.
write
(
f
"
{
datetime
.
datetime
.
now
().
isoformat
()
}
,
{
cmd_line
}
\n
"
)
f
.
write
(
f
"
Software environment installer branch:
{
script_branch
}
(commit hash:
{
script_commit_hash
}
)
\n
"
)
f
.
write
(
f
"
Spack environments branch:
{
spe_branch
}
(commit hash:
{
spe_commit_hash
}
)
\n
"
)
def
create_dir_structure
(
mpsd_release
,
script_dir
):
...
...
@@ -125,7 +125,7 @@ def prepare_environment(mpsd_release, script_dir):
create_dir_structure
(
mpsd_release
,
script_dir
)
spe_branch
,
spe_commit_hash
,
available_toolchains
=
get_release_info
(
mpsd_release
,
script_dir
)
setup_log_cmd
(
spe_branch
=
spe_branch
,
spe_commit_hash
=
spe_commit_hash
)
setup_log_cmd
(
mpsd_release
,
script_dir
,
spe_branch
=
spe_branch
,
spe_commit_hash
=
spe_commit_hash
)
return
available_toolchains
...
...
This diff is collapsed.
Click to expand it.
tests.py
+
16
−
9
View file @
6a159917
...
...
@@ -69,23 +69,30 @@ def test_prepare_environment(tmp_path):
def
test_setup_log_cmd
(
tmp_path
):
# check that logs/install-software-environment.log is updated when the module is run
log_file
=
"
logs/install-software-environment.log
"
if
os
.
path
.
exists
(
log_file
):
log_file
=
"
install.log
"
script_dir
=
tmp_path
/
"
test_prepare_env
"
spack_environments
=
"
spack-environments
"
mpsd_release_to_test
=
"
dev-23a
"
release_base_dir
=
script_dir
/
mpsd_release_to_test
if
os
.
path
.
exists
(
release_base_dir
/
log_file
):
initial_bytes
=
os
.
path
.
getsize
(
log_file
)
else
:
initial_bytes
=
0
# run the prepare_env functionality
mod
.
prepare_env
(
toolchain_base_dir
=
(
tmp_path
),
mpsd_spack_ver
=
"
dev-23a
"
,
skip_dir_check
=
False
,
shared_var
=
shared_var
,
result
=
mod
.
prepare_environment
(
mpsd_release
=
mpsd_release_to_test
,
script_dir
=
(
script_dir
)
)
# check that logs/install-software-environment.log is updated
assert
os
.
path
.
exists
(
"
logs/install-software-environment.log
"
)
assert
os
.
path
.
getsize
(
"
logs/install-software-environment.log
"
)
>
initial_bytes
assert
os
.
path
.
exists
(
release_base_dir
/
log_file
)
assert
os
.
path
.
getsize
(
release_base_dir
/
log_file
)
>
initial_bytes
# Check that the log file has "Spack environments branch: dev-23a " in the last line
with
open
(
release_base_dir
/
log_file
,
"
r
"
)
as
f
:
last_line
=
f
.
readlines
()[
-
1
]
assert
"
Spack environments branch: dev-23a
"
in
last_line
def
test_install_environment
(
tmp_path
):
...
...
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