Skip to content

fix: replace top-level package proxy imports with direct module imports#4972

Merged
mayankansys merged 6 commits intomainfrom
fix/circular-import
Mar 10, 2026
Merged

fix: replace top-level package proxy imports with direct module imports#4972
mayankansys merged 6 commits intomainfrom
fix/circular-import

Conversation

@mayankansys
Copy link
Copy Markdown
Collaborator

Context

Several modules imported config via from ansys.fluent.core import config or import ansys.fluent.core as pyfluent instead of importing directly from module_config.py. This forced __init__.py to fully execute before those modules could load, creating artificial circular-import constraints and requiring a fragile manual # isort: off ordering guard.

Change Summary

Replaced all indirect config imports with:
from ansys.fluent.core.module_config import config

Rationale

Direct imports bypass __init__.py entirely, eliminating the circular dependency
at its root. No logic was changed — only import paths.

Impact

28 files updated. Import order in __init__.py is now freely managed by isort.
No functional behaviour is affected.

@github-actions github-actions Bot added the bug Issue, problem or error in PyFluent label Mar 4, 2026
@hpohekar hpohekar marked this pull request as ready for review March 9, 2026 06:17
Copilot AI review requested due to automatic review settings March 9, 2026 06:17
@hpohekar hpohekar self-requested a review as a code owner March 9, 2026 06:17
Copy link
Copy Markdown
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 replaces indirect config imports (via ansys.fluent.core.__init__ or pyfluent.config) with direct imports from ansys.fluent.core.module_config across the source code. This eliminates circular-import constraints that required fragile # isort: off guards in __init__.py by ensuring modules can access config without triggering full package initialization.

Changes:

  • Replaced all from ansys.fluent.core import config and pyfluent.config references in 27 source files with from ansys.fluent.core.module_config import config
  • Where pyfluent was only used for config access, removed the import ansys.fluent.core as pyfluent import; where it also provided other symbols (e.g., FluentVersion, launch_fluent, utils.load_module), those were replaced with direct imports from their defining modules
  • Added a changelog entry for the fix

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/ansys/fluent/core/utils/networking.py Replace function-level config import with direct module import
src/ansys/fluent/core/utils/fluent_version.py Add module-level direct config import; update current_release/current_dev
src/ansys/fluent/core/utils/data_transfer.py Replace pyfluent import with direct config import
src/ansys/fluent/core/system_coupling.py Replace pyfluent import with direct config import
src/ansys/fluent/core/streaming_services/datamodel_streaming.py Replace pyfluent import with direct config import
src/ansys/fluent/core/streaming_services/datamodel_event_streaming.py Replace function-level config import
src/ansys/fluent/core/solver/flobject.py Replace function-level config/utils imports with direct imports
src/ansys/fluent/core/session_solver.py Add direct config import; update pyfluent.config references
src/ansys/fluent/core/session_shared.py Replace pyfluent import with direct config and load_module imports
src/ansys/fluent/core/session_pure_meshing.py Replace pyfluent import with direct config import
src/ansys/fluent/core/services/interceptors.py Replace function-level config imports
src/ansys/fluent/core/services/health_check.py Replace pyfluent import with direct config import
src/ansys/fluent/core/services/datamodel_se.py Replace pyfluent import with direct config import
src/ansys/fluent/core/services/api_upgrade.py Replace function-level config import
src/ansys/fluent/core/search.py Consolidate multiple function-level config imports into one module-level import
src/ansys/fluent/core/logger.py Replace top-level config import path
src/ansys/fluent/core/launcher/slurm_launcher.py Move config import to module level from direct module
src/ansys/fluent/core/launcher/server_info.py Replace function-level config imports
src/ansys/fluent/core/launcher/launcher_utils.py Replace function-level config import
src/ansys/fluent/core/launcher/launcher.py Replace pyfluent import with direct config import
src/ansys/fluent/core/launcher/launch_options.py Replace function-level config import
src/ansys/fluent/core/launcher/fluent_container.py Replace pyfluent import with direct config import
src/ansys/fluent/core/fluent_connection.py Replace pyfluent import with direct config and FluentVersion imports
src/ansys/fluent/core/docker/docker_compose.py Replace function-level config import
src/ansys/fluent/core/data_model_cache.py Replace function-level config import
src/ansys/fluent/core/codegen/builtin_settingsgen.py Replace config and FluentVersion imports with direct module imports
src/ansys/fluent/core/codegen/allapigen.py Replace top-level config import path
doc/changelog.d/4972.fixed.md Changelog entry for the fix

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

Comment thread src/ansys/fluent/core/codegen/builtin_settingsgen.py Outdated
Comment thread src/ansys/fluent/core/codegen/builtin_settingsgen.py Outdated
Co-authored-by: Prithwish Mukherjee <109645853+prmukherj@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 9, 2026 09:49
Copy link
Copy Markdown
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 28 out of 28 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.

@mayankansys mayankansys merged commit d8023f5 into main Mar 10, 2026
37 checks passed
@mayankansys mayankansys deleted the fix/circular-import branch March 10, 2026 08:40
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.

Fix incorrect top-level imports causing artificial circular-import constraints

6 participants