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
85d0ddd3
Commit
85d0ddd3
authored
1 year ago
by
Ashwin Kumar Karnad
Browse files
Options
Downloads
Patches
Plain Diff
log removal of package sets
parent
fd5a417a
No related branches found
No related tags found
1 merge request
!82
Remove cmd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mpsd_software_manager/mpsd_software.py
+34
-7
34 additions, 7 deletions
src/mpsd_software_manager/mpsd_software.py
with
34 additions
and
7 deletions
src/mpsd_software_manager/mpsd_software.py
+
34
−
7
View file @
85d0ddd3
...
...
@@ -1133,20 +1133,34 @@ def remove_environment(mpsd_release, root_dir, package_sets="NONE", force_remove
if
input
().
lower
()
!=
"
y
"
:
sys
.
exit
(
60
)
# Set the remove log file name from create_log_file_names
build_log_path
=
get_log_file_path
(
mpsd_release
,
"
remove
"
,
root_dir
,
"
ALL
"
)
logging
.
info
(
f
"
> Logging removal of
{
mpsd_release
}
at
{
build_log_path
}
"
)
folders_to_remove
=
os
.
listdir
(
dir_to_remove
)
# skip logs folder
# if "logs" in folders_to_remove:
# folders_to_remove.remove("logs")
for
folder
in
folders_to_remove
:
# shutil.rmtree(dir_to_remove / folder) #dosent delete file
run
(
f
"
rm -rf
{
dir_to_remove
/
folder
}
"
,
shell
=
True
,
check
=
True
)
run
(
f
"
rm -rf
{
dir_to_remove
/
folder
}
2>&1 | tee
{
build_log_path
}
"
,
shell
=
True
,
check
=
True
,
)
logging
.
warning
(
f
"
Removed release
{
mpsd_release
}
from
{
root_dir
}
"
)
return
# 3rd case: remove specific package_sets from release
for
package_set
in
package_sets
:
# we load the spack environment and remove the package_set
build_log_path
=
get_log_file_path
(
mpsd_release
,
"
remove
"
,
root_dir
,
package_set
)
logging
.
info
(
f
"
> Logging removal of
{
package_set
}
at
{
build_log_path
}
"
)
if
package_set
not
in
[
"
global_generic
"
,
"
global
"
]:
remove_spack_environment
(
dir_to_remove
/
"
spack
"
,
package_set
)
remove_spack_environment
(
dir_to_remove
/
"
spack
"
,
package_set
,
build_log_path
)
else
:
# list all specs from the global_packages.list
spe_folder
=
root_dir
/
mpsd_release
/
"
spack-environments
"
...
...
@@ -1166,10 +1180,10 @@ def remove_environment(mpsd_release, root_dir, package_sets="NONE", force_remove
# remove all packages in package_list
for
package
in
package_list
:
logging
.
info
(
f
"
Removing package
{
package
}
from installation
"
)
remove_spack_package
(
dir_to_remove
/
"
spack
"
,
package
)
remove_spack_package
(
dir_to_remove
/
"
spack
"
,
package
,
build_log_path
)
def
remove_spack_environment
(
spack_dir
,
environment_name
):
def
remove_spack_environment
(
spack_dir
,
environment_name
,
build_log_path
=
None
):
"""
Remove spack environment including packages exclusive to it.
First activate the environment,
...
...
@@ -1182,6 +1196,8 @@ def remove_spack_environment(spack_dir, environment_name):
A Path object representing the path to the spack directory.
environment_name : str
A string representing the name of the spack environment to remove.
build_log_path : pathlib.Path, optional
A Path object representing the path to where the logs will be teed
"""
logging
.
warning
(
f
"
Removing spack environment
{
environment_name
}
"
)
spack_env
=
spack_dir
/
"
share
"
/
"
spack
"
/
"
setup-env.sh
"
...
...
@@ -1195,10 +1211,15 @@ def remove_spack_environment(spack_dir, environment_name):
"
spack env deactivate
"
,
f
"
spack env remove -y
{
environment_name
}
"
,
]
run
(
"
&&
"
.
join
(
commands_to_execute
),
shell
=
True
,
check
=
True
)
build_log_path
=
build_log_path
or
"
/dev/null
"
run
(
"
&&
"
.
join
(
commands_to_execute
)
+
f
"
2>&1 |tee
{
build_log_path
}
"
,
shell
=
True
,
check
=
True
,
)
def
remove_spack_package
(
spack_dir
,
package
):
def
remove_spack_package
(
spack_dir
,
package
,
build_log_path
=
None
):
"""
Remove spack package.
Used to remove global packages.
...
...
@@ -1209,6 +1230,8 @@ def remove_spack_package(spack_dir, package):
A Path object representing the path to the spack directory.
package : str
A string representing the name of the spack package to remove.
build_log_path : pathlib.Path, optional
A Path object representing the path to where the logs will be teed
"""
logging
.
info
(
f
"
Removing spack package
{
package
}
"
)
...
...
@@ -1218,7 +1241,11 @@ def remove_spack_package(spack_dir, package):
f
"
.
{
spack_env
}
"
,
f
"
spack uninstall -y
{
package
}
"
,
]
run
(
"
&&
"
.
join
(
commands_to_execute
),
shell
=
True
,
check
=
True
)
run
(
"
&&
"
.
join
(
commands_to_execute
)
+
f
"
2>&1 |tee
{
build_log_path
}
"
,
shell
=
True
,
check
=
True
,
)
def
start_new_environment
(
release
,
from_release
,
target_dir
):
...
...
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