-
Notifications
You must be signed in to change notification settings - Fork 58
fix: example deprecation warnings and improvements #4579
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes deprecation warnings by updating all references from direct solver session settings access (solver.setup.models) to the correct settings-based access pattern (solver.settings.setup.models). Additionally, it adds PEP 723 style dependencies to example scripts and includes minor improvements throughout.
- Updates deprecated direct access patterns to settings-based access across all test files and examples
- Adds PEP 723 dependency declarations to example scripts for standalone execution
- Includes miscellaneous code improvements and cleanups
Reviewed Changes
Copilot reviewed 67 out of 68 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tests/ | Updates test files to use solver.settings instead of direct access patterns |
| examples/ | Adds PEP 723 dependency headers and updates deprecated settings access |
| src/ | Updates core library files to use settings-based access pattern |
| doc/ | Updates documentation examples to reflect new access patterns |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Anyone have any opinions on #4512 (review)? |
| ------------------------- | ||
|
|
||
| Following the introduction of the new format, the traditional method remains available for those | ||
| Following the introduction of the new format, the traditional method remains available for those |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence is out of place and lacks context:
“Following the introduction of the new format, the traditional method remains available for those who prefer the existing hierarchy.”
It doesn’t belong at the start of this section and should instead be integrated into the previous section—after introducing the new-style API—so that the relationship between the new and existing APIs is clear and non-redundant. The goal is simply to mention that the existing hierarchy-based API remains fully supported and is not deprecated.
Below are suggested rewrites for both sections.
Suggested rewrite for the previous section (new-style API introduction)
To simplify access to solver settings and improve readability, you can now instantiate settings objects directly using a concise constructor-style syntax. This avoids navigating the full hierarchy of solver settings while preserving the same functional capabilities.
<Example>
The traditional hierarchy-based API remains fully supported. The new syntax is an additional, more convenient option and not a replacement.
Suggested rewrite for the Accessing solver settings section
The hierarchy-based settings API continues to be available for users who prefer explicit navigation of the settings structure. For example, when working with string lists that support wildcard expansion:
<Code>
Co-authored-by: Sean Pearson <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
|
@Gobot1234 I made a number of remarks unconnected with the changes but I didn't want to miss the opportunity to fix some badly broken windows. My comments can be addressed either here or subsequently. For any that we do subsequently, we need to generate Issues from the comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 67 out of 68 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 67 out of 68 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/test_tui_api.py
Outdated
| assert s.split("\n")[-2].split("(")[0] == r"<solver_session>.file.read_case" | ||
| else: | ||
| assert ( | ||
| s.split("\n")[-2].split("(")[0] | ||
| == r"<solver_session>.settings.file.read_case" | ||
| ) |
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version comparison logic is inverted. For Fluent version >= v251, the assertion expects <solver_session>.file.read_case, but based on the PR description (updating to use solver.settings.*), newer versions should use the .settings. prefix. The conditional branches should be swapped.
| assert s.split("\n")[-2].split("(")[0] == r"<solver_session>.file.read_case" | |
| else: | |
| assert ( | |
| s.split("\n")[-2].split("(")[0] | |
| == r"<solver_session>.settings.file.read_case" | |
| ) | |
| assert ( | |
| s.split("\n")[-2].split("(")[0] | |
| == r"<solver_session>.settings.file.read_case" | |
| ) | |
| else: | |
| assert s.split("\n")[-2].split("(")[0] == r"<solver_session>.file.read_case" |
tests/test_settings_api.py
Outdated
| solver.tui.file.read_case(case_path) | ||
| timeout_loop( | ||
| lambda: "<solver_session>.settings.file.read_case" in capsys.readouterr().out, | ||
| lambda: "<solver_session>.file.read_case" in capsys.readouterr().out, |
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion checks for the deprecated access pattern <solver_session>.file.read_case instead of the updated pattern <solver_session>.settings.file.read_case. This contradicts the PR's goal of updating to the new API.
| lambda: "<solver_session>.file.read_case" in capsys.readouterr().out, | |
| lambda: "<solver_session>.settings.file.read_case" in capsys.readouterr().out, |
tests/test_reduction.py
Outdated
| absolute_pressure_expression.definition = "AbsolutePressure" | ||
|
|
||
| s1_min = solver1.fields.reduction.minimum( | ||
| s1_min = solver1.settings.fields.reduction.minimum( |
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path solver1.settings.fields.reduction is incorrect. Based on other usage in the codebase, it should be solver1.fields.reduction without the .settings prefix.
| s1_min = solver1.settings.fields.reduction.minimum( | |
| s1_min = solver1.fields.reduction.minimum( |
| # --------------------------------------------------------------- | ||
|
|
||
| session = pyfluent.launch_fluent(precision="double", processor_count=2, version="3d") | ||
| session = pyfluent.launch_fluent(precision="double", processor_count=2, dimension=3) |
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed parameter from version=\"3d\" to dimension=3. Verify that dimension=3 is the correct parameter name and value for specifying 3D mode, as this represents an API change.
|
@prmukherj / @seanpearsonuk are you okay with the tests that I've had to bump the markers of here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 67 out of 68 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/test_batch_ops.py
Outdated
|
|
||
|
|
||
| @pytest.mark.fluent_version(">=24.1") | ||
| @pytest.mark.fluent_version(">=25.1") |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The minimum Fluent version requirement was changed from >=24.1 to >=25.1, which may unnecessarily restrict test execution on Fluent 24.x versions where the functionality should still work.
| @pytest.mark.fluent_version(">=25.1") | |
| @pytest.mark.fluent_version(">=24.1") |
tests/test_reduction.py
Outdated
|
|
||
|
|
||
| @pytest.mark.fluent_version(">=24.1") | ||
| @pytest.mark.fluent_version(">=25.2") |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The minimum Fluent version requirement was changed from >=24.1 to >=25.2. Unless there's a specific feature dependency on 25.2, this unnecessarily restricts test coverage on earlier compatible versions.
| @pytest.mark.fluent_version(">=25.2") | |
| @pytest.mark.fluent_version(">=24.2") |
tests/test_reduction.py
Outdated
|
|
||
|
|
||
| @pytest.mark.fluent_version(">=25.1") | ||
| @pytest.mark.fluent_version(">=25.2") |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The minimum Fluent version requirement was changed from >=25.1 to >=25.2. This should only be updated if there's a concrete dependency on 25.2 features; otherwise, it reduces test coverage.
| @pytest.mark.fluent_version(">=25.2") | |
| @pytest.mark.fluent_version(">=25.1") |
| import csv | ||
| import math | ||
| import os |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The csv import is now placed after the header comment but before other standard library imports (math, os, pathlib). Standard library imports should be grouped together following PEP 8 import ordering guidelines.
| import csv | |
| import math | |
| import os | |
| import math | |
| import os | |
| import csv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 52 out of 53 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "FileName": wing_intermediary_file, | ||
| } | ||
| ) | ||
|
|
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line meshing_session.upload(wing_intermediary_file) was removed before geo_import.Execute(). If geo_import.Execute() depends on the file being uploaded first, this removal will cause a runtime error. Verify that the file upload is handled elsewhere or is no longer needed.
| # Ensure the geometry file is available to the meshing session before import. | |
| meshing_session.upload(wing_intermediary_file) |
| meshing_session.PartManagement.InputFileChanged( | ||
| FilePath=import_file_name, IgnoreSolidNames=False, PartPerBody=False | ||
| ) |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line meshing_session.upload(import_file_name) was removed before calling PartManagement.InputFileChanged(). If the file needs to be uploaded before it can be referenced by FilePath, this will cause a file-not-found error. Confirm that the upload is handled automatically or is unnecessary.
tests/test_flobject.py
Outdated
| assert set(solver.results.graphics.contour.command_names) == { | ||
| "create", | ||
| "delete", | ||
| "rename", | ||
| "list", | ||
| "list_properties", | ||
| "make_a_copy", | ||
| "display", | ||
| "add_to_graphics", | ||
| "clear_history", | ||
| } |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed from issuperset to exact equality check (==). This is stricter and will fail if Fluent adds new commands in future versions. Consider whether this increased strictness is intentional or if issuperset was more appropriate for forward compatibility.
tests/test_flobject.py
Outdated
| assert solver.results.graphics.contour.rename.argument_names == ["new", "old"] | ||
| assert solver.results.graphics.contour.delete.argument_names == ["name_list"] |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed from set comparison to list comparison. This now checks both the names and their order. Verify that the order of argument names is guaranteed to be stable across Fluent versions, or revert to set comparison if order is not significant.
| assert solver.results.graphics.contour.rename.argument_names == ["new", "old"] | |
| assert solver.results.graphics.contour.delete.argument_names == ["name_list"] | |
| assert set(solver.results.graphics.contour.rename.argument_names) == {"new", "old"} | |
| assert set(solver.results.graphics.contour.delete.argument_names) == {"name_list"} |
tests/test_field_data.py
Outdated
| ) | ||
| vertices_data = field_data.get_field_data(vertices_data_request) | ||
| assert round(vertices_data["interior-4"].vertices[5][0], 2) == 0.0 | ||
| assert round(vertices_data["interior-4"][SurfaceDataType.Vertices][5][0], 2) == 0.0 |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The field data access pattern has changed significantly from using .vertices attribute to dictionary-style access with [SurfaceDataType.Vertices]. Ensure this new pattern is documented and consistent with the current API design, as it represents a breaking change in how users access field data.
c4ec3bd to
8ea0f85
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 32 out of 33 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| mode="meshing", | ||
| dimension=3, | ||
| precision="double", | ||
| processor_count=4, |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of 'dimension=3' parameter should be verified. While dimension might be inferred or defaulted, ensure that this change doesn't affect the intended 3D simulation behavior.
| processor_count=4, | |
| processor_count=4, | |
| dimension=3, |
| ) | ||
|
|
||
| meshing_session.upload(wing_intermediary_file) | ||
| geo_import.Execute() |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of meshing_session.upload(wing_intermediary_file) at line 125 suggests that file upload is no longer necessary before Execute(). Verify that the file is accessible to the meshing session through other means (e.g., shared filesystem or automatic handling) to ensure the workflow remains functional.
| # ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| # Import the CAD geometry file (``exhaust_system.fmd``) and selectively manage some | ||
| # parts. | ||
|
|
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of meshing_session.upload(import_file_name) at line 113 suggests that file upload is no longer necessary before InputFileChanged(). Verify that the file is accessible to the meshing session through other means (e.g., shared filesystem or automatic handling) to ensure the workflow remains functional.
| meshing_session.upload(import_file_name) |
Context
When solver session settings access was deprecated directly on solver the code wasn't updated I've also sprinkled in a couple of small improvements to the examples
Change Summary
Updated all references direct access patterns (
solver.setup.models) to the correct settings-based access pattern (solver.settings.setup.models) along with adding PEP 723 styles dependencies to the examples to make them easier to run as standalone scripts.Rationale
Fixes all the deprecation warnings
Impact
Changes basically everywhere