Hello,

Previously I had problems using the external component for Abaqus which was solved by Herbt in this post. Unfortunately, I am here again because the fix does not work for my recent OpenMDAO 0.13 installs. Last week I installed OpenMDAO 0.10.3.2 and 0.13 on a Windows Server 2008 and on a Ubuntu 14.04. The installations were successful, but the external component seems to not work as it used to. I am forwarding the error I obtained at the windows machine, which was the same as for the Ubuntu machine.

I know most of your efforts are now towards OpenMDAO Alpha and that progress has been done for the external_component this week, but I would appreciate if somebody could help me with this.

P.S. I originally posted this a week ago as a comment, but now I find the answer relevant enough to have a post for itself.

Thanks,

Pedro

(openmdao-0.12.0) C:\Users\Administrator\Documents\abaqus-master>python DemoOpt.
py  > output.txt
Traceback (most recent call last):
  File "DemoOpt.py", line 77, in <module>
    opt_problem.run()
  File "C:\openmdao-0.12.0\lib\site-packages\openmdao.main-0.12.0-py2.7.egg\open
mdao\main\component.py", line 520, in run
    self.execute()
  File "C:\openmdao-0.12.0\lib\site-packages\openmdao.main-0.12.0-py2.7.egg\open
mdao\main\assembly.py", line 752, in execute
    self._system.run(self.itername, case_uuid=self._case_uuid)
  File "C:\openmdao-0.12.0\lib\site-packages\openmdao.main-0.12.0-py2.7.egg\open
mdao\main\systems.py", line 1021, in run
    self._comp.run(case_uuid=case_uuid)
  File "C:\openmdao-0.12.0\lib\site-packages\openmdao.main-0.12.0-py2.7.egg\open
mdao\main\driver.py", line 431, in run
    super(Driver, self).run(case_uuid)
  File "C:\openmdao-0.12.0\lib\site-packages\openmdao.main-0.12.0-py2.7.egg\open
mdao\main\component.py", line 520, in run
    self.execute()
  File "C:\openmdao-0.12.0\lib\site-packages\openmdao.lib-0.12.0-py2.7.egg\openm
dao\lib\drivers\genetic.py", line 160, in execute
    ga.evolve(freq_stats=0)
  File "C:\openmdao-0.12.0\lib\site-packages\pyevolve-0.6-py2.7.egg\pyevolve\GSi
mpleGA.py", line 749, in evolve
    self.internalPop.evaluate()
  File "C:\openmdao-0.12.0\lib\site-packages\pyevolve-0.6-py2.7.egg\pyevolve\GPo
pulation.py", line 382, in evaluate
    ind.evaluate(**args)
  File "C:\openmdao-0.12.0\lib\site-packages\pyevolve-0.6-py2.7.egg\pyevolve\Gen
omeBase.py", line 138, in evaluate
    for it in self.evaluator.applyFunctions(self, **args):
  File "C:\openmdao-0.12.0\lib\site-packages\pyevolve-0.6-py2.7.egg\pyevolve\Fun
ctionSlot.py", line 180, in applyFunctions
    yield f(obj, **args)
  File "C:\openmdao-0.12.0\lib\site-packages\openmdao.lib-0.12.0-py2.7.egg\openm
dao\lib\drivers\genetic.py", line 169, in _run_model
    self.run_iteration()
  File "C:\openmdao-0.12.0\lib\site-packages\openmdao.main-0.12.0-py2.7.egg\open
mdao\main\driver.py", line 497, in run_iteration
    wf.run()
  File "C:\openmdao-0.12.0\lib\site-packages\openmdao.main-0.12.0-py2.7.egg\open
mdao\main\workflow.py", line 188, in run
    self._system.run(iterbase=iterbase, case_uuid=case_uuid)
  File "C:\openmdao-0.12.0\lib\site-packages\openmdao.main-0.12.0-py2.7.egg\open
mdao\main\systems.py", line 1624, in run
    sub.run(iterbase, case_label=case_label, case_uuid=case_uuid)
  File "C:\openmdao-0.12.0\lib\site-packages\openmdao.main-0.12.0-py2.7.egg\open
mdao\main\systems.py", line 1021, in run
    self._comp.run(case_uuid=case_uuid)
  File "C:\openmdao-0.12.0\lib\site-packages\openmdao.main-0.12.0-py2.7.egg\open
