Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
29 changes: 15 additions & 14 deletions bigframes/functions/_function_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ def generate_cloud_function_code(
def create_cloud_function(
self,
def_,
cf_name,
*,
random_name,
input_types: Tuple[str],
output_type: str,
package_requirements=None,
Expand Down Expand Up @@ -428,9 +428,9 @@ def create_cloud_function(
create_function_request.parent = (
self.get_cloud_function_fully_qualified_parent()
)
create_function_request.function_id = cf_name
create_function_request.function_id = random_name
function = functions_v2.Function()
function.name = self.get_cloud_function_fully_qualified_name(cf_name)
function.name = self.get_cloud_function_fully_qualified_name(random_name)
function.build_config = functions_v2.BuildConfig()
function.build_config.runtime = python_version
function.build_config.entry_point = entry_point
Expand Down Expand Up @@ -497,24 +497,25 @@ def create_cloud_function(
# Cleanup
os.remove(archive_path)
except google.api_core.exceptions.AlreadyExists:
# If a cloud function with the same name already exists, let's
# update it
update_function_request = functions_v2.UpdateFunctionRequest()
update_function_request.function = function
operation = self._cloud_functions_client.update_function(
request=update_function_request
)
operation.result()
# b/437124912: The most likely scenario is that
# `create_function` had a retry due to a network issue. The
# retried request then fails because the first call actually
# succeeded, but we didn't get the successful response back.
#
# Since the function name was randomly chosen to avoid
# conflicts, we know the AlreadyExist can only happen because
# we created it. This error is safe to ignore.
pass

# Fetch the endpoint of the just created function
endpoint = self.get_cloud_function_endpoint(cf_name)
endpoint = self.get_cloud_function_endpoint(random_name)
if not endpoint:
raise bf_formatting.create_exception_with_feedback_link(
ValueError, "Couldn't fetch the http endpoint."
)

logger.info(
f"Successfully created cloud function {cf_name} with uri ({endpoint})"
f"Successfully created cloud function {random_name} with uri ({endpoint})"
)
return endpoint

Expand Down Expand Up @@ -571,7 +572,7 @@ def provision_bq_remote_function(
if not cf_endpoint:
cf_endpoint = self.create_cloud_function(
def_,
cloud_function_name,
random_name=cloud_function_name,
input_types=input_types,
output_type=output_type,
package_requirements=package_requirements,
Expand Down