Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eic_container
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
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
containers
eic_container
Commits
da43431f
Commit
da43431f
authored
2 years ago
by
Wouter Deconinck
Browse files
Options
Downloads
Patches
Plain Diff
fix: parallelize the single-thread checkGeometry
parent
c5d0c847
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!521
fix: parallelize the single-thread checkGeometry
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
containers/jug/setup_detectors.py
+31
-11
31 additions, 11 deletions
containers/jug/setup_detectors.py
with
31 additions
and
11 deletions
containers/jug/setup_detectors.py
+
31
−
11
View file @
da43431f
#!/usr/bin/env python3
#!/usr/bin/env python3
import
os
import
os
import
sys
import
yaml
import
yaml
import
argparse
import
argparse
import
subprocess
from
datetime
import
datetime
DETECTOR_REPO_GROUP
=
'
https://github.com/eic
'
DETECTOR_REPO_GROUP
=
'
https://github.com/eic
'
DETECTOR_BEAMLINE_ENV
=
'''
DETECTOR_BEAMLINE_ENV
=
'''
...
@@ -97,6 +100,7 @@ if __name__ == '__main__':
...
@@ -97,6 +100,7 @@ if __name__ == '__main__':
default_found
=
True
default_found
=
True
print
(
'
- {}: {}{}
'
.
format
(
det
,
branch
,
default_str
))
print
(
'
- {}: {}{}
'
.
format
(
det
,
branch
,
default_str
))
print
(
'
--> Building and installing detector/ip libraries
'
)
print
(
'
--> Building and installing detector/ip libraries
'
)
process_list
=
[]
for
det
in
detectors
:
for
det
in
detectors
:
if
not
args
.
nightly
and
'
nightly
'
in
detectors
[
det
]:
if
not
args
.
nightly
and
'
nightly
'
in
detectors
[
det
]:
del
detectors
[
det
][
'
nightly
'
]
del
detectors
[
det
][
'
nightly
'
]
...
@@ -128,7 +132,7 @@ if __name__ == '__main__':
...
@@ -128,7 +132,7 @@ if __name__ == '__main__':
'
&&
'
,
'
&&
'
,
'
cmake --build /tmp/build -j$(($(($(nproc)/4))+1)) -- install
'
]
'
cmake --build /tmp/build -j$(($(($(nproc)/4))+1)) -- install
'
]
print
(
'
'
.
join
(
cmd
))
print
(
'
'
.
join
(
cmd
))
os
.
system
(
'
'
.
join
(
cmd
))
subprocess
.
check_call
(
'
'
.
join
(
cmd
)
,
shell
=
True
)
## write version info to jug_info if available
## write version info to jug_info if available
if
os
.
path
.
exists
(
'
/etc/jug_info
'
):
if
os
.
path
.
exists
(
'
/etc/jug_info
'
):
cmd
=
[
'
cd /tmp/det
'
,
cmd
=
[
'
cd /tmp/det
'
,
...
@@ -141,17 +145,17 @@ if __name__ == '__main__':
...
@@ -141,17 +145,17 @@ if __name__ == '__main__':
'
&&
'
,
'
&&
'
,
'
cd -
'
]
'
cd -
'
]
print
(
'
'
.
join
(
cmd
))
print
(
'
'
.
join
(
cmd
))
os
.
system
(
'
'
.
join
(
cmd
))
subprocess
.
check_call
(
'
'
.
join
(
cmd
)
,
shell
=
True
)
## also copy over IP configuration to the detector
## also copy over IP configuration to the detector
if
'
ip
'
in
cfg
and
os
.
path
.
exists
(
'
/tmp/det/{ip}
'
.
format
(
ip
=
cfg
[
'
ip
'
][
'
config
'
])):
if
'
ip
'
in
cfg
and
os
.
path
.
exists
(
'
/tmp/det/{ip}
'
.
format
(
ip
=
cfg
[
'
ip
'
][
'
config
'
])):
cmd
=
'
cp -r /tmp/det/{ip} {data_dir}
'
.
format
(
cmd
=
'
cp -r /tmp/det/{ip} {data_dir}
'
.
format
(
ip
=
ip
[
'
config
'
],
data_dir
=
data_dir
)
ip
=
ip
[
'
config
'
],
data_dir
=
data_dir
)
print
(
cmd
)
print
(
cmd
)
os
.
system
(
cmd
)
subprocess
.
check_call
(
cmd
,
shell
=
True
)
## cleanup
## cleanup
cmd
=
'
rm -rf /tmp/det /tmp/build
'
cmd
=
'
rm -rf /tmp/det /tmp/build
'
print
(
cmd
)
print
(
cmd
)
os
.
system
(
cmd
)
subprocess
.
check_call
(
cmd
,
shell
=
True
)
# be resilient against failures
# be resilient against failures
if
os
.
path
.
exists
(
prefix
):
if
os
.
path
.
exists
(
prefix
):
## create a shortcut for the prefix if desired
## create a shortcut for the prefix if desired
...
@@ -160,7 +164,7 @@ if __name__ == '__main__':
...
@@ -160,7 +164,7 @@ if __name__ == '__main__':
prefix
=
prefix
,
prefix
=
prefix
,
shortcut
=
'
{}/{}-{}
'
.
format
(
args
.
prefix
,
det
,
branch
))
shortcut
=
'
{}/{}-{}
'
.
format
(
args
.
prefix
,
det
,
branch
))
print
(
cmd
)
print
(
cmd
)
os
.
system
(
cmd
)
subprocess
.
check_call
(
cmd
,
shell
=
True
)
## write an environment file for this detector
## write an environment file for this detector
with
open
(
'
{prefix}/setup.sh
'
.
format
(
prefix
=
prefix
),
'
w
'
)
as
f
:
with
open
(
'
{prefix}/setup.sh
'
.
format
(
prefix
=
prefix
),
'
w
'
)
as
f
:
if
'
ip
'
in
cfg
:
if
'
ip
'
in
cfg
:
...
@@ -183,15 +187,31 @@ if __name__ == '__main__':
...
@@ -183,15 +187,31 @@ if __name__ == '__main__':
file
=
f
)
file
=
f
)
## run once inside global prefix to initialize artifacts in /opt/detectors
## run once inside global prefix to initialize artifacts in /opt/detectors
os
.
environ
[
'
DETECTOR_PATH
'
]
=
args
.
prefix
os
.
environ
[
'
DETECTOR_PATH
'
]
=
args
.
prefix
cmd
=
f
'
bash -c
\'
cd
{
args
.
prefix
}
&& source
{
prefix
}
/setup.sh && checkGeometry -c
{
prefix
}
/share/
{
det
}
/
{
det
}
.xml
\'
'
cmd
=
f
'
cd
{
args
.
prefix
}
&& source
{
prefix
}
/setup.sh && checkGeometry -c
{
prefix
}
/share/
{
det
}
/
{
det
}
.xml
'
print
(
cmd
)
print
(
cmd
)
os
.
system
(
cmd
)
process_list
.
append
(
subprocess
.
Popen
(
cmd
,
shell
=
True
,
executable
=
'
/bin/bash
'
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
)
## run once inside specific prefix to initialize artifacts in $DETECTOR_PATH
## run once inside specific prefix to initialize artifacts in $DETECTOR_PATH
os
.
environ
[
'
DETECTOR_PATH
'
]
=
args
.
prefix
os
.
environ
[
'
DETECTOR_PATH
'
]
=
args
.
prefix
cmd
=
f
'
bash -c
\'
cd
{
prefix
}
/share/
{
det
}
&& source
{
prefix
}
/setup.sh && checkGeometry -c
{
prefix
}
/share/
{
det
}
/
{
det
}
.xml
\'
'
cmd
=
f
'
cd
{
prefix
}
/share/
{
det
}
&& source
{
prefix
}
/setup.sh && checkGeometry -c
{
prefix
}
/share/
{
det
}
/
{
det
}
.xml
'
print
(
cmd
)
print
(
cmd
)
os
.
system
(
cmd
)
process_list
.
append
(
subprocess
.
Popen
(
cmd
,
shell
=
True
,
executable
=
'
/bin/bash
'
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
))
while
len
(
process_list
)
>
0
:
now
=
datetime
.
now
()
current_time
=
now
.
strftime
(
"
%H:%M:%S
"
)
print
(
"
{} processes running... ({})
"
.
format
(
len
(
process_list
),
current_time
))
(
out
,
err
)
=
process_list
[
-
1
].
communicate
()
if
process_list
[
-
1
].
wait
()
!=
0
:
print
(
process_list
[
-
1
].
args
)
if
out
is
not
None
:
print
(
"
stdout:
"
)
print
(
out
.
decode
())
if
err
is
not
None
:
print
(
"
stderr:
"
)
print
(
err
.
decode
())
sys
.
exit
(
1
)
process_list
.
pop
()
if
not
default_found
and
not
args
.
nightly
:
if
not
default_found
and
not
args
.
nightly
:
# Skip symlinking if no defaults present and its not a nightly build
# Skip symlinking if no defaults present and its not a nightly build
pass
pass
...
@@ -204,6 +224,6 @@ if __name__ == '__main__':
...
@@ -204,6 +224,6 @@ if __name__ == '__main__':
'
&&
'
,
'
&&
'
,
'
ln -sf {full_prefix}/setup.sh {short_prefix}
'
]
'
ln -sf {full_prefix}/setup.sh {short_prefix}
'
]
print
(
'
'
.
join
(
cmd
))
print
(
'
'
.
join
(
cmd
))
os
.
system
(
'
'
.
join
(
cmd
).
format
(
full_prefix
=
full_prefix
,
short_prefix
=
args
.
prefix
))
subprocess
.
check_call
(
'
'
.
join
(
cmd
).
format
(
full_prefix
=
full_prefix
,
short_prefix
=
args
.
prefix
)
,
shell
=
True
)
print
(
'
All done!
'
)
print
(
'
All done!
'
)
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