Skip to content
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

Minor improvements to scaling API #1507

Merged
merged 87 commits into from
Oct 25, 2024
Merged

Conversation

andrewlee94
Copy link
Member

Fixes None

Summary/Motivation:

Based on initial demonstrations of the new scaling tools, a few minor improvements have been suggested.

Changes proposed in this PR:

  • Change API of call_submodel_scaler_method to take submodel object instead of string name.

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.

@andrewlee94 andrewlee94 self-assigned this Oct 23, 2024
@andrewlee94 andrewlee94 added enhancement New feature or request Priority:Normal Normal Priority Issue or PR core Issues dealing with core modeling components scaling_v2 labels Oct 23, 2024
@andrewlee94 andrewlee94 changed the title Minor improvements ot scaling API Minor improvements to scaling API Oct 23, 2024
@codecov-commenter
Copy link

codecov-commenter commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 76.98%. Comparing base (96237b9) to head (e45968b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
idaes/core/scaling/custom_scaler_base.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1507      +/-   ##
==========================================
- Coverage   76.99%   76.98%   -0.01%     
==========================================
  Files         382      382              
  Lines       61993    61992       -1     
  Branches    10146    10146              
==========================================
- Hits        47733    47727       -6     
- Misses      11852    11858       +6     
+ Partials     2408     2407       -1     

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

if callable(scaler):
# Check to see if Scaler is callable - this implies it is a class and not an instance
# Call the class to create an instance
scaler = scaler()
_log.debug(f"Using user-defined Scaler for {model}.{submodel}.")
_log.debug(f"Using user-defined Scaler for {submodel}.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this going to give human readable output, or is it going to be some Pyomo thing in brackets?

Consider using submodel.name

Copy link
Member Author

Choose a reason for hiding this comment

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

It will end up being submodel.name - it is not obvious but the f-string magic casts it to a string.

Copy link
Contributor

@agarciadiego agarciadiego left a comment

Choose a reason for hiding this comment

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

Looks good to me. Only a question about future maintenance in error messages but this should not stop merging.

"No default Scaler set for unknown.b. Cannot call dummy_method."
in caplog.text
)
assert "No default Scaler set for b. Cannot call dummy_method." in caplog.text
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if only referencing dummy_method in error message may confuse maintainer in the future

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you have a suggestion for a better message?

Copy link
Contributor

Choose a reason for hiding this comment

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

"No default Scaler set for b. Cannot call dummy_method created for testing purposes."

Copy link
Member Author

Choose a reason for hiding this comment

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

The message is generated dynamically using the name of the method the user asked for. In this test case, the method I asked for was named "dummy_method", but a user would see the name of the method they specified.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then I think it's fine

@ksbeattie ksbeattie enabled auto-merge (squash) October 24, 2024 18:29
@andrewlee94 andrewlee94 merged commit d931060 into IDAES:main Oct 25, 2024
49 of 69 checks passed
@andrewlee94 andrewlee94 deleted the scaling_tweaks branch October 25, 2024 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues dealing with core modeling components enhancement New feature or request Priority:Normal Normal Priority Issue or PR scaling_v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants