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
b8350e0c
Commit
b8350e0c
authored
Jun 17, 2021
by
Damian Alvarez
Browse files
Options
Downloads
Patches
Plain Diff
To make the contact injection logic a bit more robust
parent
14a7ac22
No related branches found
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
+53
-15
53 additions, 15 deletions
Custom_Hooks/eb_hooks.py
with
53 additions
and
15 deletions
Custom_Hooks/eb_hooks.py
+
53
−
15
View file @
b8350e0c
import
grp
import
os
import
os
import
subprocess
from
easybuild.tools.run
import
run_cmd
from
easybuild.tools.run
import
run_cmd
from
easybuild.tools.config
import
build_option
from
easybuild.tools.config
import
build_option
...
@@ -80,6 +80,46 @@ def installation_vetoer(ec):
...
@@ -80,6 +80,46 @@ def installation_vetoer(ec):
print_msg
(
f
"
-
{
package
}
"
,
stderr
=
True
)
print_msg
(
f
"
-
{
package
}
"
,
stderr
=
True
)
exit
(
1
)
exit
(
1
)
def
get_user_info
():
# Query jutil to extract the contact information
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
)
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
):
def
parse_hook
(
ec
,
*
args
,
**
kwargs
):
"""
Custom parse hook to manage installations intended for JSC systems.
"""
"""
Custom parse hook to manage installations intended for JSC systems.
"""
...
@@ -166,13 +206,16 @@ family("mpi")
...
@@ -166,13 +206,16 @@ family("mpi")
# Check where installations are going to go and add appropriate site contact
# 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
# not sure of a fool-proof way to do this, let's just try a heuristic
site_contacts
=
None
site_contacts
=
None
if
"
stages
"
in
install_path
().
lower
():
# Non-user installation
users_groups
=
[
grp
.
getgrgid
(
g
).
gr_name
for
g
in
os
.
getgroups
()]
if
'
/p/software
'
in
install_path
().
lower
()
or
'
/gpfs/software
'
in
install_path
().
lower
():
if
any
(
group
in
users_groups
for
group
in
[
"
swmanage
"
,
"
software
"
]):
if
'
swmanage
'
in
os
.
getenv
(
'
USER
'
):
site_contacts
=
"
sc@fz-juelich.de
"
site_contacts
=
'
sc@fz-juelich.de
'
if
site_contacts
is
None
:
else
:
site_contacts
=
get_user_info
()
# Inject the user
# 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
# Tag the build as a user build
key
=
"
modluafooter
"
key
=
"
modluafooter
"
value
=
'
add_property(
"
build
"
,
"
user
"
)
'
value
=
'
add_property(
"
build
"
,
"
user
"
)
'
...
@@ -182,14 +225,9 @@ family("mpi")
...
@@ -182,14 +225,9 @@ family("mpi")
else
:
else
:
ec
[
key
]
=
value
ec
[
key
]
=
value
ec
.
log
.
info
(
"
[parse hook] Injecting user as Lmod build property
"
)
ec
.
log
.
info
(
"
[parse hook] Injecting user as Lmod build property
"
)
if
site_contacts
:
# Inject the user
key
=
"
site_contacts
"
site_contacts
=
get_user_info
()
value
=
site_contacts
ec
=
inject_site_contact
(
ec
,
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
)
# If we are parsing we are not searching, in this case if the easyconfig is
# 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)
# 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