Skip to content

Conversation

@Gobot1234
Copy link
Collaborator

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

Copilot AI review requested due to automatic review settings November 3, 2025 10:56
@github-actions github-actions bot added documentation Documentation related (improving, adding, etc) examples Publishing PyFluent examples bug Issue, problem or error in PyFluent labels Nov 3, 2025
Copy link
Contributor

Copilot AI left a 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.

@Gobot1234
Copy link
Collaborator Author

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
Copy link
Collaborator

@seanpearsonuk seanpearsonuk Dec 3, 2025

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]>
Copilot AI review requested due to automatic review settings December 3, 2025 09:41
Copy link
Contributor

Copilot AI left a 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.

@seanpearsonuk
Copy link
Collaborator

seanpearsonuk commented Dec 3, 2025

@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.

Copilot AI review requested due to automatic review settings December 3, 2025 11:59
Copy link
Contributor

Copilot AI left a 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.

Copilot AI review requested due to automatic review settings December 3, 2025 20:50
Copy link
Contributor

Copilot AI left a 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.

Comment on lines 69 to 74
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"
)
Copy link

Copilot AI Dec 3, 2025

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.

Suggested change
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"

Copilot uses AI. Check for mistakes.
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,
Copy link

Copilot AI Dec 3, 2025

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.

Suggested change
lambda: "<solver_session>.file.read_case" in capsys.readouterr().out,
lambda: "<solver_session>.settings.file.read_case" in capsys.readouterr().out,

Copilot uses AI. Check for mistakes.
absolute_pressure_expression.definition = "AbsolutePressure"

s1_min = solver1.fields.reduction.minimum(
s1_min = solver1.settings.fields.reduction.minimum(
Copy link

Copilot AI Dec 3, 2025

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.

Suggested change
s1_min = solver1.settings.fields.reduction.minimum(
s1_min = solver1.fields.reduction.minimum(

Copilot uses AI. Check for mistakes.
# ---------------------------------------------------------------

session = pyfluent.launch_fluent(precision="double", processor_count=2, version="3d")
session = pyfluent.launch_fluent(precision="double", processor_count=2, dimension=3)
Copy link

Copilot AI Dec 3, 2025

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.

Copilot uses AI. Check for mistakes.
@Gobot1234
Copy link
Collaborator Author

Gobot1234 commented Dec 4, 2025

@prmukherj / @seanpearsonuk are you okay with the tests that I've had to bump the markers of here?

Copilot AI review requested due to automatic review settings December 4, 2025 09:21
Copy link
Contributor

Copilot AI left a 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.



@pytest.mark.fluent_version(">=24.1")
@pytest.mark.fluent_version(">=25.1")
Copy link

Copilot AI Dec 4, 2025

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.

Suggested change
@pytest.mark.fluent_version(">=25.1")
@pytest.mark.fluent_version(">=24.1")

Copilot uses AI. Check for mistakes.


@pytest.mark.fluent_version(">=24.1")
@pytest.mark.fluent_version(">=25.2")
Copy link

Copilot AI Dec 4, 2025

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.

Suggested change
@pytest.mark.fluent_version(">=25.2")
@pytest.mark.fluent_version(">=24.2")

Copilot uses AI. Check for mistakes.


@pytest.mark.fluent_version(">=25.1")
@pytest.mark.fluent_version(">=25.2")
Copy link

Copilot AI Dec 4, 2025

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.

Suggested change
@pytest.mark.fluent_version(">=25.2")
@pytest.mark.fluent_version(">=25.1")

Copilot uses AI. Check for mistakes.
Comment on lines +115 to 117
import csv
import math
import os
Copy link

Copilot AI Dec 4, 2025

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.

Suggested change
import csv
import math
import os
import math
import os
import csv

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings December 18, 2025 02:20
Copy link
Contributor

Copilot AI left a 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,
}
)

Copy link

Copilot AI Dec 18, 2025

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.

Suggested change
# Ensure the geometry file is available to the meshing session before import.
meshing_session.upload(wing_intermediary_file)

Copilot uses AI. Check for mistakes.
Comment on lines 114 to 116
meshing_session.PartManagement.InputFileChanged(
FilePath=import_file_name, IgnoreSolidNames=False, PartPerBody=False
)
Copy link

Copilot AI Dec 18, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines 1198 to 1208
assert set(solver.results.graphics.contour.command_names) == {
"create",
"delete",
"rename",
"list",
"list_properties",
"make_a_copy",
"display",
"add_to_graphics",
"clear_history",
}
Copy link

Copilot AI Dec 18, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines 1222 to 1223
assert solver.results.graphics.contour.rename.argument_names == ["new", "old"]
assert solver.results.graphics.contour.delete.argument_names == ["name_list"]
Copy link

Copilot AI Dec 18, 2025

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.

Suggested change
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"}

Copilot uses AI. Check for mistakes.
)
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
Copy link

Copilot AI Dec 18, 2025

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.

Copilot uses AI. Check for mistakes.
@Gobot1234 Gobot1234 force-pushed the jhilton-/example-updates branch from c4ec3bd to 8ea0f85 Compare December 18, 2025 02:28
Copilot AI review requested due to automatic review settings December 18, 2025 02:43
Copy link
Contributor

Copilot AI left a 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,
Copy link

Copilot AI Dec 18, 2025

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.

Suggested change
processor_count=4,
processor_count=4,
dimension=3,

Copilot uses AI. Check for mistakes.
)

meshing_session.upload(wing_intermediary_file)
geo_import.Execute()
Copy link

Copilot AI Dec 18, 2025

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.

Copilot uses AI. Check for mistakes.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Import the CAD geometry file (``exhaust_system.fmd``) and selectively manage some
# parts.

Copy link

Copilot AI Dec 18, 2025

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.

Suggested change
meshing_session.upload(import_file_name)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue, problem or error in PyFluent documentation Documentation related (improving, adding, etc) examples Publishing PyFluent examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants