These are chat archives for opencobra/cobrapy

2nd
Mar 2017
Moritz E. Beber
@Midnighter
Mar 02 2017 14:56
@pstjohn what is the current status: can constraints and variables added to the solver be context managed?
Peter St. John
@pstjohn
Mar 02 2017 17:29
So the thought was that if we used utility functions like add_to_solver, we can context manage things that way
But if we directly add to model.solver.interface, then we cant, since optlang isn’t aware of the cobra model. Is that what you mean?
Moritz E. Beber
@Midnighter
Mar 02 2017 17:32
I suppose, I'm still not fully aware of the context management capabilities.
@cdiener thank you for your comments!
Peter St. John
@pstjohn
Mar 02 2017 17:33
so when you put a model in a context with a call to with model:, it creates an empty stack of operations in model._context
then when the model leaves that indentation block, it essentially executes each operation on the stack in reverse order
so the trick is making sure that when a method modifies a model, it checks to see if there’s a context (with cobra.util.get_context), and if there is one, adds a function to the stack to undo whatever the function has changed
Peter St. John
@pstjohn
Mar 02 2017 18:01
Does anyone use Reaction.pop?
Christian Diener
@cdiener
Mar 02 2017 18:13
@Midnighter you're welcome! Sorry did not know as much about warnings in Python as I thought :smile:
Everything in util.solver should be context manged. So you can use those without worrying
@pstjohn No, don't even know what it does :sweat_smile:
Peter St. John
@pstjohn
Mar 02 2017 18:17
great, its gone then :smile: . Way too many ways of doing the same thing in reaction.py currently. I’m usually fine removing methods if we don’t cause tests to fail, but there was a test_reaction_pop or similar
Christian Diener
@cdiener
Mar 02 2017 18:19
If it wasn't used explicitly in the docs (not the API docs obviously :) ) it wont be missed I think :smile:
Peter St. John
@pstjohn
Mar 02 2017 19:08
Hopefully ready for review in #404. Waiting on CI, but the tests pass locally