Skip to content

Conversation

@FrancoisPgm
Copy link

Reference Issues/PRs

What does this implement/fix? Explain your changes.

Since both the CallbackContext and the TaskNode classes track the same tree structure, the attributes and methods of the TaskNode can be moved to the CallbackContext to simplify the code structure.

A new _to_dict method is added to the CallbackContext to have a dictionary representation of the instance so it can be safely passed to the Callback's on_fit_iter_end and on_fit_end methods instead of the whole CallbackContext object.

Any other comments?

@FrancoisPgm FrancoisPgm changed the base branch from master to base_callbacks_2 September 9, 2025 12:39
Copy link
Owner

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

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

A first round of comments. Implementation looks good. Now that both task nodes and callback context are merged together, we need to unify the vocabulary that we use. There are areas where we talk about task nodes and others where we talk about contexts. I think that we want to keep the notion of task around but we need to clarify somewhere that a callback context object describes the context of a task for instance.

i = 0
while True:
subcontext = callback_ctx.subcontext(task_id=i, max_tasks=None)
subcontext = callback_ctx.subcontext(task_id=i)
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure that None meaning "unknown" is a good idea. Maybe better to be more explicit and use "unknown" ?
Also undecided if it should have a default or should be a required parameter.

Copy link
Author

Choose a reason for hiding this comment

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

I don't have a strong opinion, but I think max_subtasks=None easily conveys the idea "there is no defined maximum, so you can add any number of subtasks".

@github-actions
Copy link

✔️ Linting Passed

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

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

Copy link
Owner

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

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

Alright let's merge. There are a few places where the doc is unclear between context, task and iter, but I'll iterate on the original PR to unify it properly.

@jeremiedbb jeremiedbb merged commit 8a291e5 into jeremiedbb:base_callbacks_2 Sep 11, 2025
15 of 16 checks passed
@FrancoisPgm FrancoisPgm deleted the Callback branch September 11, 2025 12:25
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