Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
easybuild-repository-public-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DEEP-SEA
easybuild-repository-public-release
Commits
74b67df9
Commit
74b67df9
authored
Jun 17, 2021
by
Damian Alvarez
Browse files
Options
Downloads
Plain Diff
Merge branch 'site_contacts_hook' into '2020'
Site contacts hook See merge request hps-public/easybuild-repository!630
parents
f8f7fe2c
a58cb3a8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Custom_Hooks/eb_hooks.py
+57
-16
57 additions, 16 deletions
Custom_Hooks/eb_hooks.py
with
57 additions
and
16 deletions
Custom_Hooks/eb_hooks.py
+
57
−
16
View file @
74b67df9
import
grp
import
os
import
subprocess
from
easybuild.tools.run
import
run_cmd
from
easybuild.tools.config
import
build_option
...
...
@@ -28,7 +28,7 @@ SUPPORTED_MPI_TOOLCHAIN_FAMILIES = [
"
iompi
"
,
"
gpsmpi
"
,
"
gompi
"
,
"
npsmpi
"
,
"
npsmpi
c
"
,
"
nompi
"
,
"
gmvapich2c
"
,
"
pmvapich2c
"
,
...
...
@@ -80,6 +80,49 @@ def installation_vetoer(ec):
print_msg
(
f
"
-
{
package
}
"
,
stderr
=
True
)
exit
(
1
)
def
get_user_info
():
# Query jutil to extract the contact information
if
os
.
getenv
(
'
CI
'
)
is
None
:
jutil
=
subprocess
.
Popen
([
os
.
getenv
(
'
JUMO_USRCMD_EXEC
'
),
'
person
'
,
'
show
'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
,
stderr
=
jutil
.
communicate
()
if
not
stderr
:
return
stdout
.
decode
(
'
utf-8
'
).
splitlines
()[
-
1
]
else
:
print_warning
(
f
'
Could not query jutil:
{
stderr
}
'
)
exit
(
1
)
else
:
return
'
CI user
'
def
inject_site_contact
(
ec
,
site_contacts
):
key
=
"
site_contacts
"
value
=
site_contacts
ec_dict
=
ec
.
asdict
()
if
key
in
ec_dict
:
if
ec_dict
[
key
]
is
not
None
:
# Check current values if it is a list
if
isinstance
(
ec_dict
[
key
],
list
):
for
contact
in
ec_dict
[
key
]:
# Already in contact
if
site_contacts
in
contact
:
break
# We looped to the end and did not find the contact in this list
else
:
# Do not add the generic one if there are other specific contacts
if
'
sc@fz-juelich.de
'
not
in
site_contacts
or
len
(
ec_dict
[
key
])
==
0
:
ec
.
log
.
info
(
"
[parse hook] Injecting contact %s
"
,
value
)
ec
[
key
].
append
(
site_contacts
)
# Check current values if it is a string
else
:
# Do not add the generic one if there are other specific contacts
if
site_contacts
not
in
ec_dict
[
key
]
and
'
sc@fz-juelich.de
'
not
in
site_contacts
:
ec
.
log
.
info
(
"
[parse hook] Injecting contact %s
"
,
value
)
ec
[
key
]
=
[
ec_dict
[
key
],
site_contacts
]
else
:
ec
.
log
.
info
(
"
[parse hook] Injecting contact %s
"
,
value
)
ec
[
key
]
=
value
return
ec
def
parse_hook
(
ec
,
*
args
,
**
kwargs
):
"""
Custom parse hook to manage installations intended for JSC systems.
"""
...
...
@@ -166,13 +209,16 @@ family("mpi")
# Check where installations are going to go and add appropriate site contact
# not sure of a fool-proof way to do this, let's just try a heuristic
site_contacts
=
None
if
"
stages
"
in
install_path
().
lower
():
users_groups
=
[
grp
.
getgrgid
(
g
).
gr_name
for
g
in
os
.
getgroups
()]
if
any
(
group
in
users_groups
for
group
in
[
"
swmanage
"
,
"
software
"
]):
site_contacts
=
"
sc@fz-juelich.de
"
if
site_contacts
is
None
:
# Non-user installation
if
'
/p/software
'
in
install_path
().
lower
()
or
'
/gpfs/software
'
in
install_path
().
lower
():
if
'
swmanage
'
in
os
.
getenv
(
'
USER
'
):
site_contacts
=
'
sc@fz-juelich.de
'
else
:
site_contacts
=
get_user_info
()
# Inject the user
site_contacts
=
os
.
getenv
(
"
USER
"
)
ec
=
inject_site_contact
(
ec
,
site_contacts
)
# User installation
else
:
# Tag the build as a user build
key
=
"
modluafooter
"
value
=
'
add_property(
"
build
"
,
"
user
"
)
'
...
...
@@ -182,14 +228,9 @@ family("mpi")
else
:
ec
[
key
]
=
value
ec
.
log
.
info
(
"
[parse hook] Injecting user as Lmod build property
"
)
if
site_contacts
:
key
=
"
site_contacts
"
value
=
site_contacts
if
key
in
ec_dict
:
if
ec_dict
[
key
]
is
not
None
and
value
not
in
ec_dict
[
key
]:
value
=
"
,
"
.
join
([
ec_dict
[
key
],
value
])
ec
[
key
]
=
value
ec
.
log
.
info
(
"
[parse hook] Injecting contact %s
"
,
value
)
# Inject the user
site_contacts
=
get_user_info
()
ec
=
inject_site_contact
(
ec
,
site_contacts
)
# If we are parsing we are not searching, in this case if the easyconfig is
# located in the search path, warn that it's dependencies will (most probably)
...
...
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
sign in
to comment