33import sys
44import torch
55import lightning
6- from .utils import check_consistency
6+ import warnings
7+ from .utils import check_consistency , custom_warning_format
78from .data import PinaDataModule
89from .solver import SolverInterface , PINNInterface
910
11+ # set the warning for compile options
12+ warnings .formatwarning = custom_warning_format
13+ warnings .filterwarnings ("always" , category = UserWarning )
14+
1015
1116class Trainer (lightning .pytorch .Trainer ):
1217 """
@@ -49,7 +54,8 @@ def __init__(
4954 :param float val_size: The percentage of elements to include in the
5055 validation dataset. Default is ``0.0``.
5156 :param bool compile: If ``True``, the model is compiled before training.
52- Default is ``False``. For Windows users, it is always disabled.
57+ Default is ``False``. For Windows users, it is always disabled. Not
58+ supported for python version greater or equal than 3.14.
5359 :param bool repeat: Whether to repeat the dataset data in each
5460 condition during training. For further details, see the
5561 :class:`~pina.data.data_module.PinaDataModule` class. Default is
@@ -104,8 +110,17 @@ def __init__(
104110 super ().__init__ (** kwargs )
105111
106112 # checking compilation and automatic batching
107- if compile is None or sys .platform == "win32" :
113+ # compilation disabled for Windows and for Python 3.14+
114+ if (
115+ compile is None
116+ or sys .platform == "win32"
117+ or sys .version_info >= (3 , 14 )
118+ ):
108119 compile = False
120+ warnings .warn (
121+ "Compilation is disabled for Python 3.14+ and for Windows." ,
122+ UserWarning ,
123+ )
109124
110125 repeat = repeat if repeat is not None else False
111126
@@ -114,7 +129,7 @@ def __init__(
114129 )
115130
116131 # set attributes
117- self .compile = compile
132+ self ._compile = compile
118133 self .solver = solver
119134 self .batch_size = batch_size
120135 self ._move_to_device ()
@@ -325,3 +340,13 @@ def _check_consistency_and_set_defaults(
325340 if batch_size is not None :
326341 check_consistency (batch_size , int )
327342 return pin_memory , num_workers , shuffle , batch_size
343+
344+ @property
345+ def compile (self ):
346+ """
347+ Whether compilation is required or not.
348+
349+ :return: ``True`` if compilation is required, ``False`` otherwise.
350+ :rtype: bool
351+ """
352+ return self ._compile
0 commit comments