mdao\main\component.py", line 520, in run
    self.execute()
  File "C:\Users\Administrator\Documents\abaqus-master\wrapabaqus_stent.py", lin
e 90, in execute
    super(WrapAbaqus_stent, self).execute()
  File "C:\openmdao-0.12.0\lib\site-packages\openmdao.lib-0.12.0-py2.7.egg\openm
dao\lib\components\external_code.py", line 175, in execute
    % (return_code, err_fragment), RuntimeError)
  File "C:\openmdao-0.12.0\lib\site-packages\openmdao.main-0.12.0-py2.7.egg\open
mdao\main\container.py", line 1353, in raise_exception
    raise exception_class(full_msg)
RuntimeError: comp (1-comp): return_code = 1
Error Output:
The system cannot find the path specified.

asked 22 Jul '15, 15:46

Leal26's gravatar image

Leal26
124

converted to question 31 Jul '15, 15:43


Pedro,

Since we aren't really updating OpenMDAO 0.X, let's just try a small fix you can make yourself. In openmdao.lib/src/openmdao/lib/components/external_code.py, update the method _execute_local, so that the first few lines look like this. I added an if statement.

    def _execute_local(self):
    """ Run command. """
    self._logger.info('executing %s...', self.command)
    start_time = time.time()

    # check to make sure command exists
    if isinstance(self.command, basestring):
        program_to_execute = self.command
    else:
        if self.command[:2] == ['cmd.exe', '/c' ]: # This is new
            program_to_execute = self.command[2]
        else:                
            program_to_execute = self.command[0]
    command_full_path = find_executable( program_to_execute )

We also need to fix this up in the Alpha !

link

answered 17 Aug '15, 09:40

Herb%20Schilling's gravatar image

Herb Schilling
126126

Pedro,

Can you send us your code? It's hard to tell what is wrong just from the error messages.

Thanks!

link

answered 07 Aug '15, 10:47

Herb%20Schilling's gravatar image

Herb Schilling
126126

email to support [at symbol] openmdao [dot] org and I'll make sure it gets to Herb.

(07 Aug '15, 14:52) kmarstel ♦♦ kmarstel's gravatar image

Hello, I have sent the envdump, test output and the files to the specified e-mail. However, I would also like to highlight a problem I had when I used the same Python for OpenMDAO Alpha and 0.0.13 (or previous versions). After installing the Alpha version, every time I used the older version of OpenMDAO, I got an error (missing library "log"). Once I removed OpenMDAO from Python's site-package directory, all went back to normal.

Thank you very much for your help!

(11 Aug '15, 18:17) Leal26 Leal26's gravatar image

Hello Herb,

The modification you did almost did the trick. To actually make it work, I had to change the last line to:

command_full_path = program_to_execute

Since distutils.spawn.find_executable() is to find .exe files, it will always return None for .bat files, such as mine. If I just remove this function everything works. Maybe a better solution would be to declare the command_full_path variable inside the if-else statements:

# check to make sure command exists
if isinstance(self.command, basestring):
    program_to_execute = self.command
    command_full_path = find_executable( program_to_execute )
else:
    if self.command[:2] == ['cmd.exe', '/c' ]: # This is new
        program_to_execute = self.command[2]
        command_full_path = program_to_execute
    else:                
        program_to_execute = self.command[0]
        command_full_path = find_executable( program_to_execute )

P.s.: Sorry for the late response, did not have enough time last week

link

answered 24 Aug '15, 16:02

Leal26's gravatar image

Leal26
124

Pedro,

Glad you got it to work !

But we really need to use find_executable, or something like it in case the user does not give an absolute path to the program to execute.

I discovered that numpy, which obviously is already a dependency for OpenMDAO, has a find_executable that is way better than the one that comes with disutils! It's in numpy.distutils.exec_command

I think I will use that in the alpha version of ExternalCode.

Our thought was also that the user shouldn't have to add the [ 'cmd.exe', '/c' ] in the first part of their command on Windows. We would put that in there for them. So even on Windows, the user just gives the command the really want to execute.

link

answered 24 Aug '15, 20:55

Herb%20Schilling's gravatar image

Herb Schilling
126126

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×7

Asked: 22 Jul '15, 15:46

Seen: 1,708 times

Last updated: 24 Aug '15, 20:55

powered by OSQA