Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit f8f4f11

Browse files
address comments
1 parent c8a6394 commit f8f4f11

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

bigframes/functions/_function_client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@ def create_cloud_function(
528528
if concurrency:
529529
function.service_config.max_instance_request_concurrency = concurrency
530530

531+
# Functions framework use environment variables to pass config to gunicorn
532+
# See https://github.com/GoogleCloudPlatform/functions-framework-python/issues/241
533+
# Code: https://github.com/GoogleCloudPlatform/functions-framework-python/blob/v3.10.1/src/functions_framework/_http/gunicorn.py#L37-L43
531534
env_vars = {}
532535
if workers:
533536
env_vars["WORKERS"] = str(workers)
@@ -636,7 +639,7 @@ def provision_bq_remote_function(
636639
)
637640
cf_endpoint = self.get_cloud_function_endpoint(cloud_function_name)
638641

639-
if (cloud_function_cpus is None) and (cloud_function_memory_mib is None):
642+
if cloud_function_memory_mib is None:
640643
cloud_function_memory_mib = _DEFAULT_FUNCTION_MEMORY_MIB
641644

642645
# assumption is most bigframes functions are cpu bound, single-threaded and many won't release GIL
@@ -735,16 +738,15 @@ def get_remote_function_specs(self, remote_function_name):
735738

736739

737740
def _infer_cpus_from_memory(memory_mib: int) -> int:
741+
# observed values, not formally documented by cloud run functions
738742
if memory_mib <= 2048:
739743
# in actuality, will be 0.583 for 1024mb, 0.33 for 512mb, etc, but we round up to 1
740744
return 1
741745
elif memory_mib <= 8192:
742746
return 2
743-
elif memory_mib <= 8192:
744-
return 2
745747
elif memory_mib <= 16384:
746748
return 4
747749
elif memory_mib <= 32768:
748750
return 8
749751
else:
750-
raise ValueError("Cloud run support at most 32768MiB per instance")
752+
raise ValueError("Cloud run supports at most 32768MiB per instance")

0 commit comments

Comments
 (0)