-
Notifications
You must be signed in to change notification settings - Fork 56
fix: Update get_si_unit_for_fluent_quantity and from_container #4573
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
Conversation
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 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_quantityto handle edge cases: empty lists,None, non-string values, and empty strings - Extended
from_containerwith 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.
Context
Before this change, certain utility functions in PyFluent — specifically
get_si_unit_for_fluent_quantity(influnits.py) andfrom_container(insession_utilities.py) — had issues handling units or container-based settings correctly. For example,get_si_unit_for_fluent_quantityneeded better handling when the inputquantitywasNone, a list, or an empty string. Also,from_containerhad 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:
flunits.py, theget_si_unit_for_fluent_quantityfunction has been updated to improve handling of various cases: whenquantityisNone, when it's a list (especially an empty list), when it is not a string, or when it is a string but empty.session_utilities.py, thefrom_containerfunction signature and/or its default parameters were adjusted (added parameters likegpu: 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.doc/changelog.d/4573.fixed.md) was added summarizing “Update get_si_unit_for_fluent_quantity and from_container”.tests/test_flobject.py) to reflect updated behavior or remove outdated assertions.Rationale
get_si_unit_for_fluent_quantitychange ensures that unit handling is robust and predictable even for edge cases: lists,None, empty strings. Since PyFluent integrates with theansys-unitslibrary and supports quantity objects, it is important that units are determined correctly.from_containerchanges 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.Impact
get_si_unit_for_fluent_quantityandfrom_containerare 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).from_containernow has more parameters/defaults).units()oras_quantity()on settings objects) may need to consider the changed handling of lists/None/empty strings inget_si_unit_for_fluent_quantity.