Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
HTConfig
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
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
EKPCondor
HTConfig
Commits
16edb6ad
Commit
16edb6ad
authored
9 months ago
by
Sebastian Brommer
Browse files
Options
Downloads
Patches
Plain Diff
fix domain parsing
parent
4f6ff648
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/prepare_singularity.py
+20
-30
20 additions, 30 deletions
scripts/prepare_singularity.py
with
20 additions
and
30 deletions
scripts/prepare_singularity.py
+
20
−
30
View file @
16edb6ad
...
...
@@ -5,10 +5,6 @@ import sys
def
get_job_ad
():
instream
=
sys
.
stdin
# # dump the input stream to a file for debugging
# with open("/scratch/job_ad.txt", "w") as f:
# for line in instream:
# f.write(line)
job_ad
=
{}
# format of the job ad is key = value
for
line
in
instream
:
...
...
@@ -26,7 +22,7 @@ def sanitize_image_name(image):
if
image
.
startswith
(
"
docker://
"
):
image
=
image
.
replace
(
"
docker://
"
,
""
)
# try to identify the domain if there is any
if
image
.
count
(
"
/
"
)
>
2
:
if
image
.
count
(
"
/
"
)
>
=
2
:
domain
=
image
.
split
(
"
/
"
)[
0
]
image
=
image
.
replace
(
domain
+
"
/
"
,
""
)
else
:
...
...
@@ -55,6 +51,8 @@ def check_image_availability(image_path):
def
main
():
job_ad
=
get_job_ad
()
status_message
=
""
condor_arg
=
""
job_ad
[
"
WantDocker
"
]
=
"
false
"
# write job_ad to a file for debugging
dumpfilepath
=
"
/scratch/job_ad_initial.json
"
with
open
(
dumpfilepath
,
"
w
"
)
as
f
:
...
...
@@ -64,41 +62,33 @@ def main():
docker_image
=
job_ad
.
get
(
"
DockerImage
"
)
if
not
container_image
and
not
docker_image
:
status_message
=
"
No container image provided, using default container: /cvmfs/unpacked.cern.ch/registry.hub.docker.com/mschnepf/slc7-condocker:latest
"
# return the default container image to stdout
print
(
'
ContainerImage =
"
/cvmfs/unpacked.cern.ch/registry.hub.docker.com/mschnepf/slc7-condocker:latest
"'
,
file
=
sys
.
stdout
,
job_ad
[
"
status_message
"
]
=
(
"
No container image provided, using default container: /cvmfs/unpacked.cern.ch/registry.hub.docker.com/mschnepf/slc7-condocker:latest
"
)
print
(
"
WantDocker = false
"
,
file
=
sys
.
stdout
)
# return the default container image to
stdout
job_ad
[
"
ContainerImage
"
]
=
(
"
/cvmfs/unpacked.cern.ch/registry.hub.docker.com/mschnepf/slc7-condocker:latest
"
)
job_ad
[
"
WantDocker
"
]
=
"
false
"
dumpfilepath
=
"
/scratch/job_ad_updated.json
"
with
open
(
dumpfilepath
,
"
w
"
)
as
f
:
for
key
,
value
in
job_ad
.
items
():
f
.
write
(
f
"
{
key
}
=
{
value
}
\n
"
)
return
# pick the args parameter that is not None
image
=
container_image
or
docker_image
condor_arg
=
""
domain
,
imagename
=
sanitize_image_name
(
image
)
image_path
=
construct_image_path
(
domain
,
imagename
)
if
check_image_availability
(
image_path
):
condor_arg
=
image_path
else
:
condor_arg
=
f
"
docker://
{
domain
}
/
{
imagename
}
"
print
(
f
'
ContainerImage =
"
{
condor_arg
}
"'
,
file
=
sys
.
stdout
)
print
(
"
WantDocker = false
"
,
file
=
sys
.
stdout
)
# pick the args parameter that is not None
image
=
container_image
or
docker_image
domain
,
imagename
=
sanitize_image_name
(
image
)
image_path
=
construct_image_path
(
domain
,
imagename
)
if
check_image_availability
(
image_path
):
condor_arg
=
image_path
else
:
condor_arg
=
f
"
docker://
{
domain
}
/
{
imagename
}
"
job_ad
[
"
ContainerImage
"
]
=
condor_arg
job_ad
[
"
status_message
"
]
=
f
"
Container image set to
{
image_path
}
via hook
"
# return the results via stdout
print
(
f
'
ContainerImage =
"
{
job_ad
[
"
ContainerImage
"
]
}
"'
,
file
=
sys
.
stdout
)
print
(
f
"
WantDocker =
{
job_ad
[
'
WantDocker
'
]
}
"
,
file
=
sys
.
stdout
)
print
(
f
'
HookStatusMessage =
"
{
job_ad
[
"
status_message
"
]
}
"'
,
file
=
sys
.
stdout
)
# dump the updated job ad to a file for debugging
job_ad
[
"
ContainerImage
"
]
=
condor_arg
job_ad
[
"
WantDocker
"
]
=
"
false
"
dumpfilepath
=
"
/scratch/job_ad_updated.json
"
with
open
(
dumpfilepath
,
"
w
"
)
as
f
:
for
key
,
value
in
job_ad
.
items
():
f
.
write
(
f
"
{
key
}
=
{
value
}
\n
"
)
status_message
=
f
"
Container image
{
image_path
}
is available, using it
"
print
(
f
"
HookStatusMessage =
{
status_message
}
"
,
file
=
sys
.
stdout
)
...
...
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