Skip to content

Commit 7ac50db

Browse files
authored
Merge pull request #57 from cropsinsilico/debug
Matlab env variable issue on some OS
2 parents 7ad9ca6 + 169d6a8 commit 7ac50db

4 files changed

Lines changed: 25 additions & 16 deletions

File tree

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ jobs:
198198
- $HOME/Library/Caches/pip
199199
- $HOME/Library/Caches/Homebrew
200200
- $HOME/R/Library
201-
env: YGG_PYTHON=3.6 R_LIBS_USER=$HOME/R/Library YGG_TEST_FLAGS="tests/test_tools.py --test-suite=types --test-suite=timing --languages R c" INSTALLR=0
201+
env: YGG_PYTHON=3.6 R_LIBS_USER=$HOME/R/Library YGG_TEST_FLAGS="tests/test_tools.py --test-suite=types --languages R c" INSTALLR=0
202202
- os: osx
203203
python: 3.7
204204
language: generic # https://github.com/travis-ci/travis-ci/issues/2312
@@ -207,7 +207,7 @@ jobs:
207207
directories:
208208
- $HOME/Library/Caches/pip
209209
- $HOME/Library/Caches/Homebrew
210-
env: YGG_CONDA=3.7 YGG_TEST_FLAGS="serialize --test-suite=examples_part1 communication/tests/test_IPCComm.py communication/tests/test_RMQAsyncComm.py" INSTALLZMQ=0
210+
env: YGG_CONDA=3.7 YGG_TEST_FLAGS="serialize --test-suite=examples_part1 communication/tests/test_IPCComm.py communication/tests/test_RMQAsyncComm.py --test-suite=timing" INSTALLZMQ=0
211211
script:
212212
- yggconfig --remove-file
213213
- yggtest --ci tests/test_config.py $YGG_TEST_FLAGS

recipe/meta.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% set name = "yggdrasil" %}
2-
{% set version = "0.10.0" %}
2+
{% set version = "1.1.1" %}
33

44
package:
55
name: {{ name|lower }}
@@ -9,9 +9,9 @@ source:
99
path: ../
1010

1111
build:
12-
number: 1
12+
number: 0
1313
script: "{{ PYTHON }} -m pip install . --no-deps --ignore-installed --no-cache-dir -vvv "
14-
skip: true # [win and vc<14]
14+
skip: true # [(win and vc<14) or py<35]
1515
entry_points:
1616
- ygginfo = yggdrasil.command_line:ygginfo
1717
- yggrun = yggdrasil.command_line:yggrun
@@ -33,9 +33,6 @@ build:
3333
- ygginstall = yggdrasil.command_line:ygginstall
3434

3535
requirements:
36-
# build:
37-
# - {{ compiler('c') }}
38-
# - {{ compiler('cxx') }}
3936
host:
4037
- czmq
4138
- pip
@@ -46,9 +43,10 @@ requirements:
4643
- cmake
4744
- czmq
4845
- flaky
46+
- git
4947
- GitPython
5048
- jsonschema
51-
- matplotlib
49+
- matplotlib-base
5250
- numpy
5351
- pandas
5452
- pyperf

yggdrasil/drivers/MatlabModelDriver.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,22 +562,32 @@ def parse_arguments(self, args):
562562
self.wrapper_products.append(self.model_wrapper)
563563

564564
@classmethod
565-
def write_error_wrapper(cls, fname, try_lines, matlab_engine=None):
565+
def write_error_wrapper(cls, fname, try_lines, env=None,
566+
matlab_engine=None):
566567
r"""Write a wrapper for the model that encloses it in a try except so
567568
that the error can be propagated appropriately.
568569
569570
Args:
570571
fname (str): File where the wrapper should be written.
571572
try_lines (list): List of lines to go in the try block.
572573
model_file (str): Path to model that should be wrapped.
574+
env (dict, optional): Dictionary of environment variables
575+
that should be set before calling the model. Defaults
576+
to None and is ignored.
573577
matlab_engine (MatlabEngine, optional): Matlab engine that will be
574-
used to call the wrapper. If not provided, it is assumed the
575-
error will be called using the Matlab interpreter on the command
576-
line. Defautls to None.
578+
used to call the wrapper. If not provided, it is assumed the
579+
error will be called using the Matlab interpreter on the command
580+
line. Defautls to None.
577581
578582
Raises:
579583
580584
"""
585+
# Add environment variables explicitly
586+
lines = []
587+
if env is not None:
588+
for k, v in env.items():
589+
lines.append('setenv(\'%s\', \'%s\')' % (
590+
k, v.encode("unicode_escape").decode('utf-8')))
581591
# Create lines based on use of engine or not
582592
if matlab_engine is not None:
583593
catch_block = ["error(e.message);"]
@@ -587,7 +597,7 @@ def write_error_wrapper(cls, fname, try_lines, matlab_engine=None):
587597
# "disp(e.identifier);",
588598
# "disp(e.stack);",
589599
# "exit(0);"]
590-
lines = cls.write_try_except(try_lines, catch_block)
600+
lines += cls.write_try_except(try_lines, catch_block)
591601
if matlab_engine is None:
592602
lines.append("exit(0);")
593603
# Write lines
@@ -615,7 +625,7 @@ def run_code(cls, lines, **kwargs):
615625
kwargs.setdefault('process_kwargs', {})
616626
if not kwargs['process_kwargs'].get('dont_wrap_error', False):
617627
lines = cls.write_error_wrapper(
618-
None, lines,
628+
None, lines, env=kwargs.get('env', None),
619629
matlab_engine=kwargs.get('matlab_engine', None))
620630
kwargs['process_kwargs']['dont_wrap_error'] = True
621631
return super(MatlabModelDriver, cls).run_code(lines, **kwargs)
@@ -677,6 +687,7 @@ def run_executable(cls, args, dont_wrap_error=False, fname_wrapper=None,
677687
if working_dir is not None:
678688
fname_wrapper = os.path.join(working_dir, fname_wrapper)
679689
cls.write_error_wrapper(fname_wrapper, try_block,
690+
env=kwargs.get('env', None),
680691
matlab_engine=matlab_engine)
681692
assert(os.path.isfile(fname_wrapper))
682693
args = [os.path.splitext(os.path.basename(fname_wrapper))[0]]

yggdrasil/examples/gs_lesson3/src/gs_lesson3.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
% Initialize input/output channels
1+
% Initialize input/output channels
22
in_channel = YggInterface('YggInput', 'input');
33
out_channel = YggInterface('YggOutput', 'output');
44

0 commit comments

Comments
 (0)