|
| 1 | +""" |
| 2 | +You can execute this pipeline by: |
| 3 | +
|
| 4 | + python examples/04-catalog/catalog_python.py |
| 5 | +""" |
| 6 | + |
| 7 | +from examples.common.functions import check_files_do_not_exist, write_files |
| 8 | +from runnable import Catalog, Pipeline, PythonTask, ShellTask |
| 9 | + |
| 10 | + |
| 11 | +def main(): |
| 12 | + write_catalog = Catalog(put=["df.csv", "data_folder/data.txt"], store_copy=False) |
| 13 | + generate_data = PythonTask( |
| 14 | + name="generate_data_python", |
| 15 | + function=write_files, |
| 16 | + catalog=write_catalog, |
| 17 | + ) |
| 18 | + |
| 19 | + delete_files_command = """ |
| 20 | + rm df.csv || true && \ |
| 21 | + rm data_folder/data.txt || true |
| 22 | + """ |
| 23 | + # delete from local files after generate |
| 24 | + # since its local catalog, we delete to show "get from catalog" |
| 25 | + delete_local_after_generate = ShellTask( |
| 26 | + name="delete_after_generate", |
| 27 | + command=delete_files_command, |
| 28 | + ) |
| 29 | + |
| 30 | + # Since store_copy was set to False, this step should fail |
| 31 | + check_files_do_not_exist_task = PythonTask( |
| 32 | + name="check_files_do_not_exist", |
| 33 | + function=check_files_do_not_exist, |
| 34 | + terminate_with_success=True, |
| 35 | + ) |
| 36 | + |
| 37 | + pipeline = Pipeline( |
| 38 | + steps=[ |
| 39 | + generate_data, |
| 40 | + delete_local_after_generate, |
| 41 | + check_files_do_not_exist_task, |
| 42 | + ] |
| 43 | + ) |
| 44 | + _ = pipeline.execute() |
| 45 | + |
| 46 | + return pipeline |
| 47 | + |
| 48 | + |
| 49 | +if __name__ == "__main__": |
| 50 | + main() |
0 commit comments