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,18 @@ def __init__(
104110 super ().__init__ (** kwargs )
105111
106112 # checking compilation and automatic batching
107- if compile is None or sys .platform == "win32" :
113+ # compile disambled for windows and py>=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 versions >= 3.14. "
122+ "Compilation is also disabled for Windows 3.2." ,
123+ UserWarning ,
124+ )
109125
110126 repeat = repeat if repeat is not None else False
111127
@@ -114,7 +130,7 @@ def __init__(
114130 )
115131
116132 # set attributes
117- self .compile = compile
133+ self ._compile = compile
118134 self .solver = solver
119135 self .batch_size = batch_size
120136 self ._move_to_device ()
@@ -325,3 +341,7 @@ def _check_consistency_and_set_defaults(
325341 if batch_size is not None :
326342 check_consistency (batch_size , int )
327343 return pin_memory , num_workers , shuffle , batch_size
344+
345+ @property
346+ def compile (self ):
347+ return self ._compile
0 commit comments