Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'comets.py' error #50

Open
2132030 opened this issue Feb 23, 2024 · 20 comments
Open

'comets.py' error #50

2132030 opened this issue Feb 23, 2024 · 20 comments

Comments

@2132030
Copy link

2132030 commented Feb 23, 2024

I get this error after 'sim.run()' code;

Running COMETS simulation ...

TypeError Traceback (most recent call last)
Cell In[73], line 1
----> 1 sim.run()

File ~/anaconda3/lib/python3.11/site-packages/cometspy/comets.py:362, in comets.run(self, delete_files)
359 c_package = self.working_dir + '.current_package' + to_append
360 c_script = self.working_dir + '.current_script' + to_append
--> 362 self.layout.write_necessary_files(self.working_dir, to_append)
364 # self.layout.write_layout(self.working_dir + '.current_layout')
365 self.parameters.write_params(c_global, c_package)

File ~/anaconda3/lib/python3.11/site-packages/cometspy/layout.py:636, in layout.write_necessary_files(self, working_dir, to_append)
634 self.__check_if_initial_pops_in_range()
635 self.write_layout(working_dir, to_append)
--> 636 self.write_model_files(working_dir)

File ~/anaconda3/lib/python3.11/site-packages/cometspy/layout.py:641, in layout.write_model_files(self, working_dir)
639 '''writes each model file'''
640 for m in self.models:
--> 641 m.write_comets_model(working_dir)

File ~/anaconda3/lib/python3.11/site-packages/cometspy/model.py:973, in model.write_comets_model(self, working_dir)
969 with open(path_to_write, 'a') as f:
971 f.write('SMATRIX ' + str(len(self.metabolites)) +
972 ' ' + str(len(self.reactions)) + '\n')
--> 973 smat.to_csv(f, mode='a', line_terminator = '\n', header=False, index=False)
974 f.write(r'//' + '\n')
976 f.write('BOUNDS ' +
977 str(self.default_bounds[0]) + ' ' +
978 str(self.default_bounds[1]) + '\n')

TypeError: NDFrame.to_csv() got an unexpected keyword argument 'line_terminator'

How can fix it? Can you help me?

@dukovski
Copy link
Contributor

I think I've seen similar problem before. Can you send me the script you are trying to run? Can you run the P1_test_tube_aerobic.ipynb at all? You can get is here: https://sites.google.com/view/comets-tutorial/home

@dukovski
Copy link
Contributor

I think I know what the bug is. "line_terminator" should be "lineterminator" in to_csv(f, mode='a', line_terminator = '\n', header=False, index=False) Let me change and test this.

@2132030
Copy link
Author

2132030 commented Feb 23, 2024

My script is below:

Archive.zip

I run 'P1_test_tube_aerobic.ipynb' but got same error.

@dukovski
Copy link
Contributor

OK, I think, in model.py all "line_terminator" need to be changed to "lineterminator". I will try that later today, but you may try to do it yourself and test it. Then you can actually push it here. I would appreciate that. :)

@2132030
Copy link
Author

2132030 commented Feb 23, 2024

I changed and test it and solved this, after then I got another error in my script:
(I am using macOS Sonoma 14.3.1, Gurobi 1100, Comets 2.10.5, java 21.0.2)

Running COMETS simulation ...
Error: COMETS simulation did not complete

 examine comets.run_output for the full java trace

 if we detect a common reason, it will be stated in the RuntimeError at the bottom

RuntimeError Traceback (most recent call last)
Cell In[39], line 1
----> 1 sim.run()

File ~/anaconda3/lib/python3.11/site-packages/cometspy/comets.py:400, in comets.run(self, delete_files)
397 self.run_errors = "STDERR empty."
399 # Raise RuntimeError if simulation had nonzero exit
--> 400 self.__analyze_run_output()
402 # '''----------- READ OUTPUT ---------------------------------------'''
403 # Read total biomass output
404 if self.parameters.all_params['writeTotalBiomassLog']:

File ~/anaconda3/lib/python3.11/site-packages/cometspy/comets.py:568, in comets.__analyze_run_output(self)
565 raise RuntimeError(f"COMETS simulation did not complete:\n {message}")
567 message = "undetected reason. examine comets.run_output for JAVA trace"
--> 568 raise RuntimeError(f"COMETS simulation did not complete:\n {message}")

RuntimeError: COMETS simulation did not complete:
undetected reason. examine comets.run_output for JAVA trace

Same error in your script:

Running COMETS simulation ...
Error: COMETS simulation did not complete

 examine comets.run_output for the full java trace

 if we detect a common reason, it will be stated in the RuntimeError at the bottom

RuntimeError Traceback (most recent call last)
Cell In[11], line 1
----> 1 experiment.run()

File ~/anaconda3/lib/python3.11/site-packages/cometspy/comets.py:400, in comets.run(self, delete_files)
397 self.run_errors = "STDERR empty."
399 # Raise RuntimeError if simulation had nonzero exit
--> 400 self.__analyze_run_output()
402 # '''----------- READ OUTPUT ---------------------------------------'''
403 # Read total biomass output
404 if self.parameters.all_params['writeTotalBiomassLog']:

File ~/anaconda3/lib/python3.11/site-packages/cometspy/comets.py:565, in comets.__analyze_run_output(self)
563 message += "if in Unix. In Windows, it suggests that something changed\n"
564 message += "with the dependencies installed alongside COMETS"
--> 565 raise RuntimeError(f"COMETS simulation did not complete:\n {message}")
567 message = "undetected reason. examine comets.run_output for JAVA trace"
568 raise RuntimeError(f"COMETS simulation did not complete:\n {message}")

RuntimeError: COMETS simulation did not complete:
JAVA could not find gurobi.
try the following:

