Skip to content

Resolve incompatibility between imp and the DeferredImportCallbackFinder#3444

Merged
jsiirola merged 4 commits intoPyomo:mainfrom
jsiirola:imp-finder-compat
Dec 6, 2024
Merged

Resolve incompatibility between imp and the DeferredImportCallbackFinder#3444
jsiirola merged 4 commits intoPyomo:mainfrom
jsiirola:imp-finder-compat

Conversation

@jsiirola
Copy link
Copy Markdown
Member

@jsiirola jsiirola commented Dec 5, 2024

Fixes # .

Summary/Motivation:

IDAES identified an incompatibility with Pyomo's DeferredImportCallbackFinder and the (deprecated) imp module. Finders from that module lack a find_spec method and instead use a find_module method.

This came up because Google Collab defines imp-style finders, which was causing errors: https://ndcbe.github.io/optimization/notebooks/7/degeneracy_hunter.html

Changes proposed in this PR:

  • Support deferring to both imp and importlib style finders
  • Add testing for Pyomo's callback hooks

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. 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.

@lbianchi-lbl
Copy link
Copy Markdown

lbianchi-lbl commented Dec 5, 2024

I tested the notebook (static link, Colab link) where the issue was originally noticed, making sure a new "runtime" (container instance) was used each time.

Without the fix (Pyomo 6.8.2)

2024-12-05_11-27

With the fix (installing Pyomo from this PR's head branch before importing it)

2024-12-05_11-24

@jsiirola jsiirola merged commit 6f36384 into Pyomo:main Dec 6, 2024
@jsiirola jsiirola deleted the imp-finder-compat branch December 6, 2024 15:36
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

Successfully merging this pull request may close these issues.

3 participants