Remove Optlang object from COBRApy model

29 views
Skip to first unread message

Nicholas Y

unread,
Nov 22, 2025, 2:31:10 PMNov 22
to cobra pie
Hi,

My name is Nick, and I have a question regarding the COBRApy Python package. 

I understand that COBRApy models contain an optlang object within them. I was wondering if it is possible to remove this optlang object from COBRApy models, or to create models without the optlang object. 

The reason for this is I would like to be able to represent a very large genome scale model in COBRApy, and I want to be able to pickle this model for fast save/reload. However, because COBRApy models contain optlang objects, I am running into issues loading the model from a pickle file. Is it possible to remove an optlang object from a COBRApy model and if so, how do I do it? Thanks!

Best regards,
Nick Yousefi

Matthias König

unread,
Nov 24, 2025, 2:57:34 AMNov 24
to cobra pie
Hi Nick,
if your problem is the serialization you should try the dill library
https://github.com/uqfoundation/dill
It can handle many uses cases pickle struggles with.
Best Matthias

Nicholas Y

unread,
Nov 26, 2025, 9:35:02 AMNov 26
to cobra pie
Hi Matthias,

Thank you for your suggestion. I will try it and see if it works.

I still do want to confirm, though, whether there is an official way to remove the optlang solver from COBRApy models. Ideally, I would still like to remove it if possible. If this is not possible with COBRApy's current design, that is fine, but I would appreciate if you could please confirm if that is the case.

If there is no official way to remove the optlang object, I am considering using a fork of COBRApy in which I modify the code to remove the optlang object. I was wondering if this would be feasible and if you could provide any insights as to what parts of the code I would need to change to achieve this.

Thank you very much for your assistance. It is much appreciated.

Best regards,
Nick Yousefi

Nicholas Y

unread,
Dec 5, 2025, 12:04:59 AMDec 5
to cobra pie
Hi,

Just wanted to follow up on this since I hadn't received a reply. I would appreciate if you could at least clarify whether removing the optlang object is officially supported, even if you aren't sure about the other parts of my question. Thanks!

Best regards,
Nick Yousefi

Joshua Lerman

unread,
Dec 5, 2025, 12:21:53 AMDec 5
to Nicholas Y, cobra pie
i suppose one way is to revert to a much older version of cobrapy.   optlang wasn’t always a dependency.

josh 

--
You received this message because you are subscribed to the Google Groups "cobra pie" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cobra-pie+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/cobra-pie/6fdacf78-aceb-4cd3-8f69-77387b2c4338n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages