get_trial_dir#

TrainContext.get_trial_dir() → str[source]#

Log directory corresponding to the trial directory for a Tune session. If calling from a Train session, this will give the trial directory of its parent Tune session.

Examples

>>> import ray.tune
>>> def train_func(config):
...     print(ray.tune.get_context().get_trial_dir())
>>> tuner = ray.tune.Tuner(train_func)
>>> tuner.fit()
/Users/root/ray_results/train_func_2023-07-19_15-01-37/train_func_d620c_00000_0_2023-07-19_15-01-40
Returns:

The trial directory path, or None if called outside a Ray Train or Ray Tune function.

Return type:

str

PublicAPI (beta): This API is in beta and may change before becoming stable.

Warning

DEPRECATED: This API is deprecated and may be removed in future Ray releases. get_trial_dir is deprecated because the concept of a Trial will soon be removed in Ray Train.Ray Train will no longer assume that it’s running within a Ray Tune Trial in the future. See this issue for more context and migration options: ray-project/ray#49454. Disable these warnings by setting the environment variable: RAY_TRAIN_ENABLE_V2_MIGRATION_WARNINGS=0