Skip to content

Commit

Permalink
empty_ok=False arg
Browse files Browse the repository at this point in the history
  • Loading branch information
vict0rsch committed Feb 21, 2024
1 parent 5ec0c3d commit be0206d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gflownet/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ def load_gflow_net_from_run_path(
print_config=False,
device="cuda",
load_final_ckpt=True,
empty_ok=False,
):
"""
Load GFlowNet from a run path (directory with a `.hydra` directory inside).
Expand All @@ -326,11 +327,18 @@ def load_gflow_net_from_run_path(
Device to which the models should be moved, by default "cuda".
load_final_ckpt : bool, optional
Whether to load the final models, by default True.
empty_ok : bool, optional
Whether to allow the checkpoints directory to be empty, by default False.
Returns
-------
Tuple[GFN, DictConfig]
Loaded GFlowNet and the loaded config.
Raises
------
ValueError
If no checkpoints are found in the directory.
"""
run_path = resolve_path(run_path)
hydra_dir = run_path / ".hydra"
Expand Down Expand Up @@ -375,6 +383,8 @@ def load_gflow_net_from_run_path(
)

if forward_final is None and backward_final is None:
if not empty_ok:
raise ValueError("No checkpoints found in", str(ckpt_dir))
print("Warning: no checkpoints found in", str(ckpt_dir))

return gflownet, config
Expand Down

0 comments on commit be0206d

Please sign in to comment.