Skip to content

Conversation

@sevyharris
Copy link
Contributor

imp is deprecated and is getting removed in Python 3.12. documentation here shows the official suggestion for replacing imp.load_source calls: https://docs.python.org/3/whatsnew/3.12.html#imp

Motivation or Problem

Tiny PR to replace deprecated call to imp.load_source

Description of Changes

Changes adopted from official documentation:

https://docs.python.org/3/whatsnew/3.12.html#imp

import importlib.util
import importlib.machinery

def load_source(modname, filename):
    loader = importlib.machinery.SourceFileLoader(modname, filename)
    spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
    module = importlib.util.module_from_spec(spec)
    # The module is always executed and not cached in sys.modules.
    # Uncomment the following line to cache the module.
    # sys.modules[module.__name__] = module
    loader.exec_module(module)
    return module

Testing

Should be good to go as long as the CI tests pass. All the code is responsible for is loading the recommended families.

@github-actions
Copy link

Regression Testing Results

⚠️ One or more regression tests failed.
Please download the failed results and run the tests locally or check the log to see why.

Detailed regression test results.

Regression test aromatics:

Reference: Execution time (DD:HH:MM:SS): 00:00:00:49
Current: Execution time (DD:HH:MM:SS): 00:00:00:50
Reference: Memory used: 746.21 MB
Current: Memory used: 747.57 MB

aromatics Passed Core Comparison ✅

Original model has 15 species.
Test model has 15 species. ✅
Original model has 11 reactions.
Test model has 11 reactions. ✅

aromatics Passed Edge Comparison ✅

Original model has 106 species.
Test model has 106 species. ✅
Original model has 358 reactions.
Test model has 358 reactions. ✅

Details Observables Test Case: Aromatics Comparison

✅ All Observables varied by less than 0.500 on average between old model and new model in all conditions!

aromatics Passed Observable Testing ✅

Regression test liquid_oxidation:

Reference: Execution time (DD:HH:MM:SS): 00:00:01:56
Current: Execution time (DD:HH:MM:SS): 00:00:01:57
Reference: Memory used: 846.19 MB
Current: Memory used: 845.89 MB

liquid_oxidation Passed Core Comparison ✅

Original model has 37 species.
Test model has 37 species. ✅
Original model has 241 reactions.
Test model has 241 reactions. ✅

liquid_oxidation Failed Edge Comparison ❌

Original model has 214 species.
Test model has 214 species. ✅
Original model has 1590 reactions.
Test model has 1593 reactions. ❌
The original model has 2 reactions that the tested model does not have. ❌
rxn: CC(C[CH]COO)OO(115) <=> [OH](22) + CC(CCC=O)OO(116) origin: intra_H_migration
rxn: CC(C[CH]COO)OO(115) <=> [OH](22) + CC(=O)CCCOO(112) origin: intra_H_migration
The tested model has 5 reactions that the original model does not have. ❌
rxn: CC(C[CH]COO)OO(118) <=> CC(CC[CH]OO)OO(133) origin: intra_H_migration
rxn: CC(C[CH]COO)OO(118) <=> C[C](CCCOO)OO(132) origin: intra_H_migration
rxn: CC(CC(C)OO)O[O](90) + CC(CCCOO)O[O](108) <=> oxygen(1) + CC([O])CC(C)OO(110) + CC([O])CCCOO(122) origin: Peroxyl_Disproportionation
rxn: CC(CC(C)OO)O[O](90) + CC(CCCOO)O[O](108) <=> oxygen(1) + CC(=O)CC(C)OO(100) + CC(O)CCCOO(152) origin: Peroxyl_Termination
rxn: CC(CC(C)OO)O[O](90) + CC(CCCOO)O[O](108) <=> oxygen(1) + CC(=O)CCCOO(115) + CC(O)CC(C)OO(143) origin: Peroxyl_Termination

Details Observables Test Case: liquid_oxidation Comparison

