Skip to content

Add a simpler way to wrap existing flowsheets for FlowsheetRunner#1772

Open
dangunter wants to merge 17 commits intoIDAES:mainfrom
dangunter:minimalwrap-1771
Open

Add a simpler way to wrap existing flowsheets for FlowsheetRunner#1772
dangunter wants to merge 17 commits intoIDAES:mainfrom
dangunter:minimalwrap-1771

Conversation

@dangunter
Copy link
Copy Markdown
Member

@dangunter dangunter commented Apr 17, 2026

Fixes #1771

Summary/Motivation:

See issue

Changes proposed in this PR:

  • add simple_wrap.py with a decorator function fi_main
  • import fi_main at structfs subpackage level so from idaes.core.util.structfs import fi_main will work
  • add some utility functions in fsrunner to find and run the wrapped methods (as well as find the older-style global flowsheet objects)

Legal Acknowledgement

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

  1. I agree my contributions are submitted under the license terms described in the LICENSE.txt file at the top level of this directory.
  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.

@dangunter dangunter self-assigned this Apr 17, 2026
@dangunter dangunter requested a review from CopyDemon April 17, 2026 04:35
@dangunter
Copy link
Copy Markdown
Member Author

@CopyDemon @sspoon

This is the simplified wrapper code. It pretty much does what we talked about.

Sheng, note that there are a few new functions at the bottom of fsrunner.py that can be used to detect whether the module has a global flowsheet object (like previously), or uses this simplified wrapper function, or neither. See the tests with the word "wrapped" in their names in test_fsrunner.py

@dangunter
Copy link
Copy Markdown
Member Author

Example usage (from the docs)

from idaes.core.util.structfs import fi_main

@fi_main
def my_main_function(some, args, keyword=None): # can take any arguments
    # build the flowsheet -> model
    model = build_flowsheet()
    # initialize the flowsheet
    # solve the flowsheet -> solve_result
    solve_result = solve_flowsheet()

    # **Important!**: return the model and solve result as a tuple
    return model, solve_result

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 17, 2026

Codecov Report

❌ Patch coverage is 87.69231% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.82%. Comparing base (886bb73) to head (c1a74eb).

Files with missing lines Patch % Lines
idaes/core/util/structfs/fsrunner.py 70.37% 4 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1772      +/-   ##
==========================================
- Coverage   73.82%   73.82%   -0.01%     
==========================================
  Files         419      421       +2     
  Lines       66274    66331      +57     
  Branches    11133    11139       +6     
==========================================
+ Hits        48927    48968      +41     
- Misses      14810    14818       +8     
- Partials     2537     2545       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dangunter dangunter marked this pull request as ready for review April 19, 2026 16:02
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.

Reduce code needed to "wrap" flowsheets with structfs

1 participant