(self)
| 39 | class TestThreadContainer(unittest.TestCase): |
| 40 | @SkipIfNoModule("ignite") |
| 41 | def test_container(self): |
| 42 | net = torch.nn.Conv2d(1, 1, 3, padding=1) |
| 43 | |
| 44 | opt = torch.optim.Adam(net.parameters()) |
| 45 | |
| 46 | img = torch.rand(1, 16, 16) |
| 47 | data = {CommonKeys.IMAGE: img, CommonKeys.LABEL: img} |
| 48 | loader = DataLoader([data for _ in range(10)]) |
| 49 | |
| 50 | trainer = SupervisedTrainer( |
| 51 | device=torch.device("cpu"), |
| 52 | max_epochs=1, |
| 53 | train_data_loader=loader, |
| 54 | network=net, |
| 55 | optimizer=opt, |
| 56 | loss_function=torch.nn.L1Loss(), |
| 57 | ) |
| 58 | |
| 59 | con = ThreadContainer(trainer) |
| 60 | con.start() |
| 61 | time.sleep(1) # wait for trainer to start |
| 62 | |
| 63 | self.assertTrue(con.is_alive) |
| 64 | self.assertIsNotNone(con.status()) |
| 65 | self.assertGreater(len(con.status_dict), 0) |
| 66 | |
| 67 | con.join() |
| 68 | |
| 69 | @SkipIfNoModule("ignite") |
| 70 | @SkipIfNoModule("matplotlib") |
nothing calls this directly
no test coverage detected