def test_run_manager_init(empty_creds_db, empty_creds_fs, inputs, expected): with RunManager(database=empty_creds_db, file_store=empty_creds_fs, algorithm_name="fake", algorithm_version="1.1.1", inputs=inputs) as run: assert run._inputs == expected
def test_make_serializable_type( empty_creds_db, empty_creds_fs, data_dir, example_audio ): # Test with real path with RunManager( database=empty_creds_db, file_store=empty_creds_fs, algorithm_name="fake", algorithm_version="1.1.1", inputs=[example_audio], ) as run: # Can't use PosixPath because if testing is done on windows then this fails for i in run._input_files: assert "Path" in i.type assert isinstance(i.value, Path) # Test with non existent path with pytest.raises(FileNotFoundError): run = RunManager( database=empty_creds_db, file_store=empty_creds_fs, algorithm_name="fake", algorithm_version="1.1.1", inputs=[Path("/this/will/fail.mp4")], ) # Test with directory with pytest.raises(IsADirectoryError): run = RunManager( database=empty_creds_db, file_store=empty_creds_fs, algorithm_name="fake", algorithm_version="1.1.1", inputs=[data_dir], ) # With any other type with RunManager( database=empty_creds_db, file_store=empty_creds_fs, algorithm_name="fake", algorithm_version="1.1.1", inputs=[((str(tuple), ("this", "will", "be", "cast", "to", "string")))], ) as run: assert run._inputs == [ RunIO(str(tuple), "('this', 'will', 'be', 'cast', 'to', 'string')") ]
def test_run_manager_safe_exit(empty_creds_db, empty_creds_fs): with RunManager( database=empty_creds_db, file_store=empty_creds_fs, algorithm_name="fake", algorithm_version="1.1.1", ) as run: run.register_output(1)
def test_run_manager_failed_exit(empty_creds_db, empty_creds_fs): # Generate exception log with pytest.raises(AssertionError): with RunManager(database=empty_creds_db, file_store=empty_creds_fs, algorithm_name="fake", algorithm_version="1.1.1"): assert False # Check exception log exists logs = list(Path(".").glob("exception_log_*.err")) assert len(logs) == 1 # Clean up exception log for log in logs: log.unlink()