|
5 | 5 | """ |
6 | 6 |
|
7 | 7 | import logging |
| 8 | +import tempfile |
8 | 9 |
|
9 | 10 | from pathvalidate import ValidationError, validate_filename |
10 | 11 |
|
|
13 | 14 | from dataiku.customrecipe import get_output_names_for_role |
14 | 15 | from dataiku.customrecipe import get_recipe_config |
15 | 16 |
|
16 | | -from cache_utils import CustomTmpFile |
17 | 17 | from xlsx_writer import dataframes_to_xlsx |
18 | 18 |
|
19 | 19 | logger = logging.getLogger(__name__) |
|
50 | 50 | raise ValueError(f"{e}\n") |
51 | 51 |
|
52 | 52 |
|
53 | | -tmp_file_helper = CustomTmpFile() |
54 | | -tmp_file_path = tmp_file_helper.get_temporary_cache_file(output_file_name) |
55 | | -logger.info("Intend to write the output xls file to the following location: {}".format(tmp_file_path)) |
| 53 | +with tempfile.NamedTemporaryFile() as tmp_file: |
| 54 | + tmp_file_path = tmp_file.name |
| 55 | + logger.info("Intend to write the output xls file to the following location: {}".format(tmp_file_path)) |
56 | 56 |
|
57 | | -dataframes_to_xlsx(input_datasets_names, tmp_file_path, lambda name: dataiku.Dataset(name).get_dataframe()) |
| 57 | + dataframes_to_xlsx(input_datasets_names, tmp_file_path, lambda name: dataiku.Dataset(name).get_dataframe()) |
58 | 58 |
|
59 | | -with open(tmp_file_path, 'rb', encoding=None) as f: |
60 | | - output_folder.upload_stream(output_file_name, f) |
| 59 | + with open(tmp_file_path, 'rb', encoding=None) as f: |
| 60 | + output_folder.upload_stream(output_file_name, f) |
61 | 61 |
|
62 | | -tmp_file_helper.destroy_cache() |
63 | 62 |
|
64 | 63 | logger.info("Ended recipe processing.") |
0 commit comments