diff --git a/flytekit/core/data_persistence.py b/flytekit/core/data_persistence.py index cd4ffd1619..e24febefef 100644 --- a/flytekit/core/data_persistence.py +++ b/flytekit/core/data_persistence.py @@ -22,10 +22,10 @@ """ -import datetime import os import pathlib import re +import tempfile import typing from abc import abstractmethod from distutils import dir_util @@ -448,11 +448,9 @@ def put_data(self, local_path: Union[str, os.PathLike], remote_path: str, is_mul DataPersistencePlugins.register_plugin("file://", DiskPersistence) DataPersistencePlugins.register_plugin("/", DiskPersistence) -tmp_dir_prefix = f"{os.sep}tmp{os.sep}flyte" - -tmp_dir = os.path.join(tmp_dir_prefix, datetime.datetime.now().strftime("%Y%m%d_%H%M%S")) +tmp_dir_prefix = tempfile.mkdtemp(prefix="tmp-flyte") default_local_file_access_provider = FileAccessProvider( - local_sandbox_dir=os.path.join(tmp_dir, "sandbox"), - raw_output_prefix=os.path.join(tmp_dir, "raw"), + local_sandbox_dir=os.path.join(tmp_dir_prefix, "sandbox"), + raw_output_prefix=os.path.join(tmp_dir_prefix, "raw"), data_config=DataConfig.auto(), )