Skip to content

Commit

Permalink
[AIRFLOW-5459] Use a dynamic tmp location in Dataflow operator
Browse files Browse the repository at this point in the history
  • Loading branch information
marengaz authored and mik-laj committed Sep 15, 2019
1 parent 7351df8 commit ae9608d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions airflow/gcp/operators/dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import re
import uuid
import copy
import tempfile
from enum import Enum
from typing import List, Optional

Expand Down Expand Up @@ -454,8 +455,10 @@ def google_cloud_to_local(self, file_name: str) -> str:

bucket_id = path_components[0]
object_id = '/'.join(path_components[1:])
local_file = '/tmp/dataflow{}-{}'.format(str(uuid.uuid4())[:8],
path_components[-1])
local_file = os.path.join(
tempfile.gettempdir(),
'dataflow{}-{}'.format(str(uuid.uuid4())[:8], path_components[-1])
)
self._gcs_hook.download(bucket_id, object_id, local_file)

if os.stat(local_file).st_size > 0:
Expand Down

0 comments on commit ae9608d

Please sign in to comment.