✅ All Observables varied by less than 0.100 on average between old model and new model in all conditions!

liquid_oxidation Passed Observable Testing ✅

Regression test nitrogen:

Reference: Execution time (DD:HH:MM:SS): 00:00:01:02
Current: Execution time (DD:HH:MM:SS): 00:00:01:02
Reference: Memory used: 848.85 MB
Current: Memory used: 843.44 MB

nitrogen Passed Core Comparison ✅

Original model has 41 species.
Test model has 41 species. ✅
Original model has 360 reactions.
Test model has 360 reactions. ✅

nitrogen Passed Edge Comparison ✅

Original model has 133 species.
Test model has 133 species. ✅
Original model has 983 reactions.
Test model has 983 reactions. ✅

Details Observables Test Case: NC Comparison

✅ All Observables varied by less than 0.200 on average between old model and new model in all conditions!

nitrogen Passed Observable Testing ✅

Regression test oxidation:

Reference: Execution time (DD:HH:MM:SS): 00:00:01:48
Current: Execution time (DD:HH:MM:SS): 00:00:01:49
Reference: Memory used: 733.64 MB
Current: Memory used: 733.33 MB

oxidation Passed Core Comparison ✅

Original model has 59 species.
Test model has 59 species. ✅
Original model has 694 reactions.
Test model has 694 reactions. ✅

oxidation Passed Edge Comparison ✅

Original model has 230 species.
Test model has 230 species. ✅
Original model has 1526 reactions.
Test model has 1526 reactions. ✅

Details Observables Test Case: Oxidation Comparison

✅ All Observables varied by less than 0.500 on average between old model and new model in all conditions!

oxidation Passed Observable Testing ✅
Errors occurred during observable testing ⚠️ WARNING:root:Initial mole fractions do not sum to one; normalizing.

Regression test sulfur:

Reference: Execution time (DD:HH:MM:SS): 00:00:00:39
Current: Execution time (DD:HH:MM:SS): 00:00:00:40
Reference: Memory used: 836.64 MB
Current: Memory used: 843.49 MB

sulfur Passed Core Comparison ✅

Original model has 27 species.
Test model has 27 species. ✅
Original model has 74 reactions.
Test model has 74 reactions. ✅

sulfur Failed Edge Comparison ❌

Original model has 89 species.
Test model has 89 species. ✅
Original model has 227 reactions.
Test model has 227 reactions. ✅
The original model has 1 reactions that the tested model does not have. ❌
rxn: O(4) + SO2(15) (+N2) <=> SO3(16) (+N2) origin: primarySulfurLibrary
The tested model has 1 reactions that the original model does not have. ❌
rxn: O(4) + SO2(15) (+N2) <=> SO3(16) (+N2) origin: primarySulfurLibrary

Details Observables Test Case: SO2 Comparison

✅ All Observables varied by less than 0.100 on average between old model and new model in all conditions!

sulfur Passed Observable Testing ✅

Regression test superminimal:

Reference: Execution time (DD:HH:MM:SS): 00:00:00:25
Current: Execution time (DD:HH:MM:SS): 00:00:00:26
Reference: Memory used: 936.10 MB
Current: Memory used: 932.96 MB

superminimal Passed Core Comparison ✅

Original model has 13 species.
Test model has 13 species. ✅
Original model has 21 reactions.
Test model has 21 reactions. ✅

superminimal Passed Edge Comparison ✅

Original model has 18 species.
Test model has 18 species. ✅
Original model has 28 reactions.
Test model has 28 reactions. ✅

Regression test RMS_constantVIdealGasReactor_superminimal:

Reference: Execution time (DD:HH:MM:SS): 00:00:02:53
Current: Execution time (DD:HH:MM:SS): 00:00:02:20
Reference: Memory used: 2322.27 MB
Current: Memory used: 2287.37 MB

RMS_constantVIdealGasReactor_superminimal Passed Core Comparison ✅

