Skip to content

Conversation

@dario-coscia
Copy link
Collaborator

In this PR the PINA callbacks and related tests are updated.
The Refinment callback is deprecated, see issue #481

"""PINA Callbacks Implementations"""

# To remove once Callbacks are implemented again.
# pylint: disable=W0611
Copy link
Member

Choose a reason for hiding this comment

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

I would remove this for now. Maybe, we will restore them in the future but for now I would keep all the warnings

self._new_optimizers = new_optimizers
self._epoch_switch = epoch_switch

# pylint: disable=W0212
Copy link
Member

Choose a reason for hiding this comment

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

Also here! I suggest to remove this

for idx, optim in enumerate(self._new_optimizers):
optim.hook(trainer.solver.models[idx].parameters())
optims.append(optim.instance)
optim.hook(trainer.solver._pina_models[idx].parameters())
Copy link
Member

Choose a reason for hiding this comment

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

We are accessing a private member of the solver class. Isn't a cleaner way to do the same thing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope, this is the only way to work for all solvers.

Copy link
Collaborator

@GiovanniCanali GiovanniCanali left a comment

Choose a reason for hiding this comment

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

Thank you, @dario-coscia, for fixing the callbacks. Code looks good to me!

While I believe the docstrings will be addresses in the corresponding PR, I am leaving some comments to point out some minor inconsistencies.

I am also committing some small rephrasing modifications and typos corrections.

"""
Lightning Callback for Metric Tracking.
Tracks specific metrics during the training process.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest to move the description of callbacks to the class docstring, and fill the docstring of __init__ methods with brief sentences, such as "Initialization" for instance. What do you think?

:param metrics_to_track: List of metrics to track. Defaults to train/val loss.
:param metrics_to_track: List of metrics to track.
Defaults to train loss.
:type metrics_to_track: list, optional
Copy link
Collaborator

Choose a reason for hiding this comment

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

In some cases, the type list is used generically, while in others, the specific types of instances within the list are explicitly defined. What convention should we follow?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank! You are right it should be list of str

@ndem0
Copy link
Member

ndem0 commented Mar 12, 2025

Can we merge?

@FilippoOlivo
Copy link
Member

Ok for me!

@dario-coscia dario-coscia force-pushed the 0.2 branch 2 times, most recently from 1f54775 to 795e4a4 Compare March 12, 2025 18:40
@dario-coscia
Copy link
Collaborator Author

Yes!

@GiovanniCanali
Copy link
Collaborator

Ready to merge!

@FilippoOlivo FilippoOlivo force-pushed the 0.2 branch 3 times, most recently from 7eec394 to 795e4a4 Compare March 13, 2025 13:11
@FilippoOlivo FilippoOlivo merged commit 89259b6 into 0.2 Mar 13, 2025
16 of 17 checks passed
@dario-coscia dario-coscia deleted the callbacks branch March 17, 2025 14:13
ndem0 pushed a commit that referenced this pull request Mar 19, 2025
---------

Co-authored-by: giovanni <[email protected]>
FilippoOlivo pushed a commit to FilippoOlivo/PINA that referenced this pull request Mar 21, 2025
FilippoOlivo pushed a commit to FilippoOlivo/PINA that referenced this pull request Apr 17, 2025
dario-coscia added a commit that referenced this pull request Apr 17, 2025
---------

Co-authored-by: giovanni <[email protected]>
GiovanniCanali added a commit to GiovanniCanali/PINA that referenced this pull request Dec 2, 2025
GiovanniCanali added a commit to GiovanniCanali/PINA that referenced this pull request Dec 2, 2025
GiovanniCanali added a commit to GiovanniCanali/PINA that referenced this pull request Dec 2, 2025
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.

5 participants