Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
KM3BUU
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
simulation
KM3BUU
Commits
738ae7c0
Commit
738ae7c0
authored
3 years ago
by
Johannes Schumann
Browse files
Options
Downloads
Patches
Plain Diff
Add ctrl for local GiBUU installation w/o docker
parent
4bf3cd98
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!12
Restructure
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
km3buu/ctrl.py
+29
-20
29 additions, 20 deletions
km3buu/ctrl.py
with
29 additions
and
20 deletions
km3buu/ctrl.py
+
29
−
20
View file @
738ae7c0
...
...
@@ -13,6 +13,7 @@ __email__ = "jschumann@km3net.de"
__status__
=
"
Development
"
from
shutil
import
copy
import
subprocess
from
spython.main
import
Client
from
os.path
import
join
,
abspath
,
basename
,
isdir
,
isfile
from
tempfile
import
NamedTemporaryFile
,
TemporaryDirectory
...
...
@@ -47,7 +48,7 @@ $CONTAINER_GIBUU_EXEC < {1};
"""
def
run_jobcard
(
jobcard
,
outdir
):
def
run_jobcard
(
jobcard
,
outdir
,
container
=
False
):
"""
Method for run
...
...
@@ -58,6 +59,8 @@ def run_jobcard(jobcard, outdir):
of a jobcard object or a path to a jobcard
outdir: str
The path to the directory the output should be written to.
container: boolean
Call GiBUU inside container environment
"""
input_dir
=
TemporaryDirectory
()
outdir
=
abspath
(
outdir
)
...
...
@@ -80,23 +83,29 @@ def run_jobcard(jobcard, outdir):
jobcard
[
"
neutrino_induced
"
][
"
FileNameflux
"
]
=
tmp_fluxfile
with
open
(
jobcard_fpath
,
"
w
"
)
as
f
:
f
.
write
(
str
(
jobcard
))
log
.
info
(
"
Create temporary file for associated runscript
"
)
script_fpath
=
join
(
input_dir
.
name
,
"
run.sh
"
)
with
open
(
script_fpath
,
"
w
"
)
as
f
:
ctnt
=
GIBUU_SHELL
.
format
(
outdir
,
jobcard_fpath
)
f
.
write
(
ctnt
)
output
=
Client
.
execute
(
Config
().
gibuu_image_path
,
[
"
/bin/sh
"
,
script_fpath
],
bind
=
[
outdir
,
input_dir
.
name
],
return_result
=
True
,
)
with
open
(
join
(
outdir
,
jobcard
.
filename
),
"
w
"
)
as
f
:
f
.
write
(
str
(
jobcard
))
msg
=
output
[
"
message
"
]
if
isinstance
(
msg
,
str
):
log
.
info
(
"
GiBUU output:
\n
%s
"
%
msg
)
if
container
:
log
.
info
(
"
Create temporary file for associated runscript
"
)
script_fpath
=
join
(
input_dir
.
name
,
"
run.sh
"
)
with
open
(
script_fpath
,
"
w
"
)
as
f
:
ctnt
=
GIBUU_SHELL
.
format
(
outdir
,
jobcard_fpath
)
f
.
write
(
ctnt
)
output
=
Client
.
execute
(
Config
().
gibuu_image_path
,
[
"
/bin/sh
"
,
script_fpath
],
bind
=
[
outdir
,
input_dir
.
name
],
return_result
=
True
,
)
with
open
(
join
(
outdir
,
jobcard
.
filename
),
"
w
"
)
as
f
:
f
.
write
(
str
(
jobcard
))
msg
=
output
[
"
message
"
]
if
isinstance
(
msg
,
str
):
log
.
info
(
"
GiBUU output:
\n
%s
"
%
msg
)
else
:
log
.
info
(
"
GiBUU output:
\n
%s
"
%
msg
[
0
])
log
.
error
(
"
GiBUU stacktrace:
\n
%s
"
%
msg
[
1
])
return
output
[
"
return_code
"
]
else
:
log
.
info
(
"
GiBUU output:
\n
%s
"
%
msg
[
0
])
log
.
error
(
"
GiBUU stacktrace:
\n
%s
"
%
msg
[
1
])
return
output
[
"
return_code
"
]
p
=
subprocess
.
Popen
(
[
os
.
environ
[
"
CONTAINER_GIBUU_EXEC
"
],
"
<
"
,
jobcard_fpath
],
cwd
=
outdir
)
return
p
.
wait
()
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