diff --git a/tests/example_script.py b/tests/example_script.py index c8bc616..1815c02 100644 --- a/tests/example_script.py +++ b/tests/example_script.py @@ -30,10 +30,12 @@ def main(*args): print(args) + def process(batch, *args): # process function for grid wrapper print('Execute batch:', batch) main(batch, *args, input_path, batch_size, debug, output_path) + if __name__ == '__main__': main(input_path, batch_size, debug, output_path) diff --git a/tests/test_compiler.py b/tests/test_compiler.py index 703b1eb..c94121c 100644 --- a/tests/test_compiler.py +++ b/tests/test_compiler.py @@ -119,3 +119,40 @@ def test_create_operator( file = Path(file_path) file.with_suffix('.yaml').unlink() file.with_suffix('.job.yaml').unlink() + # TODO: Add tests for the created container image + + +test_create_gridwrapper_input = [ + ( + TEST_NOTEBOOK_PATH, + DUMMY_REPO, + 'your_function', + [], + ), + ( + TEST_SCRIPT_PATH, + DUMMY_REPO, + 'process', + [TEST_NOTEBOOK_PATH], + ) +] +@pytest.mark.parametrize( + "file_path, repository, process, args", + test_create_gridwrapper_input, +) +def test_create_gridwrapper( + file_path: str, + repository: str, + process: str, + args: List, +): + subprocess.run(['python', '../src/c3/create_gridwrapper.py', file_path, *args, + '-r', repository, '-p', process], check=True) + + file = Path(file_path) + gw_file = file.parent / f'gw_{file.stem}.py' + + gw_file.with_suffix('.yaml').unlink() + gw_file.with_suffix('.job.yaml').unlink() + gw_file.unlink() + # TODO: Add tests for the created container image \ No newline at end of file