Skip to content

Commit a73e592

Browse files
authored
Merge pull request #3 from dataiku/chore/use-tmp-directory
Replace the custom cache module with Python's tempfile library
2 parents 135d368 + d6ad71d commit a73e592

4 files changed

Lines changed: 11 additions & 58 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## [Version 1.1.1](https://github.com/dataiku/dss-plugin-multisheet-excel-export/releases/tag/v1.1.0) - Chore release - 2023-08
4+
- Use python library to create temp file instead of a custom cache
5+
36
## [Version 1.1.0](https://github.com/dataiku/dss-plugin-multisheet-excel-export/releases/tag/v1.1.0) - New hotfix release - 2023-08
47
- Updated plugin to python 3.7, 3.8, 3.9, 3.10, 3.11
58

custom-recipes/to-excel/recipe.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
import logging
8+
import tempfile
89

910
from pathvalidate import ValidationError, validate_filename
1011

@@ -13,7 +14,6 @@
1314
from dataiku.customrecipe import get_output_names_for_role
1415
from dataiku.customrecipe import get_recipe_config
1516

16-
from cache_utils import CustomTmpFile
1717
from xlsx_writer import dataframes_to_xlsx
1818

1919
logger = logging.getLogger(__name__)
@@ -50,15 +50,14 @@
5050
raise ValueError(f"{e}\n")
5151

5252

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))
5656

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())
5858

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)
6161

62-
tmp_file_helper.destroy_cache()
6362

6463
logger.info("Ended recipe processing.")

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id" : "multisheet-excel-export",
3-
"version" : "1.1.0",
3+
"version" : "1.1.1",
44

55

66
"meta" : {

python-lib/cache_utils.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)