import os
os.environ['GUROBI_COMETS_HOME']
if there is nothing there try setting that variable
to the location of gurobi.jar, for example:
os.environ['GUROBI_COMETS_HOME'] = '/opt/gurobi900/linux64'

@dukovski
Copy link
Contributor

This seems like you don't have gurobi installed properly. Are you doing this on Linux? If yes, make sure you have the GUROBI_COMETS_HOME defined in your .bashrc file.
My .bashrc file has these lines:

export COMETS_HOME=/projectnb/cometsfba/comets_2.11.1
export PATH=$PATH:$COMETS_HOME
export GUROBI_HOME=/share/pkg.7/gurobi/9.0.0/install/
export GUROBI_COMETS_HOME=/share/pkg.7/gurobi/9.0.0/install/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GUROBI_COMETS_HOME/lib/

export GUROBI_PATH=$GUROBI_HOME

Make sure you adapt them to your case, wherever you installed gurobi should replace my line /share/pkg.7/gurobi/9.0.0/install/
Is this enough info you need, or should I explain in more detail?

@2132030
Copy link
Author

2132030 commented Feb 23, 2024

No, I am using MacOS

@dukovski
Copy link
Contributor

On Mac you need this line:
export GUROBI_HOME=/Library/gurobi902/mac64/
Where instead of gurobi902 put gurobi, so replace the number to your version of gurobi.

@2132030
Copy link
Author

2132030 commented Feb 26, 2024

I tried this line in .bashrc file:
export GUROBI_HOME= /Library/gurobi1100/macos_universal2

but, I got this error again:

Running COMETS simulation ...
Error: COMETS simulation did not complete

 examine comets.run_output for the full java trace

 if we detect a common reason, it will be stated in the RuntimeError at the bottom

RuntimeError Traceback (most recent call last)
Cell In[19], line 1
----> 1 experiment.run()

File ~/anaconda3/lib/python3.11/site-packages/cometspy/comets.py:400, in comets.run(self, delete_files)
397 self.run_errors = "STDERR empty."
399 # Raise RuntimeError if simulation had nonzero exit
--> 400 self.__analyze_run_output()
402 # '''----------- READ OUTPUT ---------------------------------------'''
403 # Read total biomass output
404 if self.parameters.all_params['writeTotalBiomassLog']:

File ~/anaconda3/lib/python3.11/site-packages/cometspy/comets.py:565, in comets.__analyze_run_output(self)
563 message += "if in Unix. In Windows, it suggests that something changed\n"
564 message += "with the dependencies installed alongside COMETS"
--> 565 raise RuntimeError(f"COMETS simulation did not complete:\n {message}")
567 message = "undetected reason. examine comets.run_output for JAVA trace"
568 raise RuntimeError(f"COMETS simulation did not complete:\n {message}")

RuntimeError: COMETS simulation did not complete:
JAVA could not find gurobi.
try the following:

import os
os.environ['GUROBI_COMETS_HOME']
if there is nothing there try setting that variable
to the location of gurobi.jar, for example:
os.environ['GUROBI_COMETS_HOME'] = '/opt/gurobi900/linux64'

@jeremymchacon
Copy link
Collaborator

jeremymchacon commented Feb 26, 2024 via email

@dukovski
Copy link
Contributor

You need to make sure that you are running bash on your Mac. If you are running zsh, which is the default in latest Macs, you need to get that line in the .zshrc file. Check, do you have a .zshrc file?

@2132030
Copy link
Author

2132030 commented Mar 1, 2024

Yes, I have .zshrc file

@2132030
Copy link
Author

2132030 commented Mar 1, 2024

I tried in the .zshrc file but I got this error again :(

RuntimeError: COMETS simulation did not complete:
JAVA could not find gurobi.
try the following:

import os
os.environ['GUROBI_COMETS_HOME']
if there is nothing there try setting that variable
to the location of gurobi.jar, for example:
os.environ['GUROBI_COMETS_HOME'] = '/opt/gurobi900/linux64'

@dukovski
Copy link
Contributor

dukovski commented Mar 1, 2024

Can you show me a screenshot of your gurobi path and directory contents?
What do you get when you run:
import os
os.environ['GUROBI_COMETS_HOME']

@2132030
Copy link
Author

2132030 commented Mar 2, 2024

Screenshot 2024-03-02 at 16 29 48

I got when I run:
import os
os.environ['GUROBI_COMETS_HOME']
Screenshot 2024-03-02 at 16 31 30

@dukovski
Copy link
Contributor

dukovski commented Mar 2, 2024

aha, yes. The problem is that /lib at the end.
In your .bashrc and .zshrc files you should have
export GUROBI_COMETS_HOME=/Library/gurobi1100/macos_universal2/
wihtout the lib at the end.

@2132030
Copy link
Author

2132030 commented Mar 4, 2024

I tried that but got error again.

Screenshot 2024-03-04 at 11 09 47 Screenshot 2024-03-04 at 11 09 30

@jeremymchacon
Copy link
Collaborator

Good morning. Are you positive that gurobi is installed properly? Gurobi has a test case in their install instructions which is worth double-checking.

If it is installed properly, would you post a screenshot of your gurobi's path all the way to gurobi.jar? Thanks!

@dukovski
Copy link
Contributor

dukovski commented Mar 4, 2024

To follow up on Jeremy's comment,
the problem probably is those two lib in the path, you should have only one.

@2132030
Copy link
Author

2132030 commented Mar 5, 2024

Good morning. Are you positive that gurobi is installed properly? Gurobi has a test case in their install instructions which is worth double-checking.
If it is installed properly, would you post a screenshot of your gurobi's path all the way to gurobi.jar? Thanks!

Here,

Screenshot 2024-03-05 at 12 28 48 Screenshot 2024-03-05 at 13 29 35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants