Skip to content

Commit 9f6063b

Browse files
committed
disable trainer prog bar for test of model checkpoint on exception
1 parent d4d933b commit 9f6063b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tests/tests_pytorch/checkpointing/test_model_checkpoint.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ def training_step(self, batch, batch_idx):
773773

774774
model = TroubledModel()
775775
checkpoint_callback = ModelCheckpoint(dirpath=tmp_path, filename="{step}", save_on_exception=True, every_n_epochs=4)
776-
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback], max_epochs=5, logger=False)
776+
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback], max_epochs=5, logger=False, enable_progress_bar=False)
777777
with pytest.raises(RuntimeError, match="Trouble!"):
778778
trainer.fit(model)
779779
print(os.listdir(tmp_path))
@@ -789,7 +789,7 @@ def validation_step(self, batch, batch_idx):
789789
model = TroubledModel()
790790
epoch_length = 64
791791
checkpoint_callback = ModelCheckpoint(dirpath=tmp_path, filename="{step}", save_on_exception=True, every_n_epochs=4)
792-
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback], max_epochs=5, logger=False)
792+
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback], max_epochs=5, logger=False, enable_progress_bar=False)
793793
with pytest.raises(RuntimeError, match="Trouble!"):
794794
trainer.fit(model)
795795
assert os.path.isfile(tmp_path / f"step={epoch_length}.ckpt")
@@ -804,7 +804,7 @@ def on_train_batch_start(self, trainer, pl_module, batch, batch_idx):
804804

805805
model = BoringModel()
806806
checkpoint_callback = ModelCheckpoint(dirpath=tmp_path, filename="{step}", save_on_exception=True, every_n_epochs=4)
807-
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnTrainBatchStart()], max_epochs=5, logger=False)
807+
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnTrainBatchStart()], max_epochs=5, logger=False, enable_progress_bar=False)
808808
with pytest.raises(RuntimeError, match="Trouble!"):
809809
trainer.fit(model)
810810
assert os.path.isfile(tmp_path / "step=1.ckpt")
@@ -819,7 +819,7 @@ def on_train_batch_end(self, trainer, pl_module, outputs, batch, batch_idx):
819819

820820
model = BoringModel()
821821
checkpoint_callback = ModelCheckpoint(dirpath=tmp_path, filename="{step}", save_on_exception=True, every_n_epochs=4)
822-
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnTrainBatchEnd()], max_epochs=5, logger=False)
822+
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnTrainBatchEnd()], max_epochs=5, logger=False, enable_progress_bar=False)
823823
with pytest.raises(RuntimeError, match="Trouble!"):
824824
trainer.fit(model)
825825

