Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
BOXMOX Python Package
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
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
MBEES
BOXMOX Python Package
Commits
24dd7e4d
Commit
24dd7e4d
authored
7 years ago
by
Christoph.Knote
Browse files
Options
Downloads
Patches
Plain Diff
More crazy shit.
parent
5040d715
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
boxmox/experiment.py
+34
-13
34 additions, 13 deletions
boxmox/experiment.py
with
34 additions
and
13 deletions
boxmox/experiment.py
+
34
−
13
View file @
24dd7e4d
...
...
@@ -4,6 +4,7 @@ if os.name == 'posix' and sys.version_info[0] < 3:
import
subprocess32
as
s
else
:
import
subprocess
as
s
import
threading
import
shutil
import
fnmatch
import
numpy
as
np
...
...
@@ -186,6 +187,27 @@ class Experiment:
return
mech
@property
def
running
(
self
):
'''
Check if simulation is running (if started with asynchronous=True).
'''
if
self
.
pid
is
None
:
return
False
else
:
return
self
.
pid
.
poll
()
is
None
def
_run
(
self
,
dumbOutput
=
False
):
try
:
self
.
pid
=
s
.
Popen
(
"
./
"
+
self
.
mechanism
+
"
.exe
"
,
stdout
=
s
.
PIPE
,
bufsize
=
1
)
self
.
pid
.
wait
()
self
.
_pp_run
(
dumbOutput
=
dumbOutput
)
except
Exception
as
e
:
failDir
=
self
.
path
+
"
_failed_at_{:s}
"
.
format
(
datetime
.
datetime
.
strftime
(
datetime
.
datetime
.
now
(),
"
%Y%m%d%H%M%S
"
))
self
.
archive
(
failDir
)
raise
Exception
(
'
BOXMOX integration failed: {:s}
'
.
format
(
str
(
e
)))
return
def
run
(
self
,
dumbOutput
=
False
,
asynchronous
=
False
):
'''
Run BOXMOX experiment
...
...
@@ -202,29 +224,28 @@ class Experiment:
pwd
=
os
.
getcwd
()
os
.
chdir
(
self
.
path
)
try
:
self
.
pid
=
s
.
Popen
(
"
./
"
+
self
.
mechanism
+
"
.exe
"
,
stdout
=
s
.
PIPE
,
bufsize
=
1
)
if
asynchronous
:
return
self
.
pid
.
wait
()
# wait for the subprocess to exit
if
asynchronous
:
thread
=
threading
.
Thread
(
target
=
self
.
_run
,
args
=
(
dumbOutput
,))
thread
.
start
()
os
.
chdir
(
pwd
)
return
else
:
self
.
_run
(
dumbOutput
=
dumbOutput
)
os
.
chdir
(
pwd
)
def
_pp_run
(
self
,
dumbOutput
=
False
):
try
:
self
.
lastLog
=
[]
for
line
in
iter
(
self
.
pid
.
stdout
.
readline
,
b
''
):
self
.
lastLog
.
append
(
line
.
replace
(
'
\n
'
,
''
))
except
Exception
as
e
:
os
.
chdir
(
pwd
)
failDir
=
self
.
path
+
"
_failed_at_{:s}
"
.
format
(
datetime
.
datetime
.
strftime
(
datetime
.
datetime
.
now
(),
"
%Y%m%d%H%M%S
"
))
self
.
archive
(
failDir
)
raise
Exception
(
'
BOXMOX integration failed: {:s}
'
.
format
(
str
(
e
)))
except
:
pass
if
dumbOutput
:
self
.
_populateDumbOutput
()
else
:
self
.
_populateOutput
()
os
.
chdir
(
pwd
)
outputTypes
=
{
'
Concentrations
'
:
{
'
ending
'
:
'
.conc
'
,
'
class
'
:
ConcentrationOutput
},
'
Rates
'
:
{
'
ending
'
:
'
.rates
'
,
'
class
'
:
RatesOutput
},
'
Jacobian
'
:
{
'
ending
'
:
'
.jacobian
'
,
'
class
'
:
JacobianOutput
},
...
...
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