cog-imperial / OMLT

Represent trained machine learning models as Pyomo optimization formulations
Other
257 stars 56 forks source link

Replace _BlockData with BlockData #144

Open andrewlee94 opened 2 months ago

andrewlee94 commented 2 months ago

Pyomo recently made ComponentData classes public (https://github.com/Pyomo/pyomo/pull/3221) which will be part of the upcoming release. Currently, this causes the following error to occur in OMLT:

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

The Pyomo team is working to try to address this issue, however OMLT should update its code to address this as otherwise deprecation warnings will be emitted when using the old class names.

The fix is to replace all instances of _BlockData with BlockData (just removing the underscore) - this applies to any other instance of Pyomo component data objects as well (although I could only find 2 instances of these in the OMLT code).

Legal Acknowledgement\ By contributing to this software project, I agree my contributions are submitted under the BSD license. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

jalving commented 1 month ago

Thanks for the update @andrewlee94. We had to fix some CI issues in OMLT, so this PR didn't hit the usual checks. I'm happy to update this PR with the latest from main.