Skip to content

[df] Avoid side-effects if external package interacts with distribute… - #23164

Merged
vepadulano merged 1 commit into
root-project:masterfrom
vepadulano:gh-23072
Aug 28, 2026
Merged

vepadulano merged 1 commit into
root-project:masterfrom
vepadulano:gh-23072

Conversation

@vepadulano

Copy link
Copy Markdown
Member

…d module at exit time

The distributed RDataFrame Python module raises a warning to let users know it has been moved out of the Experimental namespace. This was implemented by creating a dummy Python class type that injects the warning at __getattribute__ time and using that class as the class of the injected distributed module when the user accesses it via Experimental.

That implementation may have undesired interactions in extreme edge-cases. For example, if a third-party library accesses available Python modules during the session and inspects them, the distributed Python module warning could be triggered. One notable example are the XRootD Python bindings. The client module of this package registers a function with atexit. At exit time, that function accesses all objects available to the garbage collector, which includes all Python modules (even external to XRootD itself). See the implementation at:

https://github.com/xrootd/xrootd/blob/v6.1.1/python/libs/client/finalize.py

While accessing all these objects, XRootD is also accessing ROOT modules if ROOT was imported in the same application. As such, the dummy class behaviour explained above kicked in.

This commit proposes to change the implementation that raises the warning to use a mechanism based on function decorators. The downside is a few more lines of code: every function supposed to be accessed publicly of the distributed module must be decorated so that the warning is raised before the function runs if the user is accessing it via Experimental. The upside is avoiding the scenario described above and having the warning raised right at the point of calling the function rather than slightly earlier during module attribute access.

This Pull request:

Changes or fixes:

Fixes #23072

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes #

…d module at exit time

The distributed RDataFrame Python module raises a warning to let users know it
has been moved out of the `Experimental` namespace. This was implemented by
creating a dummy Python class type that injects the warning at
`__getattribute__` time and using that class as the class of the injected
distributed module when the user accesses it via `Experimental`.

That implementation may have undesired interactions in extreme edge-cases. For
example, if a third-party library accesses available Python modules during the
session and inspects them, the distributed Python module warning could be
triggered. One notable example are the XRootD Python bindings. The `client`
module of this package registers a function with `atexit`. At exit time, that
function accesses all objects available to the garbage collector, which includes
all Python modules (even external to XRootD itself). See the implementation at:

https://github.com/xrootd/xrootd/blob/v6.1.1/python/libs/client/finalize.py

While accessing all these objects, XRootD is also accessing ROOT modules if ROOT
was imported in the same application. As such, the dummy class behaviour
explained above kicked in.

This commit proposes to change the implementation that raises the warning to use
a mechanism based on function decorators. The downside is a few more lines of
code: every function supposed to be accessed publicly of the distributed module
must be decorated so that the warning is raised before the function runs if the
user is accessing it via `Experimental`. The upside is avoiding the scenario
described above and having the warning raised right at the point of calling the
function rather than slightly earlier during module attribute access.

Co-authored-by: Silia Taider <silia.taider@cern.ch>
@github-actions

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 15h 33m 12s ⏱️
 3 860 tests  3 858 ✅ 0 💤 2 ❌
79 521 runs  79 516 ✅ 2 💤 3 ❌

For more details on these failures, see this check.

Results for commit 4b8ae87.

@vepadulano
vepadulano requested a review from hageboeck August 27, 2026 15:19
@dpiparo

dpiparo commented Aug 28, 2026

Copy link
Copy Markdown
Member

to be backported to 6.40 for 6.40.06?

@vepadulano
vepadulano merged commit 1b4787d into root-project:master Aug 28, 2026
31 of 38 checks passed
@vepadulano

Copy link
Copy Markdown
Member Author

/backport to 6.40

@root-project-bot

Copy link
Copy Markdown

Preparing to backport PR #23164 to branch 6.40 requested by vepadulano

@root-project-bot

Copy link
Copy Markdown

Something went wrong with the creation of the PR to backport to 6.40: @vepadulano please see the logs

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.

Noisy warnings when using Experimental features

3 participants