-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change --load_best=true to fail if checkpoint does not exist.
Also adjust it to support loading checkpoint with arbitrary name in the checkpoint directory even if last.ckpt doesn't exist.
- Loading branch information
Showing
4 changed files
with
124 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import pathlib | ||
import shutil | ||
from typing import Any | ||
|
||
import pytest | ||
from upath import UPath | ||
|
||
from rslp.utils.rslearn import run_model_predict | ||
|
||
|
||
def test_error_if_no_checkpoint(tmp_path: pathlib.Path, monkeypatch: Any) -> None: | ||
"""Verify that an error is raised if --load_best=true with no checkpoint.""" | ||
# We need to use some config for this, so here we use the landsat_vessels one. | ||
model_config_fname = "data/landsat_vessels/config_detector.yaml" | ||
ds_config_fname = "data/landsat_vessels/predict_dataset_config.json" | ||
|
||
# Copy the config.json so that the dataset is valid. | ||
shutil.copyfile(ds_config_fname, tmp_path / "config.json") | ||
(tmp_path / "windows" / "default").mkdir(parents=True) | ||
|
||
# Overwrite RSLP_PREFIX to ensure the checkpoint won't exist. | ||
monkeypatch.setenv("RSLP_PREFIX", str(tmp_path)) | ||
|
||
with pytest.raises(FileNotFoundError): | ||
run_model_predict(model_config_fname, UPath(tmp_path)) |