From d339212f3c566c9e42e1126bfaeed74beeff1a82 Mon Sep 17 00:00:00 2001 From: Ben Weinstein Date: Sun, 15 Aug 2021 07:04:55 -0700 Subject: [PATCH] close stale issues --- .github/workflows/stale.yml | 19 +++++++++++++++++++ tests/test_main.py | 20 +++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 00000000..3f0088ea --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,19 @@ +name: Close inactive issues +on: + schedule: + - cron: "30 1 * * *" + +jobs: + close-issues: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v3 + with: + days-before-issue-stale: 30 + days-before-issue-close: 14 + stale-issue-label: "stale" + stale-issue-message: "This issue is stale because it has been open for 30 days with no activity." + close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale." + days-before-pr-stale: -1 + days-before-pr-close: -1 + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/tests/test_main.py b/tests/test_main.py index 02a577af..99256503 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -226,7 +226,7 @@ def on_train_end(self, trainer, pl_module): trainer = Trainer(fast_dev_run=True) trainer.fit(m, train_ds) -def test_save_and_reload(m, tmpdir): +def test_save_and_reload_checkpoint(m, tmpdir): img_path = get_data(path="2019_YELL_2_528000_4978000_image_crop2.png") m.config["train"]["fast_dev_run"] = True m.create_trainer() @@ -243,6 +243,24 @@ def test_save_and_reload(m, tmpdir): assert not pred_after_reload.empty pd.testing.assert_frame_equal(pred_after_train,pred_after_reload) +def test_save_and_reload_weights(m, tmpdir): + img_path = get_data(path="2019_YELL_2_528000_4978000_image_crop2.png") + m.config["train"]["fast_dev_run"] = True + m.create_trainer() + #save the prediction dataframe after training and compare with prediction after reload checkpoint + m.trainer.fit(m) + pred_after_train = m.predict_image(path = img_path) + torch.save(m.model.state_dict(),"{}/checkpoint.pt".format(tmpdir)) + + #reload the checkpoint to model object + after = main.deepforest() + after.model.load_state_dict(torch.load("{}/checkpoint.pt".format(tmpdir))) + pred_after_reload = after.predict_image(path = img_path) + + assert not pred_after_train.empty + assert not pred_after_reload.empty + pd.testing.assert_frame_equal(pred_after_train,pred_after_reload) + def test_reload_multi_class(two_class_m, tmpdir): two_class_m.config["train"]["fast_dev_run"] = True two_class_m.create_trainer()