Skip to content

Commit 1c79cdb

Browse files
author
bgoli
committed
added custom python bin argument to multicorefva
1 parent 510f84b commit 1c79cdb

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

cbmpy/CBConfig.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
__VERSION_MAJOR__ = 0
4141
__VERSION_MINOR__ = 8
42-
__VERSION_MICRO__ = 3
42+
__VERSION_MICRO__ = 4
4343

4444
__CBCONFIG__ = {
4545
'VERSION_MAJOR': __VERSION_MAJOR__,
@@ -62,6 +62,8 @@
6262
'ENVIRONMENT': '{} {} ({})'.format(
6363
platform.system(), platform.release(), platform.architecture()[0]
6464
),
65+
'MULTICORE_PYTHON_BIN_OVERRIDE': None,
66+
6567
}
6668

6769

cbmpy/CBMultiCore.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import cPickle as pickle
4343

4444
from . import CBSolver
45-
4645
from . import _multicorefva
4746

4847
MULTIFVAFILE = __file__.replace('CBMultiCore', '_multicorefva')
@@ -89,14 +88,23 @@ def runMultiCoreFVA(
8988
oldlpgen=False,
9089
markupmodel=True,
9190
procs=2,
91+
override_bin=None
9292
):
9393
"""
9494
Run a multicore FVA where:
9595
9696
- *fba* is an fba model instance
9797
- *procs* [default=2] number of processing threads (optimum seems to be about the number of physical cores)
98+
- *python_override_bin* allows customization of the Python bin used for the multicore process
9899
99100
"""
101+
# this is a hack to sort out the multicore import mess
102+
#if subprocess.call([PYTHON_BIN, '-c', 'import os', 'import cbmpy', 'os.sys.exit(-1)']):
103+
if override_bin is not None:
104+
PYTHON_BIN = override_bin
105+
__CBCONFIG__['MULTICORE_PYTHON_BIN_OVERRIDE'] = override_bin
106+
else:
107+
PYTHON_BIN = 'python'
100108

101109
# CBSolver.analyzeModel(fba, oldlpgen=False)
102110
# cplx_FluxVariabilityAnalysis(fba, selected_reactions=None, pre_opt=True, tol=None, objF2constr=True, rhs_sense='lower', optPercentage=100.0, work_dir=None, quiet=True, debug=False, oldlpgen=False, markupmodel=True)
@@ -116,7 +124,8 @@ def runMultiCoreFVA(
116124
fN = str(time.time()).split('.')[0]
117125
fba.serializeToDisk(fN, protocol=-1)
118126
fN = os.path.abspath(fN)
119-
subprocess.call(['python', MULTIFVAFILE, str(procs), fN])
127+
print(__CBCONFIG__['MULTICORE_PYTHON_BIN_OVERRIDE'])
128+
subprocess.call([PYTHON_BIN, MULTIFVAFILE, str(procs), fN])
120129
F = open(fN, 'rb')
121130
res = pickle.load(F)
122131
F.close()

0 commit comments

Comments
 (0)