Skip to content

[FEATURE] enable experimental features on a global level #772

Closed as duplicate

Description

@mgovers

Describe the feature request
Currently, the experimental feature is an option to the calculations:

  • C API:
    • to enable experimental features, the PGM_set_experimental_features() function needs to be called on a PGM_Options object.
  • Python API:
    • it currently requires using the protected _calculate_* functions instead of the public calculate_* ones.
    • to prevent linter errors, it is possible to use an inheritance pattern, e.g.
         py    class PowerGridModelWithExperimentalFeatures(PowerGridModel):        def calculate_power_flow_with_experimental_features(self, *args, **kwargs):            return super()._calculate_power_flow(*args, **kwargs)   

This approach enables experimental features in the calculation itself, but it has no effect on other features that do not immediately run within in calculations, like data creation. That would require a global experimental feature setting.

Such a global experimental feature flag could be added to the handle (C API)

  • A good example of a feature that could have benefited from a global experimental feature flag was columnar dataset creation.

Design

  • C API:
    • to the PGM_Handle, add an experimental_features member variable
    • for PGM_set_experimental_features:
         * [ ] move to basics.h (this is a backwards compatible change)
         * [ ] if handle is not nullptr [new feature]
           * [ ] set handle->experimental_features to the value of experimental_features [new feature]
         * [ ] if options is not nullptr [new feature]
           * [ ] set options->experimental_features to the value of experimental_features [existing feature]
    • after this change,
         * [ ] the calculations may depend on options->experimental_features || handle->experimental_features or one of the two (decide on a case-by-case basis)
         * [ ] other things may depend on handle->experimental_features
  • Python API (TBD):
    • add a global function set_experimental_features
         * [ ] this in turn calls PGM_set_experimental_features(handle, nullptr, _ExperimentalFeatures.enabled)
    • setting the experimental_features flag on the _calculate_* functions:
      • setting it to enabled calls PGM_set_experimental_features(handle, options, enabled)
      • setting it to disabled implies set_experimental_features(handle, options, disabled)
      • setting it to None (default) only sets the default Options to disabled: set_experimental_features(None, options, disabled)

NOTE: the Python API behavior is still TBD

TBD

  • The C++ wrapper for the C API uses a handle for every created object. We need to make a decision on how to approach this.
  • The Python API uses one handle and multiple Options. Calling the PGM_set_experimental_features for every Options object would repeatedly enable/disable/enable/disable the settings on the handle. This is not desirable, as it may result in unexpected behavior.

Activity

  1. mgovers commented on Oct 9, 2024

    @mgovers
    MemberAuthor

    This issue is mainly there for future reference. The TBD's are quite difficult to resolve. Closing this issue as wont fix for now

  2. mgovers commented on Jun 11, 2026

    @mgovers
    MemberAuthor

    Since we are once again encountering the necessity for this (see also #1334), should we revisit the decision to not plan this?

    Some points for the rationale:

    1. it's experimental... it may change... there's no backwards compatibility issues as long as PGM_set_experimental_features(handle, options, disabled) results in the same behavior. It's a non-issue.
    2. we're looking to do a major version bump. Now is the time.
    3. the Python library now uses a thread-local handle, rather than one handle for all threads. Parallel testing is no longer an issue. We just need to disable experimental features after a single thread test is done. Some pattern like with experimental_features_enabled(): ... could do the trick
    4. the whole C++ library is officially experimental (although we know of a user that uses this) so we can change the behavior if we need to. The main issue here is how to set experimental features on an object. A potential resolution could be to optionally provide a C++ constructor overload that takes an external handle instead of one that is created internally in the object.

    Any objections to re-opening this?

  3. removed this from the Release 2.0 milestone on Jun 11, 2026
  4. mgovers commented on Jun 11, 2026

    @mgovers
    MemberAuthor

    Closing in favor of #934

  5. moved this from Q3 2026 to No status in Power Grid Modelon Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requestwontfixThis will not be worked on

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions