Skip to content

Commit

Permalink
Added more error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
annaelisalappe committed Dec 13, 2024
1 parent 54bba46 commit 81462d3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/itwinai/torch/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1423,13 +1423,14 @@ def _set_tune_config(self) -> None:
metric=metric,
mode=mode,
)
except AttributeError:
except AttributeError as e:
print(
"Could not set Tune Config. Please ensure that you have passed the "
"correct arguments for it. You can find more information for which "
"arguments to set at "
"https://docs.ray.io/en/latest/tune/api/doc/ray.tune.TuneConfig.html."
)
print(e)

def _set_scaling_config(self) -> None:
scaling_config = self.config.get("scaling_config", {})
Expand All @@ -1439,13 +1440,14 @@ def _set_scaling_config(self) -> None:

try:
self.scaling_config = ray.train.ScalingConfig(**scaling_config)
except AttributeError:
except AttributeError as e:
print(
"Could not set Scaling Config. Please ensure that you have passed the "
"correct arguments for it. You can find more information for which "
"arguments to set at "
"https://docs.ray.io/en/latest/train/api/doc/ray.train.ScalingConfig.html"
)
print(e)

def _set_run_config(self) -> None:
run_config = self.config.get("run_config", {})
Expand All @@ -1463,13 +1465,14 @@ def _set_run_config(self) -> None:
storage_path = Path("ray_checkpoints").resolve()

self.run_config = ray.train.RunConfig(**run_config, storage_path=storage_path)
except AttributeError:
except AttributeError as e:
print(
"Could not set Run Config. Please ensure that you have passed the "
"correct arguments for it. You can find more information for which "
"arguments to set at "
"https://docs.ray.io/en/latest/train/api/doc/ray.train.RunConfig.html"
)
print(e)

def _set_train_loop_config(self) -> None:
train_loop_config = self.config.get("train_loop_config", {})
Expand All @@ -1487,12 +1490,13 @@ def _set_train_loop_config(self) -> None:
param = getattr(tune, param_type)(**param)
train_loop_config[name] = param

except AttributeError:
except AttributeError as e:
print(
f"{param} could not be set. Check that this parameter type is "
"supported by Ray Tune at "
"https://docs.ray.io/en/latest/tune/api/search_space.html"
)
print(e)
else:
print(
"WARNING: No training_loop_config detected. "
Expand Down
8 changes: 5 additions & 3 deletions src/itwinai/torch/tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,14 @@ def get_raytune_search_alg(
"INFO: No search algorithm detected. Using Ray Tune BasicVariantGenerator."
)
return None
except AttributeError:
except AttributeError as e:
print(
"Invalid search algorithm configuration passed. Please make sure that the search "
"algorithm you are using has the correct attributes. You can read more about the "
"different search algorithms supported by Ray Tune at "
"https://docs.ray.io/en/latest/tune/api/suggestion.html."
"https://docs.ray.io/en/latest/tune/api/suggestion.html. "
)
print(e)


def get_raytune_scheduler(
Expand Down Expand Up @@ -145,10 +146,11 @@ def get_raytune_scheduler(
"INFO: No search algorithm detected. Using default Ray Tune FIFOScheduler."
)
return None
except AttributeError:
except AttributeError as e:
print(
"Invalid scheduler configuration passed. Please make sure that the scheduler "
"you are using has the correct attributes. You can read more about the "
"different schedulers supported by Ray Tune at "
"https://docs.ray.io/en/latest/tune/api/schedulers.html."
)
print(e)

0 comments on commit 81462d3

Please sign in to comment.