Skip to content

feat: Add exposure level to settings objects.#5028

Draft
prmukherj wants to merge 4 commits intomainfrom
feat/add_exposure_level_to_settings_api
Draft

feat: Add exposure level to settings objects.#5028
prmukherj wants to merge 4 commits intomainfrom
feat/add_exposure_level_to_settings_api

Conversation

@prmukherj
Copy link
Copy Markdown
Collaborator

Context

What was the situation or problem before this change?

Change Summary

What changes were made?

Rationale

Why was this approach taken?

Impact

What parts of the system or workflows are affected?

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

Adds an “exposure level” concept to solver settings objects so callers can determine whether a setting is alpha/beta/stable, and ensures this metadata can be propagated through generated settings classes.

Changes:

  • Introduced an ExposureLevel enum and a new exposure_level() accessor on settings objects (defaulting to Stable).
  • Plumbed exposure-level static info into dynamically created settings classes via _exposure_level.
  • Updated settings code generation to persist _exposure_level into generated Python and stub outputs.

Reviewed changes

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

File Description
src/ansys/fluent/core/solver/flobject.py Adds ExposureLevel, exposes exposure_level() accessor, and threads exposure level from static info into generated class dict.
src/ansys/fluent/core/codegen/settingsgen.py Includes _exposure_level in collected metadata and emits it into generated classes and stubs.

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

Comment on lines +486 to +499
def exposure_level(self) -> ExposureLevel | None:
"""Get the exposure level of the object.

Returns
-------
ExposureLevel | None
The exposure level of the object (Alpha, Beta, or Stable).
"""
attr = self.get_attr(_InlineConstants.exposure_level)
if attr is None:
attr = getattr(self, "_exposure_level", None)
if attr is None:
return ExposureLevel.STABLE
return ExposureLevel(attr.lower())
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type and docstring indicate ExposureLevel | None, but this method always returns an ExposureLevel (defaults to ExposureLevel.STABLE when the attribute is missing). Consider updating the signature/docs to return ExposureLevel and documenting the default/mapping behavior (including how unknown is treated).

Copilot uses AI. Check for mistakes.
"""
attr = self.get_attr(_InlineConstants.exposure_level)
if attr is None:
attr = getattr(self, "_exposure_level", None)
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getattr(self, "_exposure_level", None) goes through Base.__getattribute__, and when _exposure_level is absent it constructs the enhanced allowed-name error message before getattr swallows the AttributeError. To avoid that overhead, fetch the class attribute directly (e.g., via getattr(self.__class__, "_exposure_level", None) or object.__getattribute__).

Suggested change
attr = getattr(self, "_exposure_level", None)
attr = getattr(self.__class__, "_exposure_level", None)

Copilot uses AI. Check for mistakes.
Comment on lines +497 to +499
if attr is None:
return ExposureLevel.STABLE
return ExposureLevel(attr.lower())
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New exposure-level behavior isn’t covered by tests. Since this adds a new public accessor, please add unit/integration coverage to verify: (1) missing exposure returns Stable, (2) "unknown" maps to Stable, and (3) invalid values raise a helpful ValueError.

Suggested change
if attr is None:
return ExposureLevel.STABLE
return ExposureLevel(attr.lower())
# If no exposure level is set, default to Stable.
if attr is None:
return ExposureLevel.STABLE
# If the attribute is already an ExposureLevel, return it directly.
if isinstance(attr, ExposureLevel):
return attr
# Normalize string values and handle special cases.
if isinstance(attr, str):
normalized = attr.strip().lower()
# Treat empty/unknown exposure levels as Stable.
if not normalized or normalized == "unknown":
return ExposureLevel.STABLE
try:
return ExposureLevel(normalized)
except ValueError as exc:
valid_values = ", ".join(e.value for e in ExposureLevel)
raise ValueError(
f"Invalid exposure level {attr!r}. "
f"Valid values are: {valid_values!s} or 'unknown'."
) from exc
# Any non-string, non-ExposureLevel value is invalid.
raise ValueError(
f"Invalid exposure level type {type(attr).__name__!s}: {attr!r}."
)

Copilot uses AI. Check for mistakes.
@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Mar 31, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@prmukherj prmukherj linked an issue Apr 1, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "exposure-level" attribute to settings objects

3 participants