Skip to content

Conversation

@hpohekar
Copy link
Collaborator

@hpohekar hpohekar commented Oct 29, 2025


Context

Before this change, certain utility functions in PyFluent — specifically get_si_unit_for_fluent_quantity (in flunits.py) and from_container (in session_utilities.py) — had issues handling units or container-based settings correctly. For example, get_si_unit_for_fluent_quantity needed better handling when the input quantity was None, a list, or an empty string. Also, from_container had parameters or logic that required adjustment for container-mode launches and file-transfer workflows. The existing behavior could lead to unexpected results when working with quantity units or launching sessions with containers.


Change Summary

The PR makes the following changes:

  • In flunits.py, the get_si_unit_for_fluent_quantity function has been updated to improve handling of various cases: when quantity is None, when it's a list (especially an empty list), when it is not a string, or when it is a string but empty.
  • In session_utilities.py, the from_container function signature and/or its default parameters were adjusted (added parameters like gpu: bool | None = None, file_transfer_service: Any | None = None, use_podman_compose: bool | None = None). This expands the function’s ability to launch Fluent in container mode with more flexibility.
  • A changelog entry (doc/changelog.d/4573.fixed.md) was added summarizing “Update get_si_unit_for_fluent_quantity and from_container”.
  • Some tests were modified (in tests/test_flobject.py) to reflect updated behavior or remove outdated assertions.

Rationale

  • The get_si_unit_for_fluent_quantity change ensures that unit handling is robust and predictable even for edge cases: lists, None, empty strings. Since PyFluent integrates with the ansys-units library and supports quantity objects, it is important that units are determined correctly.
  • The from_container changes are motivated by the need to better support containerised workflows of Fluent (e.g., using Docker or Podman) and enabling file transfer services for these sessions. Having additional parameters gives users more control (GPU usage, whether to use Docker Compose or Podman Compose, file transfer service) in launching Fluent via Python.
  • Overall, the changes aim to reduce brittleness in unit-handling and broaden the support of containerised execution scenarios, improving reliability and usability of PyFluent in advanced workflows.

Impact

  • The functions get_si_unit_for_fluent_quantity and from_container are internal utilities used by the PyFluent core library (ansys.fluent.core). Workflows that involve retrieving or interpreting units of Fluent quantities will benefit (or may require slight adjustments if they relied on previous behavior).
  • Session launch workflows, especially those using container mode (Docker or Podman) or using custom file-transfer services, will see enhanced capabilities and possibly changed interfaces (because from_container now has more parameters/defaults).
  • Test and code-quality improvements: since the tests were adjusted, developers extending or modifying PyFluent should see fewer false positives/failures around unit and container-session utilities.
  • Downstream code that introspects or depends on unit strings (via units() or as_quantity() on settings objects) may need to consider the changed handling of lists/None/empty strings in get_si_unit_for_fluent_quantity.
  • Because these are utility changes rather than front-end user APIs, the impact on everyday usage of PyFluent (e.g., reading cases, solving) may be small for many users. But for advanced users leveraging units or container workflows, the improvements should lead to more predictable behavior.

@github-actions github-actions bot added the bug Issue, problem or error in PyFluent label Oct 29, 2025
@hpohekar hpohekar linked an issue Oct 29, 2025 that may be closed by this pull request
@hpohekar hpohekar marked this pull request as ready for review October 29, 2025 03:56
Copilot AI review requested due to automatic review settings October 29, 2025 03:56
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 issues with unit handling and container-based session launches in PyFluent by updating two key utility functions: get_si_unit_for_fluent_quantity (for more robust unit handling) and from_container (for enhanced container workflow support).

Key Changes:

  • Improved get_si_unit_for_fluent_quantity to handle edge cases: empty lists, None, non-string values, and empty strings
  • Extended from_container with new parameters (use_docker_compose, use_podman_compose) for greater flexibility in containerized Fluent launches
  • Re-enabled a previously skipped test for ansys-units integration

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/test_flobject.py Removes skip marker from ansys-units integration test, indicating the underlying issue is now resolved
src/ansys/fluent/core/solver/flunits.py Updates unit handling logic to properly handle empty lists and falsy values before type checking
src/ansys/fluent/core/session_utilities.py Adds Docker/Podman Compose parameters to container launch function
doc/changelog.d/4573.fixed.md Documents the fix for these utility functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hpohekar hpohekar enabled auto-merge (squash) October 29, 2025 16:06
@hpohekar hpohekar merged commit 0876455 into main Oct 29, 2025
35 checks passed
@hpohekar hpohekar deleted the fix/state_with_units branch October 29, 2025 23:35
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_ansys_units_integration is failing Bug located in SessionBase.from_container() test_ansys_units_integration is failing in 25.2

5 participants