-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Problem serialization #532
Comments
Not that I speak for Steven, but I'd be surprised if there were such a way (at least, for now). One obstacle is that Expression objects are highly recursive data structures. Even if a user has a small number of Constraint objects, the Expressions involved in those objects might take a massive amount of space if written in a format like JSON. At a higher level, you say that you "just" want the data to recreate the original CVXPY problem, but, that is necessarily more data than the input to ECOS or SCS! |
@SteveDiamond actually something recently occured to me about this issue. Is it possible to serialize and de-serialize cvxpy Problems using If cvxpy doesn't currently support pickle (and this can accidentally happen for dozens of different reasons) then it may be worth keeping this issue open. |
@rileyjmurray good point! I added a test for pickling and unpickling a problem, and it seems to work. |
Pickle seems to be an issue again when
If you are running it in a joblib loop you will get lots of errors. |
That's unfortunate. What do you think we should do? |
In my code I just did
before calling the parallel loop in joblib. However, that defies the purpose of storing |
My understanding is that we should only run into pickling issues when dealing with objects from third-party libraries like solver interfaces. If that's the case then we can take advantage of qualitative "serialization" features that are sure to exist for those interfaces. For mosek we have a |
I agree it is not a major issue when dealing with external libraries. I was not referring to serializing to store the problem on disk. I was mostly considering the case when you are solving cvxpy problems in parallel in a loop and you already happen to have an unserializable object inside A simple solution would be to include the code above into a small problem method called, for example, |
@SteveDiamond, any idea if there's a good way to serialize a CVXPY problem?
I know that
get_problem_data
exists, but that returns the problem data for specific solvers. I basically want to construct some sort of JSON (protobuf, etc.) that contains all the data for expressions to allow me to recreate a CVXPY Problem. This is different fromget_problem_data
in that I don't want all the data necessary to recreate, say, the input to ECOS or SCS--I just want all the data to recreate the original CVXPY problem.I essentially want to pickle a
Problem
object, but would like to avoid all the security issues around python pickles (arbitrary code execution!).The text was updated successfully, but these errors were encountered: