Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion benchmarl/experiment/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,9 @@ def _load_experiment(self) -> Experiment:
return self

@staticmethod
def reload_from_file(restore_file: str) -> Experiment:
def reload_from_file(
restore_file: str, experiment_patch: Optional[Dict[str, Any]] = None
) -> Experiment:
"""
Restores the experiment from the checkpoint file.

Expand All @@ -1016,6 +1018,7 @@ def reload_from_file(restore_file: str) -> Experiment:

Args:
restore_file (str): The checkpoint file (.pt) of the experiment reload.
experiment_patch (Optional[Dict[str, Any]]): The patch to apply to the experiment config.

Returns:
The reloaded experiment.
Expand All @@ -1035,7 +1038,13 @@ def reload_from_file(restore_file: str) -> Experiment:
critic_model_config = pickle.load(f)
callbacks = pickle.load(f)
task.config = task_config
experiment_config.save_folder = experiment_folder.parent
experiment_config.restore_file = restore_file
if experiment_patch is not None:
for key, value in experiment_patch.items():
if not hasattr(experiment_config, key):
raise ValueError(f"Experiment config does not have attribute {key}")
setattr(experiment_config, key, value)
experiment = Experiment(
task=task,
algorithm_config=algorithm_config,
Expand Down
Loading