File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 31
31
DATASETS = os .environ .get ("BIGQUERY_DATASET" , "" ).strip ().split ()
32
32
SIMPLE_TABLE = os .environ .get ("BIGQUERY_SIMPLE_TABLE" )
33
33
DOWNLOAD_TABLE = os .environ .get ("BIGQUERY_DOWNLOAD_TABLE" )
34
+ MAX_BLOBS_PER_RUN = 5000 # Cannot exceed 10,000
34
35
35
36
prefix = {Simple .__name__ : "simple_requests" , Download .__name__ : "file_downloads" }
36
37
@@ -138,12 +139,16 @@ def load_processed_files_into_bigquery(event, context):
138
139
139
140
# Get the processed files we're loading
140
141
download_prefix = f"{ folder } /downloads-"
141
- download_source_blobs = bucket .list_blobs (prefix = download_prefix )
142
+ download_source_blobs = bucket .list_blobs (
143
+ prefix = download_prefix , max_results = MAX_BLOBS_PER_RUN
144
+ )
142
145
download_source_uris = [
143
146
f"gs://{ blob .bucket .name } /{ blob .name } " for blob in download_source_blobs
144
147
]
145
148
simple_prefix = f"{ folder } /simple-"
146
- simple_source_blobs = bucket .list_blobs (prefix = simple_prefix )
149
+ simple_source_blobs = bucket .list_blobs (
150
+ prefix = simple_prefix , max_results = MAX_BLOBS_PER_RUN
151
+ )
147
152
simple_source_uris = [
148
153
f"gs://{ blob .bucket .name } /{ blob .name } " for blob in simple_source_blobs
149
154
]
Original file line number Diff line number Diff line change @@ -151,7 +151,7 @@ def test_load_processed_files_into_bigquery(
151
151
152
152
blob_stub = pretend .stub (name = "blobname" , bucket = bucket )
153
153
154
- def _generate_blob_list (prefix ):
154
+ def _generate_blob_list (prefix , max_results ):
155
155
blob_list = [blob_stub ]
156
156
blob_lists [prefix ] = blob_list
157
157
return blob_list
@@ -203,8 +203,8 @@ def _generate_blob_list(prefix):
203
203
pretend .call (RESULT_BUCKET ),
204
204
]
205
205
assert bucket_stub .list_blobs .calls == [
206
- pretend .call (prefix = f"processed/{ partition } /downloads-" ),
207
- pretend .call (prefix = f"processed/{ partition } /simple-" ),
206
+ pretend .call (prefix = f"processed/{ partition } /downloads-" , max_results = 5000 ),
207
+ pretend .call (prefix = f"processed/{ partition } /simple-" , max_results = 5000 ),
208
208
]
209
209
assert (
210
210
load_job_stub .result .calls
You can’t perform that action at this time.
0 commit comments