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
0cf9b9f3
Commit
0cf9b9f3
authored
1 year ago
by
Ashwin Kumar Karnad
Browse files
Options
Downloads
Patches
Plain Diff
refactor prepate env into sub functions
parent
859fb5c5
Branches
Branches containing commit
Tags
Tags containing commit
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
+22
-4
22 additions, 4 deletions
install-mpsd-software-environment.py
with
22 additions
and
4 deletions
install-mpsd-software-environment.py
+
22
−
4
View file @
0cf9b9f3
...
@@ -62,8 +62,10 @@ def setup_log_cmd(msg=None,*args, **kwargs):
...
@@ -62,8 +62,10 @@ def setup_log_cmd(msg=None,*args, **kwargs):
# MSGs
# MSGs
with
open
(
config_vars
[
"
cmd_log_file
"
],
"
a
"
)
as
f
:
with
open
(
config_vars
[
"
cmd_log_file
"
],
"
a
"
)
as
f
:
if
msg
:
if
msg
:
# Write the message to the log file
f
.
write
(
msg
+
"
\n
"
)
f
.
write
(
msg
+
"
\n
"
)
else
:
else
:
# Write the header
f
.
write
(
"
-
"
*
50
+
"
\n
"
)
f
.
write
(
"
-
"
*
50
+
"
\n
"
)
# Gather data to log
# Gather data to log
...
@@ -79,14 +81,14 @@ def setup_log_cmd(msg=None,*args, **kwargs):
...
@@ -79,14 +81,14 @@ def setup_log_cmd(msg=None,*args, **kwargs):
# Write to log file
# Write to log file
f
.
write
(
f
"
{
datetime
.
datetime
.
now
().
isoformat
()
}
,
{
cmd_line
}
\n
"
)
f
.
write
(
f
"
{
datetime
.
datetime
.
now
().
isoformat
()
}
,
{
cmd_line
}
\n
"
)
f
.
write
(
f
.
write
(
f
"
Software environment installer branch:
{
shared_var
[
'
script_branch
'
]
}
(commit hash:
{
shared_var
[
'
script_commit_hash
'
]
}
)
\n
"
f
"
Software environment installer branch:
{
script_branch
}
(commit hash:
{
script_commit_hash
}
)
\n
"
)
)
f
.
write
(
f
.
write
(
f
"
Spack environments branch:
{
shared_var
[
'
spe_branch
'
]
}
(commit hash:
{
shared_var
[
'
spe_commit_hash
'
]
}
)
\n
"
f
"
Spack environments branch:
{
spe_branch
}
(commit hash:
{
spe_commit_hash
}
)
\n
"
)
)
def
create_dir_structure
(
mpsd_release
,
script_dir
):
def
prepare_environment
(
mpsd_release
,
script_dir
):
# Create the directory structure for the release
release_base_dir
=
os
.
path
.
join
(
script_dir
,
mpsd_release
)
release_base_dir
=
os
.
path
.
join
(
script_dir
,
mpsd_release
)
if
not
os
.
path
.
exists
(
release_base_dir
):
if
not
os
.
path
.
exists
(
release_base_dir
):
os
.
makedirs
(
release_base_dir
)
os
.
makedirs
(
release_base_dir
)
...
@@ -109,6 +111,13 @@ def prepare_environment(mpsd_release, script_dir):
...
@@ -109,6 +111,13 @@ def prepare_environment(mpsd_release, script_dir):
subprocess
.
run
([
"
git
"
,
"
checkout
"
,
mpsd_release
])
subprocess
.
run
([
"
git
"
,
"
checkout
"
,
mpsd_release
])
subprocess
.
run
([
"
git
"
,
"
pull
"
])
subprocess
.
run
([
"
git
"
,
"
pull
"
])
def
get_release_info
(
mpsd_release
,
script_dir
):
# Get the info for release
release_base_dir
=
os
.
path
.
join
(
script_dir
,
mpsd_release
)
if
not
os
.
path
.
exists
(
release_base_dir
):
raise
Exception
(
"
Release directory does not exist. Run create_dir_structure() first.
"
)
with
os_chdir
(
release_base_dir
):
with
os_chdir
(
"
spack-environments
"
):
# Get the branch and commit hash of the spack-environments repo and store them in shared_var
# Get the branch and commit hash of the spack-environments repo and store them in shared_var
spe_commit_hash
=
(
spe_commit_hash
=
(
subprocess
.
run
([
"
git
"
,
"
rev-parse
"
,
"
HEAD
"
],
stdout
=
subprocess
.
PIPE
)
subprocess
.
run
([
"
git
"
,
"
rev-parse
"
,
"
HEAD
"
],
stdout
=
subprocess
.
PIPE
)
...
@@ -123,6 +132,15 @@ def prepare_environment(mpsd_release, script_dir):
...
@@ -123,6 +132,15 @@ def prepare_environment(mpsd_release, script_dir):
.
strip
()
.
strip
()
)
)
available_toolchains
=
os
.
listdir
(
"
toolchains
"
)
available_toolchains
=
os
.
listdir
(
"
toolchains
"
)
return
spe_branch
,
spe_commit_hash
,
available_toolchains
def
prepare_environment
(
mpsd_release
,
script_dir
):
# create the release folder and clone the spack-environments repo
# get the branch and commit hash of the spack-environments repo and available toolchains
# log the command usage.
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
(
spe_branch
=
spe_branch
,
spe_commit_hash
=
spe_commit_hash
)
return
available_toolchains
return
available_toolchains
...
...
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