@@ -836,7 +836,7 @@ def on_train_epoch_start(self, trainer, pl_module):
836836
model = BoringModel()
837837
epoch_length = 64
838838
checkpoint_callback = ModelCheckpoint(dirpath=tmp_path, filename="{step}", save_on_exception=True, every_n_epochs=4)
839-
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnTrainEpochStart()], max_epochs=5, logger=False)
839+
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnTrainEpochStart()], max_epochs=5, logger=False, enable_progress_bar=False)
840840
with pytest.raises(RuntimeError, match="Trouble!"):
841841
trainer.fit(model)
842842
assert os.path.isfile(tmp_path / f"step={epoch_length}.ckpt")
@@ -852,7 +852,7 @@ def on_train_epoch_end(self, trainer, pl_module):
852852
model = BoringModel()
853853
epoch_length = 64
854854
checkpoint_callback = ModelCheckpoint(dirpath=tmp_path, filename="{step}", save_on_exception=True, every_n_epochs=4)
855-
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnTrainEpochEnd()], max_epochs=5, logger=False)
855+
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnTrainEpochEnd()], max_epochs=5, logger=False, enable_progress_bar=False)
856856
with pytest.raises(RuntimeError, match="Trouble!"):
857857
trainer.fit(model)
858858
assert os.path.isfile(tmp_path / f"step={2*epoch_length}.ckpt")
@@ -868,7 +868,7 @@ def on_validation_batch_start(self, trainer, pl_module, batch, batch_idx):
868868
model = BoringModel()
869869
epoch_length = 64
870870
checkpoint_callback = ModelCheckpoint(dirpath=tmp_path, filename="{step}", save_on_exception=True, every_n_epochs=4)
871-
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnValidationBatchStart()], max_epochs=5, logger=False)
871+
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnValidationBatchStart()], max_epochs=5, logger=False, enable_progress_bar=False)
872872
with pytest.raises(RuntimeError, match="Trouble!"):
873873
trainer.fit(model)
874874
assert os.path.isfile(tmp_path / f"step={epoch_length}.ckpt")
@@ -884,7 +884,7 @@ def on_validation_batch_end(self, trainer, pl_module, outputs, batch, batch_idx)
884884
model = BoringModel()
885885
epoch_length = 64
886886
checkpoint_callback = ModelCheckpoint(dirpath=tmp_path, filename="{step}", save_on_exception=True, every_n_epochs=4)
887-
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnValidationBatchEnd()], max_epochs=5, logger=False)
887+
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnValidationBatchEnd()], max_epochs=5, logger=False, enable_progress_bar=False)
888888
with pytest.raises(RuntimeError, match="Trouble!"):
889889
trainer.fit(model)
890890
assert os.path.isfile(tmp_path / f"step={epoch_length}.ckpt")
@@ -900,7 +900,7 @@ def on_validation_epoch_start(self, trainer, pl_module):
900900
model = BoringModel()
901901
epoch_length = 64
902902
checkpoint_callback = ModelCheckpoint(dirpath=tmp_path, filename="{step}", save_on_exception=True, every_n_epochs=4)
903-
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnValidationEpochStart()], max_epochs=5, logger=False)
903+
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnValidationEpochStart()], max_epochs=5, logger=False, enable_progress_bar=False)
904904
with pytest.raises(RuntimeError, match="Trouble!"):
905905
trainer.fit(model)
906906
assert os.path.isfile(tmp_path / f"step={epoch_length}.ckpt")
@@ -916,7 +916,7 @@ def on_validation_epoch_end(self, trainer, pl_module):
916916
model = BoringModel()
917917
epoch_length = 64
918918
checkpoint_callback = ModelCheckpoint(dirpath=tmp_path, filename="{step}", save_on_exception=True, every_n_epochs=4)
919-
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnValidationEpochEnd()], max_epochs=5, logger=False)
919+
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnValidationEpochEnd()], max_epochs=5, logger=False, enable_progress_bar=False)
920920
with pytest.raises(RuntimeError, match="Trouble!"):
921921
trainer.fit(model)
922922
assert os.path.isfile(tmp_path / f"step={epoch_length}.ckpt")
@@ -931,7 +931,7 @@ def on_validation_start(self, trainer, pl_module):
931931
model = BoringModel()
932932
epoch_length = 64
933933
checkpoint_callback = ModelCheckpoint(dirpath=tmp_path, filename="{step}", save_on_exception=True, every_n_epochs=4)
934-
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnValidationStart()], max_epochs=5, logger=False)
934+
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnValidationStart()], max_epochs=5, logger=False, enable_progress_bar=False)
935935
with pytest.raises(RuntimeError, match="Trouble!"):
936936
trainer.fit(model)
937937
assert os.path.isfile(tmp_path / f"step={epoch_length}.ckpt")
@@ -946,7 +946,7 @@ def on_validation_end(self, trainer, pl_module):
946946
model = BoringModel()
947947
epoch_length = 64
948948
checkpoint_callback = ModelCheckpoint(dirpath=tmp_path, filename="{step}", save_on_exception=True, every_n_epochs=4)
949-
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnValidationEnd()], max_epochs=5, logger=False)
949+
trainer = Trainer(default_root_dir=tmp_path, callbacks=[checkpoint_callback, TroublemakerOnValidationEnd()], max_epochs=5, logger=False, enable_progress_bar=False)
950950
with pytest.raises(RuntimeError, match="Trouble!"):
951951
trainer.fit(model)
952952
assert os.path.isfile(tmp_path / f"step={epoch_length}.ckpt")

0 commit comments

Comments
 (0)