Original model has 13 species.
Test model has 13 species. ✅
Original model has 19 reactions.
Test model has 19 reactions. ✅

RMS_constantVIdealGasReactor_superminimal Passed Edge Comparison ✅

Original model has 13 species.
Test model has 13 species. ✅
Original model has 19 reactions.
Test model has 19 reactions. ✅

Details Observables Test Case: RMS_constantVIdealGasReactor_superminimal Comparison

✅ All Observables varied by less than 0.100 on average between old model and new model in all conditions!

RMS_constantVIdealGasReactor_superminimal Passed Observable Testing ✅

Regression test RMS_CSTR_liquid_oxidation:

Reference: Execution time (DD:HH:MM:SS): 00:00:29:46
Current: Execution time (DD:HH:MM:SS): 00:00:23:25
Reference: Memory used: 3572.83 MB
Current: Memory used: 3287.18 MB

RMS_CSTR_liquid_oxidation Failed Core Comparison ❌

Original model has 35 species.
Test model has 35 species. ✅
Original model has 180 reactions.
Test model has 192 reactions. ❌
The original model has 1 species that the tested model does not have. ❌
spc: CCCC=O(88)
The tested model has 1 species that the original model does not have. ❌
spc: CC[CH]CCOO(74)
The original model has 1 reactions that the tested model does not have. ❌
rxn: [CH3](10) + CCCC=O(88) <=> CCCC(C)[O](41) origin: R_Addition_MultipleBond
The tested model has 13 reactions that the original model does not have. ❌
rxn: CC[CH]CCOO(74) <=> CCCCCO[O](61) origin: intra_H_migration
rxn: [O]O(13) + CC[CH]CCOO(74) <=> oxygen(1) + CCCCCOO(78) origin: H_Abstraction
rxn: OO(23) + CC[CH]CCOO(74) <=> [O]O(13) + CCCCCOO(78) origin: H_Abstraction
rxn: CC[CH]CCOO(74) + pentane(2) <=> C[CH]CCC(11) + CCCCCOO(78) origin: H_Abstraction
rxn: CC[CH]CCOO(74) + pentane(2) <=> CC[CH]CC(7) + CCCCCOO(78) origin: H_Abstraction
rxn: CC[CH]CCOO(74) + CCCC(C)OO(26) <=> CCCC(C)O[O](21) + CCCCCOO(78) origin: H_Abstraction
rxn: CC[CH]CCOO(74) + CCC(CC)OO(27) <=> CCC(CC)O[O](22) + CCCCCOO(78) origin: H_Abstraction
rxn: [CH2]CCCC(12) + CCCCCOO(78) <=> CC[CH]CCOO(74) + pentane(2) origin: H_Abstraction
rxn: [OH](24) + CCCCCOO(78) <=> O(42) + CC[CH]CCOO(74) origin: H_Abstraction
rxn: [CH2]CCCC(12) + CC[CH]CCOO(74) <=> C=CCCC(17) + CCCCCOO(78) origin: Disproportionation
rxn: C[CH]CCC(11) + CC[CH]CCOO(74) <=> C=CCCC(17) + CCCCCOO(78) origin: Disproportionation
rxn: CC[CH]CCOO(74) + CCCCCOO(78) <=> CCCCCO[O](61) + CCCCCOO(78) origin: H_Abstraction
rxn: CC[CH]CCOO(74) + CCCC(C)OO(26) <=> C[CH]CC(C)OO(34) + CCCCCOO(78) origin: H_Abstraction

RMS_CSTR_liquid_oxidation Passed Edge Comparison ✅

Original model has 107 species.
Test model has 107 species. ✅
Original model has 549 reactions.
Test model has 549 reactions. ✅

Details Observables Test Case: RMS_CSTR_liquid_oxidation Comparison

✅ All Observables varied by less than 0.100 on average between old model and new model in all conditions!

RMS_CSTR_liquid_oxidation Passed Observable Testing ✅

