Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes copy_s3 by using generic GCS function #976

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions parsons/google/google_bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,12 +696,13 @@ def copy_s3(
# copy from S3 to GCS
tmp_gcs_bucket = check_env.check("GCS_TEMP_BUCKET", tmp_gcs_bucket)
gcs_client = gcs_client or GoogleCloudStorage()
temp_blob_uri = gcs_client.copy_s3_to_gcs(
aws_source_bucket=bucket,
gcs_client.copy_bucket_to_gcs(
source="s3",
source_bucket=bucket,
aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key,
gcs_sink_bucket=tmp_gcs_bucket,
aws_s3_key=key,
source_path=key,
)
temp_blob_name = key
temp_blob_uri = gcs_client.format_uri(bucket=tmp_gcs_bucket, name=temp_blob_name)
Expand Down
8 changes: 5 additions & 3 deletions test/test_databases/test_bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ def test_copy_large_compressed_file_from_gcs(

def test_copy_s3(self):
# setup dependencies / inputs
source = "s3"
table_name = "table_name"
bucket = "aws_bucket"
key = "file.gzip"
Expand All @@ -301,12 +302,13 @@ def test_copy_s3(self):
)

# check that the method did the right things
gcs_client.copy_s3_to_gcs.assert_called_once_with(
aws_source_bucket=bucket,
gcs_client.copy_bucket_to_gcs.assert_called_once_with(
source=source,
source_bucket=bucket,
aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key,
gcs_sink_bucket=tmp_gcs_bucket,
aws_s3_key=key,
source_path=key,
)
bq.copy_from_gcs.assert_called_once()
gcs_client.delete_blob.assert_called_once()
Expand Down
Loading