Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
[AP-498] Change default /tmp folder for encrypting files
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-transferwise authored Jan 31, 2020
1 parent 9e1c55d commit 0e200f6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
long_description = f.read()

setup(name="pipelinewise-target-snowflake",
version="1.4.0",
version="1.4.1",
description="Singer.io target for loading data to Snowflake - PipelineWise compatible",
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down
4 changes: 1 addition & 3 deletions target_snowflake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def persist_lines(config, lines, information_schema_cache=None) -> None:
key_properties = {}
validators = {}
records_to_load = {}
csv_files_to_load = {}
row_count = {}
stream_to_sync = {}
total_row_count = {}
Expand Down Expand Up @@ -292,7 +291,6 @@ def persist_lines(config, lines, information_schema_cache=None) -> None:

row_count[stream] = 0
total_row_count[stream] = 0
csv_files_to_load[stream] = NamedTemporaryFile(mode='w+b')

elif t == 'ACTIVATE_VERSION':
logger.debug('ACTIVATE_VERSION message')
Expand Down Expand Up @@ -416,7 +414,7 @@ def flush_records(stream, records_to_load, row_count, db_sync, temp_dir=None):
csv_line = db_sync.record_to_csv_line(record)
f.write(bytes(csv_line + '\n', 'UTF-8'))

s3_key = db_sync.put_to_stage(csv_file, stream, row_count)
s3_key = db_sync.put_to_stage(csv_file, stream, row_count, temp_dir=temp_dir)
try:
db_sync.load_csv(s3_key, row_count)
except Exception as e:
Expand Down
5 changes: 3 additions & 2 deletions target_snowflake/db_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def record_to_csv_line(self, record):
]
)

def put_to_stage(self, file, stream, count):
def put_to_stage(self, file, stream, count, temp_dir=None):
logger.info("Uploading {} rows to external snowflake stage on S3".format(count))

# Generating key in S3 bucket
Expand All @@ -379,7 +379,8 @@ def put_to_stage(self, file, stream, count):
)
encryption_metadata, encrypted_file = SnowflakeEncryptionUtil.encrypt_file(
encryption_material,
file
file,
tmp_dir=temp_dir
)

# Upload to s3
Expand Down

0 comments on commit 0e200f6

Please sign in to comment.