Regression test fragment:

Reference: Execution time (DD:HH:MM:SS): 00:00:00:30
Current: Execution time (DD:HH:MM:SS): 00:00:00:30
Reference: Memory used: 698.16 MB
Current: Memory used: 699.21 MB

fragment Passed Core Comparison ✅

Original model has 10 species.
Test model has 10 species. ✅
Original model has 2 reactions.
Test model has 2 reactions. ✅

fragment Passed Edge Comparison ✅

Original model has 33 species.
Test model has 33 species. ✅
Original model has 47 reactions.
Test model has 47 reactions. ✅

Details Observables Test Case: fragment Comparison

✅ All Observables varied by less than 0.100 on average between old model and new model in all conditions!

fragment Passed Observable Testing ✅
Errors occurred during observable testing ⚠️ WARNING:root:Initial mole fractions do not sum to one; normalizing.

Regression test RMS_constantVIdealGasReactor_fragment:

Reference: Execution time (DD:HH:MM:SS): 00:00:03:27
Current: Execution time (DD:HH:MM:SS): 00:00:02:44
Reference: Memory used: 2494.07 MB
Current: Memory used: 2404.56 MB

RMS_constantVIdealGasReactor_fragment Passed Core Comparison ✅

Original model has 10 species.
Test model has 10 species. ✅
Original model has 2 reactions.
Test model has 2 reactions. ✅

RMS_constantVIdealGasReactor_fragment Passed Edge Comparison ✅

Original model has 27 species.
Test model has 27 species. ✅
Original model has 24 reactions.
Test model has 24 reactions. ✅

Details Observables Test Case: RMS_constantVIdealGasReactor_fragment Comparison

✅ All Observables varied by less than 0.100 on average between old model and new model in all conditions!

RMS_constantVIdealGasReactor_fragment Passed Observable Testing ✅
Errors occurred during observable testing ⚠️ WARNING:root:Initial mole fractions do not sum to one; normalizing.

Regression test minimal_surface:

Reference: Execution time (DD:HH:MM:SS): 00:00:00:32
Current: Execution time (DD:HH:MM:SS): 00:00:00:31
Reference: Memory used: 849.36 MB
Current: Memory used: 844.14 MB

minimal_surface Passed Core Comparison ✅

Original model has 11 species.
Test model has 11 species. ✅
Original model has 3 reactions.
Test model has 3 reactions. ✅

minimal_surface Passed Edge Comparison ✅

Original model has 38 species.
Test model has 38 species. ✅
Original model has 38 reactions.
Test model has 38 reactions. ✅

Details Observables Test Case: minimal_surface Comparison

✅ All Observables varied by less than 0.500 on average between old model and new model in all conditions!

minimal_surface Passed Observable Testing ✅

beep boop this comment was written by a bot 🤖

JacksonBurns
JacksonBurns previously approved these changes Jan 15, 2026
Copy link
Contributor

@JacksonBurns JacksonBurns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just add a link to this function, since it's a bit wacky, but otherwise looks good to me! Thanks.

sevyharris and others added 2 commits January 16, 2026 08:39
imp is deprecated and is getting removed in Python 3.12.
documentation here shows the official suggestion for replacing
imp.load_source calls: https://docs.python.org/3/whatsnew/3.12.html#imp
Add link to documentation showing recommended way to replace imp.load_source

Co-authored-by: Jackson Burns <33505528+JacksonBurns@users.noreply.github.com>
@sevyharris sevyharris force-pushed the replace_deprecated_imp branch from 9523429 to 148131f Compare January 16, 2026 13:40
@sevyharris
Copy link
Contributor Author

I'd just add a link to this function, since it's a bit wacky, but otherwise looks good to me! Thanks.

@JacksonBurns Thanks for the review! I just noticed the CI is failing a couple tests. Probably not too dangerous to merge this PR anyways, but I'll see if I can fix those real quick on a separate PR so everything is passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants