Skip to content

Commit

Permalink
fixed bucket ls for requester-pays buckets
Browse files Browse the repository at this point in the history
  • Loading branch information
bw2 committed Oct 22, 2024
1 parent 3c31875 commit b0a09b5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions step_pipeline/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,9 @@ def check_gcloud_storage_region(gs_path, expected_regions=("US", "US-CENTRAL1"),
#client = _get_google_storage_client(gcloud_project=gcloud_project)
#bucket = client.get_bucket(bucket_name)
#location = bucket.location
gcloud_project_arg = f"-u {gcloud_project}" if gcloud_project else ""
gsutil_output = subprocess.check_output(
f"gsutil ls -Lb gs://{bucket_name}",
f"gsutil {gcloud_project_arg} ls -Lb gs://{bucket_name}",
shell=True,
stderr=subprocess.STDOUT,
encoding="UTF-8")
Expand All @@ -431,7 +432,7 @@ def check_gcloud_storage_region(gs_path, expected_regions=("US", "US-CENTRAL1"),
break
if location is None:
raise GoogleStorageException(f"ERROR: Could not determine gs://{bucket_name} bucket region."
f"gsutil ls -Lb gs://{bucket_name} returned:\n{gsutil_output}")
f"gsutil {gcloud_project_arg} ls -Lb gs://{bucket_name} returned:\n{gsutil_output}")

BUCKET_LOCATION_CACHE[bucket_name] = location
except Exception as e:
Expand Down

0 comments on commit b0a09b5

Please sign in to comment.