Skip to content

Conversation

@FrancoisPgm
Copy link

Remove the CallbackContext's _depth property, as it can easily be obtained as len(_get_task_info_path(self.task_info)).

@github-actions
Copy link

github-actions bot commented Sep 19, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: ff69339. Link to the linter CI: here

Comment on lines 200 to 202
depth = len(_get_task_info_path(task_info)) - 1
indent = f"{' ' * depth}"
style = f"[{colors[(depth) % len(colors)]}]"
Copy link
Owner

Choose a reason for hiding this comment

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

I'd like to avoid calling _get_task_info_path because it will be called for each node while we could build the depth during the tree building.

Let's define a depth attribute at init time as self.depth = 0 if parent is None else parent.depth + 1.

import pytest

from sklearn.callback._callback_context import CallbackContext
from sklearn.callback._progressbar import _get_task_info_path
Copy link
Owner

Choose a reason for hiding this comment

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

Since we need it for metric monitor as well, let's directly move it in callback_context. Importing it from progressbar in test_callback_context feels off

…d move _get_task_info_path to _callback_context.py
@jeremiedbb jeremiedbb merged commit 12b921f into jeremiedbb:base_callbacks_2 Sep 23, 2025
13 of 16 checks passed
@FrancoisPgm FrancoisPgm deleted the remove_depth_prop branch September 23, 2025 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants