{ "cells": [ { "cell_type": "code", "execution_count": 178, "id": "7e66c738-f269-4cc6-ab32-e91fb65b234d", "metadata": {}, "outputs": [], "source": [ "import re\n", "from openai import OpenAI\n", "import gradio as gr\n", "import requests\n", "import json\n", "from typing import List\n", "from bs4 import BeautifulSoup, Tag, NavigableString\n", "from IPython.display import Markdown, display, update_display" ] }, { "cell_type": "code", "execution_count": 179, "id": "f85f4df7-3173-4ed9-ae1b-83b02088b00f", "metadata": {}, "outputs": [], "source": [ "#\n", "# from Ed Donner's github repo for LLM Engineering course on Udemy: \n", "# https://github.com/ed-donner/llm_engineering/blob/main/week1/day5.ipynb\n", "#\n", "headers = {\n", " \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36\"\n", "}\n", "\n", "class Website:\n", " \"\"\"\n", " A utility class to represent a Website that we have scraped, now with links\n", " \"\"\"\n", "\n", " def __init__(self, url):\n", " \n", " self.url = url\n", " self.title = None\n", " self.links = set()\n", " self.last_updated = '1970-01-01'\n", " \n", " response = requests.get(url, headers=headers)\n", " self.body = response.content\n", " self.soup = BeautifulSoup(self.body, 'html.parser')\n", " self.article = self.soup.find('article', class_='devsite-article')\n", " # self.title = soup.title.string if soup.title else \"No title found\"\n", " # if soup.body:\n", " # for irrelevant in soup.body([\"script\", \"style\", \"img\", \"input\"]):\n", " # irrelevant.decompose()\n", " # self.text = soup.body.get_text(separator=\"\\n\", strip=True)\n", " # else:\n", " # self.text = \"\"\n", " # links = [link.get('href') for link in soup.find_all('a')]\n", " # self.links = [link for link in links if link]\n", "\n", " def get_doc_title(self):\n", " if self.title:\n", " return self.title\n", "\n", " # title = self.soup.find('h1', class_='devsite-page-title').find(string=True, recursive=False).strip()\n", " title = self.soup.find('h1').find(string=True, recursive=False).strip()\n", " if not title:\n", " self.title = '{} | No Title'.format(self.url)\n", " else:\n", " self.title = title\n", "\n", " return self.title\n", "\n", " def get_last_updated(self):\n", " footer = self.soup.find('devsite-content-footer')\n", " footer_paras = footer.find_all('p')\n", " for fp in footer_paras:\n", " last_updated_re = r'Last updated (.*) UTC'\n", " match = re.search(last_updated_re, fp.get_text())\n", " if match:\n", " self.last_updated = match.group(1)\n", " break\n", "\n", " def get_doc_links(self):\n", " nav_items = self.soup.find_all('li', class_='devsite-nav-item')\n", " links_in_article = self.article_section.find_all('a', href=True)\n", " all_links = nav_items + links_in_article\n", " \n", " for al in all_links:\n", " link = al.find('a', href=True)\n", " if link and 'docs' in link['href']:\n", " if link['href'][0] == '/':\n", " self.links.add('https://cloud.google.com{}'.format(link['href']))\n", " else:\n", " self.links.add(link['href'])\n" ] }, { "cell_type": "code", "execution_count": 180, "id": "46dff4b3-949f-40ac-b8e3-cd89c5b20461", "metadata": {}, "outputs": [], "source": [ "exclude_tags = ['devsite-feedback', 'devsite-actions', 'devsite-toc', 'aside', 'devsite-page-title-meta', 'devsite-thumb-rating']" ] }, { "cell_type": "code", "execution_count": 181, "id": "5c6233b9-498b-44e4-9a87-e58aaa281ba9", "metadata": {}, "outputs": [], "source": [ "# eventarc = Website('https://cloud.google.com/eventarc/docs')\n", "# eventarc = Website('https://cloud.google.com/build/docs/deploying-builds/deploy-compute-engine')\n", "# eventarc = Website('https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-using-serial-console')\n", "eventarc = Website('https://cloud.google.com/functions/docs/deploy')" ] }, { "cell_type": "code", "execution_count": 182, "id": "afa176e2-4024-493a-be97-f2526cca92cd", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Deploy a function'" ] }, "execution_count": 182, "metadata": {}, "output_type": "execute_result" } ], "source": [ "eventarc.get_doc_title()" ] }, { "cell_type": "code", "execution_count": 183, "id": "7dcaa961-55f9-4778-9d55-96e24b6e8c7e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Deploy a function'" ] }, "execution_count": 183, "metadata": {}, "output_type": "execute_result" } ], "source": [ "eventarc.title" ] }, { "cell_type": "code", "execution_count": 184, "id": "030abb06-d590-43da-8333-184520f000b0", "metadata": {}, "outputs": [], "source": [ "soup = eventarc.soup" ] }, { "cell_type": "code", "execution_count": 185, "id": "0c908d8b-0cdb-4617-ae9a-d411cca8b7f2", "metadata": {}, "outputs": [], "source": [ "footer = soup.find('devsite-content-footer')" ] }, { "cell_type": "code", "execution_count": 186, "id": "e675fde6-664c-428c-98cc-c0d1ce4b82f1", "metadata": {}, "outputs": [], "source": [ "footer_paras = footer.find_all('p')" ] }, { "cell_type": "code", "execution_count": 187, "id": "a841163b-84f2-4068-981e-4a99b5e1fcc5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "None\n", "Nope\n", "<re.Match object; span=(0, 27), match='Last updated 2025-05-23 UTC'>\n", "2025-05-23\n" ] } ], "source": [ "for fp in footer_paras:\n", " last_updated_re = r'Last updated (.*) UTC'\n", " match = re.search(last_updated_re, fp.get_text())\n", " print(match)\n", " if match:\n", " print(match.group(1))\n", " else:\n", " print('Nope')" ] }, { "cell_type": "code", "execution_count": 188, "id": "436065d7-d3fe-412a-b0b6-a774044290b3", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'2025-05-23'" ] }, "execution_count": 188, "metadata": {}, "output_type": "execute_result" } ], "source": [ "eventarc.get_last_updated()\n", "eventarc.last_updated" ] }, { "cell_type": "code", "execution_count": 189, "id": "bb6ec155-ed4d-451a-9d0d-885f959ebd85", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'https://cloud.google.com/docs/ai-ml'" ] }, "execution_count": 189, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nav_items = soup.find_all('li', class_='devsite-nav-item')\n", "nav_items[0].find('a', href=True)['href']" ] }, { "cell_type": "code", "execution_count": 190, "id": "0a740921-505c-4e4a-987f-fa8947a27ebd", "metadata": {}, "outputs": [], "source": [ "links_on_page = set()\n", "for ni in nav_items:\n", " link = ni.find('a', href=True)\n", " if link and 'docs' in link['href']:\n", " if link['href'][0] == '/' and '#' not in link['href']:\n", " links_on_page.add('https://cloud.google.com{}'.format(link['href']))\n", " else:\n", " links_on_page.add(link['href'])" ] }, { "cell_type": "code", "execution_count": 191, "id": "f9474a3e-579e-4923-b1e6-22b5c782cd5f", "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "{'https://cloud.google.com/docs',\n", " 'https://cloud.google.com/docs/access-resources',\n", " 'https://cloud.google.com/docs/ai-ml',\n", " 'https://cloud.google.com/docs/application-development',\n", " 'https://cloud.google.com/docs/application-hosting',\n", " 'https://cloud.google.com/docs/compute-area',\n", " 'https://cloud.google.com/docs/costs-usage',\n", " 'https://cloud.google.com/docs/cross-product-overviews',\n", " 'https://cloud.google.com/docs/data',\n", " 'https://cloud.google.com/docs/databases',\n", " 'https://cloud.google.com/docs/devtools',\n", " 'https://cloud.google.com/docs/dhm-cloud',\n", " 'https://cloud.google.com/docs/generative-ai',\n", " 'https://cloud.google.com/docs/iac',\n", " 'https://cloud.google.com/docs/industry',\n", " 'https://cloud.google.com/docs/migration',\n", " 'https://cloud.google.com/docs/networking',\n", " 'https://cloud.google.com/docs/observability',\n", " 'https://cloud.google.com/docs/security',\n", " 'https://cloud.google.com/docs/storage',\n", " 'https://cloud.google.com/docs/tech-area-overviews',\n", " 'https://cloud.google.com/functions/1stgendocs/concepts/overview',\n", " 'https://cloud.google.com/functions/docs/apis',\n", " 'https://cloud.google.com/functions/docs/bestpractices/retries',\n", " 'https://cloud.google.com/functions/docs/building',\n", " 'https://cloud.google.com/functions/docs/concepts/iam',\n", " 'https://cloud.google.com/functions/docs/concepts/overview',\n", " 'https://cloud.google.com/functions/docs/deploy',\n", " 'https://cloud.google.com/functions/docs/managing',\n", " 'https://cloud.google.com/functions/docs/monitoring/audit-logging',\n", " 'https://cloud.google.com/functions/docs/resources',\n", " 'https://cloud.google.com/functions/docs/running/direct',\n", " 'https://cloud.google.com/functions/docs/samples',\n", " 'https://cloud.google.com/functions/docs/securing/authenticating',\n", " 'https://cloud.google.com/functions/docs/securing/cmek',\n", " 'https://cloud.google.com/functions/docs/securing/custom-constraints',\n", " 'https://cloud.google.com/functions/docs/securing/execution-environment-security',\n", " 'https://cloud.google.com/functions/docs/securing/function-identity',\n", " 'https://cloud.google.com/functions/docs/securing/gen-org-policy',\n", " 'https://cloud.google.com/functions/docs/securing/managing-access-iam',\n", " 'https://cloud.google.com/functions/docs/securing/overview',\n", " 'https://cloud.google.com/functions/docs/troubleshooting',\n", " 'https://cloud.google.com/marketplace/docs',\n", " 'https://cloud.google.com/run/docs/functions-with-run'}" ] }, "execution_count": 191, "metadata": {}, "output_type": "execute_result" } ], "source": [ "links_on_page" ] }, { "cell_type": "code", "execution_count": 192, "id": "6d1987db-b346-41cb-adcb-1a4ba0f6fd03", "metadata": {}, "outputs": [], "source": [ "article_section = soup.find('article', class_='devsite-article')\n", "links_in_article = article_section.find_all('a', href=True)" ] }, { "cell_type": "code", "execution_count": 193, "id": "2b48bcf0-dd19-4378-83e0-6526eea688e7", "metadata": {}, "outputs": [], "source": [ "def make_google_cloud_link(link):\n", " return 'https://cloud.google.com{}'.format(link['href'])" ] }, { "cell_type": "code", "execution_count": 194, "id": "20d62b32-bac1-49d6-96ae-86143fcaa3bd", "metadata": {}, "outputs": [], "source": [ "article_links = set()\n", "for lia in links_in_article:\n", " if lia and 'docs' in lia['href'] and '#' not in lia['href']:\n", " article_links.add(make_google_cloud_link(lia))" ] }, { "cell_type": "code", "execution_count": 195, "id": "bad4726e-394a-4935-a57f-f53fe8f87ae6", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'https://cloud.google.com/functions/docs/apis',\n", " 'https://cloud.google.com/functions/docs/building',\n", " 'https://cloud.google.com/functions/docs/runtime-support',\n", " 'https://cloud.google.com/functions/docs/tutorials/terraform',\n", " 'https://cloud.google.com/functions/docs/tutorials/terraform-pubsub',\n", " 'https://cloud.google.com/run/docs/configuring',\n", " 'https://cloud.google.com/run/docs/configuring/concurrency',\n", " 'https://cloud.google.com/run/docs/configuring/connect-cloudsql',\n", " 'https://cloud.google.com/run/docs/configuring/connecting-vpc',\n", " 'https://cloud.google.com/run/docs/configuring/execution-environments',\n", " 'https://cloud.google.com/run/docs/configuring/http2',\n", " 'https://cloud.google.com/run/docs/configuring/min-instances',\n", " 'https://cloud.google.com/run/docs/configuring/networking-best-practices',\n", " 'https://cloud.google.com/run/docs/configuring/request-timeout',\n", " 'https://cloud.google.com/run/docs/configuring/services/containers',\n", " 'https://cloud.google.com/run/docs/configuring/services/cpu',\n", " 'https://cloud.google.com/run/docs/configuring/services/environment-variables',\n", " 'https://cloud.google.com/run/docs/configuring/services/memory-limits',\n", " 'https://cloud.google.com/run/docs/configuring/services/secrets',\n", " 'https://cloud.google.com/run/docs/configuring/services/service-identity',\n", " 'https://cloud.google.com/run/docs/configuring/tags',\n", " 'https://cloud.google.com/run/docs/locations',\n", " 'https://cloud.google.com/run/docs/quickstarts/functions/deploy-functions-gcloud',\n", " 'https://cloud.google.com/run/docs/reference/cloud-run-admin-api-overview',\n", " 'https://cloud.google.com/run/docs/write-functions',\n", " 'https://cloud.google.com/shell/docs/how-cloud-shell-works',\n", " 'https://cloud.google.comhttps://cloud.google.com/functions/docs',\n", " 'https://cloud.google.comhttps://cloud.google.com/functions/docs/concepts/overview',\n", " 'https://cloud.google.comhttps://cloud.google.com/run/docs/quickstarts/functions/deploy-functions-console'}" ] }, "execution_count": 195, "metadata": {}, "output_type": "execute_result" } ], "source": [ "article_links" ] }, { "cell_type": "code", "execution_count": 196, "id": "98477112-90f6-4ddd-96e9-dfc5e8f5ff82", "metadata": {}, "outputs": [], "source": [ "# i = 0\n", "# for elem in article_section:\n", "# if i < 5:\n", " \n", "# if elem.name in exclude_tags:\n", "# continue\n", "\n", "# print('** {} **: {}'.format(i,elem))\n", "# if isinstance(elem, Tag):\n", "# keys = elem.attrs.keys()\n", "# print(keys)\n", "# if 'class' in keys:\n", "# print(\"---*** TAG NAME: {}\".format(elem.name))\n", "# print(elem['class'])\n", "# class_list = elem['class']\n", "# print(\"CLASS_LIST: {}\".format(class_list))\n", "# for cl in class_list:\n", "# print(\"CLASS cl: {}\".format(cl))\n", "# if 'breadcrumb' in cl or 'meta' in cl:\n", "# print('DECOMPOSING\\n')\n", "# elem.decompose()\n", "# break\n", "# else:\n", "# print('No class or no breadcrumb')\n", "# i = i + 1\n", "# else:\n", "# continue\n", "# else:\n", "# article_section = article_section\n", "# break" ] }, { "cell_type": "code", "execution_count": 197, "id": "849ab8d6-3f38-46a7-bbe8-5341f070861a", "metadata": {}, "outputs": [], "source": [ "# article_section" ] }, { "cell_type": "code", "execution_count": 198, "id": "dceddf77-03a8-46d8-b569-929b1115b35d", "metadata": {}, "outputs": [], "source": [ "soupy = eventarc.soup" ] }, { "cell_type": "code", "execution_count": 199, "id": "1445ba84-7e53-4612-8a31-2c60355913ab", "metadata": {}, "outputs": [], "source": [ "art_body = soupy.select('.devsite-article-body')" ] }, { "cell_type": "code", "execution_count": 200, "id": "3a2263cb-694d-490c-8fd3-57a53e8dabfc", "metadata": {}, "outputs": [], "source": [ "content = \"\"\n", "for ab in art_body:\n", " for pre_tag in ab.find_all('pre'):\n", " pre_tag.replace_with(\"```\" + pre_tag.text.strip() + \"```\")\n", " for code in ab.find_all('code'):\n", " code.replace_with(\"`\" + code.text.strip() + \"`\")\n", " a_tags = ab.find_all('a')\n", " for a_tag in a_tags:\n", " a_tag.text.strip()\n", " content += ab.get_text(separator=\"\\n\").strip()" ] }, { "cell_type": "code", "execution_count": 201, "id": "ff87addb-f13c-4884-957b-fbffe47b2d4e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\"Deploy a function\\n\\n\\nThis guide shows you how to deploy a function from source code using the\\n\\n`gcloud functions`\\n command. To learn how to deploy a function using the\\n\\n`gcloud run`\\n command, see\\n\\nDeploy a Cloud Run function using the gcloud CLI\\n.\\n\\n\\nThe deployment process takes your source code and configuration settings and\\n\\nbuilds a runnable image\\n that Cloud Run functions\\nmanages automatically in order to handle requests to your function.\\n\\n\\nDeployment basics\\n\\n\\nFor an introduction on the type of functions you can deploy, see\\n\\nWrite Cloud Run functions\\n.\\n\\n\\nUsers deploying functions must have the\\n\\nCloud Functions Developer\\n\\nIAM role or a role that includes the same permissions. See also\\n\\nAdditional configuration for deployment\\n.\\n\\n\\n\\n\\n\\n\\nIn the Google Cloud console, activate Cloud Shell.\\n\\n\\nActivate Cloud Shell\\n\\n\\n\\n At the bottom of the Google Cloud console, a\\n \\nCloud Shell\\n\\n session starts and displays a command-line prompt. Cloud Shell is a shell environment\\n with the Google Cloud CLI\\n already installed and with values already set for\\n your current project. It can take a few seconds for the session to initialize.\\n \\n\\n\\n\\n\\nUse the \\n`gcloud functions deploy`\\n\\ncommand to deploy a function:\\n\\n\\n```gcloud functions deploy YOUR_FUNCTION_NAME \\\\\\n --region=YOUR_REGION \\\\\\n --runtime=YOUR_RUNTIME \\\\\\n --source=YOUR_SOURCE_LOCATION \\\\\\n --entry-point=YOUR_CODE_ENTRYPOINT \\\\\\n TRIGGER_FLAGS```\\n\\n\\nThe first argument, \\n`YOUR_FUNCTION_NAME`\\n, is a name for\\nyour deployed function. The function name must start with a letter\\nfollowed by up to 62 letters, numbers, hyphens, or underscores, and must end\\nwith a letter or a number. The name of the Cloud Run service that\\nis created for your function will replace underscores with hyphens and\\nuppercase letters will be converted to lowercase. For example,\\n\\n`Function_1`\\n will be given the name \\n`function-1`\\n in Cloud Run.\\n\\n\\nNote:\\n Run \\n`gcloud config set functions/gen2 true`\\n to set all future\\n first time deployments.\\n\\n\\n\\n\\nThe \\n`--region`\\n flag\\nspecifies the region in which to deploy your function. See\\n\\nLocations\\n for a list of regions supported by\\nCloud Run.\\n\\n\\nThe \\n`--runtime`\\n flag\\nspecifies which language runtime your function uses. See\\n\\nRuntime support\\n for a list of supported\\nruntime IDs.\\n\\n\\nThe \\n`--source`\\n flag\\nspecifies the location of your function source code.\\n\\n\\nThe \\n`--entry-point`\\n\\nflag specifies the entry point to your function in your source code. This is\\nthe code that will be executed when your function runs. The value of this\\nflag must be a function name or fully-qualified class name that exists in\\nyour source code. For more information, see\\n\\nFunction entry point\\n.\\n\\n\\nTo specify the \\ntrigger\\n for your\\nfunction, additional flags (represented as\\n\\n`TRIGGER_FLAGS`\\n above) are required, depending on\\nthe trigger you want to use:\\n\\n\\n\\n\\n\\n\\nTrigger flags\\n\\n\\nTrigger description\\n\\n\\n\\n\\n\\n\\n`--trigger-http`\\n\\n\\nTrigger the function with an HTTP(S) request.\\n\\n\\n\\n\\n\\n\\n`--trigger-topic=YOUR_PUBSUB_TOPIC`\\n\\n\\nTrigger the function when a message is published to the specified\\n Pub/Sub topic.\\n\\n\\n\\n\\n\\n\\n`--trigger-bucket=YOUR_STORAGE_BUCKET`\\n\\n\\nTrigger the function when an object is created or overwritten in the\\n specified Cloud Storage bucket.\\n\\n\\n\\n\\n\\n\\n`--trigger-event-filters=EVENTARC_EVENT_FILTERS`\\n\\n\\nTrigger the function with Eventarc when an\\n event that matches the specified filters occurs.\\n\\n\\n\\n\\n\\n\\nFor a complete reference on the deployment command and its flags, see the\\n\\n`gcloud functions deploy`\\n\\ndocumentation.\\n\\n\\nFor more details about \\n`gcloud functions deploy`\\n configuration flags,\\nrefer to \\nCloud Run documentation\\n.\\n\\n\\n\\n\\n\\n\\nWhen deployment finishes successfully, functions appear with a green check\\nmark in the Cloud Run overview page in the\\n\\nGoogle Cloud console\\n.\\n\\n\\nThe initial deployment of a function may take several minutes, while the\\nunderlying infrastructure is provisioned. Redeploying an existing function\\nis faster, and incoming traffic is automatically migrated to the newest version.\\n\\n\\nNote:\\n Instances provisioned with a previous version of a function may continue\\nrunning and processing traffic for several minutes after a new deployment has\\nfinished. This ensures that traffic sent to your function while a deployment is\\nin progress isn't dropped. Also note that when a deployment fails,\\nif there is a previous version of the function, it will continue to be\\navailable in most cases.\\n\\n\\nHTTP endpoint URL\\n\\n\\nWhen you create a function with the \\n`gcloud functions`\\n command or the\\nCloud Functions v2 API, by default, the function has a\\n\\n`cloudfunctions.net`\\n HTTP endpoint URL. If you take this function and deploy it\\non Cloud Run, your function also receives a \\n`run.app`\\n HTTP endpoint\\nURL. However, functions created in Cloud Run won't have an\\n\\n`cloudfunctions.net`\\n HTTP endpoint URL. A function's \\n`cloudfunctions.net`\\n URL\\nand \\n`run.app`\\n URL behave in exactly the same way. They are interchangeable,\\nand are used to trigger your function.\\n\\n\\nTerraform examples\\n\\n\\nFor examples about how to deploy functions using Terraform, see the\\n\\nTerraform HTTP example\\n and\\n\\nTerraform Pub/Sub example\\n.\\n\\n\\nConfigure networking\\n\\n\\nFunctions created using the \\nCloud Functions v2 API\\n\\n(for example, by using \\n`gcloud functions`\\n, the REST API, or Terraform) can be\\nmanaged with the \\nCloud Run Admin API\\n\\nas well as the Cloud Functions v2 API.\\n\\n\\nNote:\\n If you created a Cloud Run function using\\n\\n`gcloud run`\\n commands or the Cloud Run Admin API, you can't manage that function\\nwith \\n`gcloud functions`\\n commands or the Cloud Functions v2 API.\\n\\n\\nTo learn more about managing networks for functions, including how to route\\n\\nVPC network traffic\\n, see\\n\\nBest practices for Cloud Run networking\\n.\\n\\n\\nLearn how to deploy Cloud Run functions on Cloud Run\\n\\n\\nDeploying functions on Cloud Run is similar to the steps described in\\nthis document, but with some added advantages:\\n\\n\\n\\n\\nYou can use the Google Cloud console, as well as the gcloud CLI\\n(\\n`gcloud run deploy`\\n).\\n\\n\\nThe steps for specifying triggers are slightly different. To learn more, see\\n\\ntriggers and retries\\n\\nand \\nexamples of function triggers\\n.\\n\\n\\nCloud Run offers a broader array of configuration options:\\n\\n\\n\\nMinimum instances\\n\\n\\nConcurrency\\n\\n\\nContainer configuration\\n\\n\\nCPU limits\\n\\n\\nMemory limits\\n\\n\\nRequest timeout\\n\\n\\nSecrets\\n\\n\\nEnvironment variables\\n\\n\\nExecution environment\\n\\n\\nHTTP/2\\n\\n\\nService accounts\\n\\n\\nCloud SQL connections\\n\\n\\nSession affinity and traffic splitting\\n\\n\\nTags\\n\\n\\nNetworking\"" ] }, "execution_count": 201, "metadata": {}, "output_type": "execute_result" } ], "source": [ "content" ] }, { "cell_type": "code", "execution_count": 202, "id": "2c49a47c-f5cb-42b1-a1fc-32b888886075", "metadata": {}, "outputs": [], "source": [ "def normalize_newlines(text):\n", " # Replace multiple newlines (\\n\\n or more) with a single \\n\n", " text = re.sub(r'\\n{2,}', '\\n', text)\n", " # Replace single newlines (\\n) with a space\n", " text = re.sub(r'(?<!\\n)\\n(?!\\n)', ' ', text)\n", " return text" ] }, { "cell_type": "code", "execution_count": 203, "id": "b9dca0bc", "metadata": {}, "outputs": [], "source": [ "folder = 'page_content'\n", "filename = eventarc.get_doc_title().lower().replace(\" \", \"_\")\n", "folder_and_filename = folder + \"/\" + filename + \".txt\"\n", "with open(folder_and_filename, \"w\") as f:\n", " f.write(clean_content)" ] }, { "cell_type": "code", "execution_count": 224, "id": "b435565c", "metadata": {}, "outputs": [], "source": [ "raw_folder = 'raw_soup'\n", "filename = eventarc.get_doc_title().lower().replace(\" \", \"_\")\n", "folder_and_filename = raw_folder + \"/\" + filename + \"_RAW.txt\"\n", "with open(folder_and_filename, \"w\") as f:\n", " f.write(str(art_body[0]))" ] }, { "cell_type": "code", "execution_count": 222, "id": "3f6cc3c5", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'<div class=\"devsite-article-body clearfix devsite-no-page-title\">\\n<h1 data-text=\"Deploy a function\" id=\"deploy-a-function\" tabindex=\"-1\">Deploy a function</h1>\\n<p>This guide shows you how to deploy a function from source code using the\\n`gcloud functions` command. To learn how to deploy a function using the\\n`gcloud run` command, see\\n<a href=\"/run/docs/quickstarts/functions/deploy-functions-gcloud\">Deploy a Cloud Run function using the gcloud CLI</a>.</p>\\n<p>The deployment process takes your source code and configuration settings and\\n<a href=\"/functions/docs/building\">builds a runnable image</a> that Cloud Run functions\\nmanages automatically in order to handle requests to your function.</p>\\n<h2 data-text=\"Deployment basics\" id=\"basics\" tabindex=\"-1\">Deployment basics</h2>\\n<p>For an introduction on the type of functions you can deploy, see\\n<a href=\"/run/docs/write-functions\">Write Cloud Run functions</a>.</p>\\n<p>Users deploying functions must have the\\n<a href=\"/functions/docs/reference/iam/roles#cloudfunctions.developer\">Cloud Functions Developer</a>\\nIAM role or a role that includes the same permissions. See also\\n<a href=\"/functions/docs/reference/iam/roles#additional-configuration\">Additional configuration for deployment</a>.</p>\\n<ol>\\n<li>\\n<p>In the Google Cloud console, activate Cloud Shell.</p>\\n<p><a class=\"button button-primary\" href=\"https://console.cloud.google.com/?cloudshell=true\" target=\"console\" track-metadata-end-goal=\"launchCloudShell\" track-name=\"consoleLink\" track-type=\"commonIncludes\">Activate Cloud Shell</a></p>\\n<p>\\n At the bottom of the Google Cloud console, a\\n <a href=\"/shell/docs/how-cloud-shell-works\">Cloud Shell</a>\\n session starts and displays a command-line prompt. Cloud Shell is a shell environment\\n with the Google Cloud CLI\\n already installed and with values already set for\\n your current project. It can take a few seconds for the session to initialize.\\n </p>\\n</li>\\n<li><p>Use the <a href=\"/sdk/gcloud/reference/functions/deploy\">`gcloud functions deploy`</a>\\ncommand to deploy a function:</p>\\n<div></div><devsite-code>```gcloud functions deploy YOUR_FUNCTION_NAME \\\\\\n --region=YOUR_REGION \\\\\\n --runtime=YOUR_RUNTIME \\\\\\n --source=YOUR_SOURCE_LOCATION \\\\\\n --entry-point=YOUR_CODE_ENTRYPOINT \\\\\\n TRIGGER_FLAGS```</devsite-code>\\n<p>The first argument, `YOUR_FUNCTION_NAME`, is a name for\\nyour deployed function. The function name must start with a letter\\nfollowed by up to 62 letters, numbers, hyphens, or underscores, and must end\\nwith a letter or a number. The name of the Cloud Run service that\\nis created for your function will replace underscores with hyphens and\\nuppercase letters will be converted to lowercase. For example,\\n`Function_1` will be given the name `function-1` in Cloud Run.</p>\\n<aside class=\"note\"><strong>Note:</strong><span> Run `gcloud config set functions/gen2 true` to set all future\\n first time deployments.</span></aside>\\n<ul>\\n<li><p>The <a href=\"/sdk/gcloud/reference/functions/deploy#--region\">`--region`</a> flag\\nspecifies the region in which to deploy your function. See\\n<a href=\"/run/docs/locations\">Locations</a> for a list of regions supported by\\nCloud Run.</p></li>\\n<li><p>The <a href=\"/sdk/gcloud/reference/functions/deploy#--runtime\">`--runtime`</a> flag\\nspecifies which language runtime your function uses. See\\n<a href=\"/functions/docs/runtime-support\">Runtime support</a> for a list of supported\\nruntime IDs.</p></li>\\n<li><p>The <a href=\"/sdk/gcloud/reference/functions/deploy#--source\">`--source`</a> flag\\nspecifies the location of your function source code.</p></li>\\n<li><p>The <a href=\"/sdk/gcloud/reference/functions/deploy#--entry-point\">`--entry-point`</a>\\nflag specifies the entry point to your function in your source code. This is\\nthe code that will be executed when your function runs. The value of this\\nflag must be a function name or fully-qualified class name that exists in\\nyour source code. For more information, see\\n<a href=\"/run/docs/write-functions#function_entry_point\">Function entry point</a>.</p></li>\\n<li><p>To specify the <a href=\"/sdk/gcloud/reference/functions/deploy#--trigger-bucket\">trigger</a> for your\\nfunction, additional flags (represented as\\n`TRIGGER_FLAGS` above) are required, depending on\\nthe trigger you want to use:</p>\\n<table>\\n<tr>\\n<th>Trigger flags</th>\\n<th>Trigger description</th>\\n</tr>\\n<tr>\\n<td>`--trigger-http`</td>\\n<td>Trigger the function with an HTTP(S) request.</td>\\n</tr>\\n<tr>\\n<td>`--trigger-topic=YOUR_PUBSUB_TOPIC`</td>\\n<td>Trigger the function when a message is published to the specified\\n Pub/Sub topic.</td>\\n</tr>\\n<tr>\\n<td>`--trigger-bucket=YOUR_STORAGE_BUCKET`</td>\\n<td>Trigger the function when an object is created or overwritten in the\\n specified Cloud Storage bucket.</td>\\n</tr>\\n<tr>\\n<td>`--trigger-event-filters=EVENTARC_EVENT_FILTERS`</td>\\n<td>Trigger the function with Eventarc when an\\n event that matches the specified filters occurs.</td>\\n</tr>\\n</table>\\n<p>For a complete reference on the deployment command and its flags, see the\\n<a href=\"/sdk/gcloud/reference/functions/deploy\">`gcloud functions deploy`</a>\\ndocumentation.</p>\\n<p>For more details about `gcloud functions deploy` configuration flags,\\nrefer to <a href=\"/run/docs/configuring\">Cloud Run documentation</a>.</p></li>\\n</ul></li>\\n</ol>\\n<p>When deployment finishes successfully, functions appear with a green check\\nmark in the Cloud Run overview page in the\\n<a href=\"https://console.cloud.google.com/run\">Google Cloud console</a>.</p>\\n<p>The initial deployment of a function may take several minutes, while the\\nunderlying infrastructure is provisioned. Redeploying an existing function\\nis faster, and incoming traffic is automatically migrated to the newest version.</p>\\n<aside class=\"note\"><strong>Note:</strong><span> Instances provisioned with a previous version of a function may continue\\nrunning and processing traffic for several minutes after a new deployment has\\nfinished. This ensures that traffic sent to your function while a deployment is\\nin progress isn\\'t dropped. Also note that when a deployment fails,\\nif there is a previous version of the function, it will continue to be\\navailable in most cases.</span></aside>\\n<h2 data-text=\"HTTP endpoint URL\" id=\"http-endpoint\" tabindex=\"-1\">HTTP endpoint URL</h2>\\n<p>When you create a function with the `gcloud functions` command or the\\nCloud Functions v2 API, by default, the function has a\\n`cloudfunctions.net` HTTP endpoint URL. If you take this function and deploy it\\non Cloud Run, your function also receives a `run.app` HTTP endpoint\\nURL. However, functions created in Cloud Run won\\'t have an\\n`cloudfunctions.net` HTTP endpoint URL. A function\\'s `cloudfunctions.net` URL\\nand `run.app` URL behave in exactly the same way. They are interchangeable,\\nand are used to trigger your function.</p>\\n<h2 data-text=\"Terraform examples\" id=\"terraform_examples\" tabindex=\"-1\">Terraform examples</h2>\\n<p>For examples about how to deploy functions using Terraform, see the\\n<a href=\"/functions/docs/tutorials/terraform\">Terraform HTTP example</a> and\\n<a href=\"/functions/docs/tutorials/terraform-pubsub\">Terraform Pub/Sub example</a>.</p>\\n<h2 data-text=\"Configure networking\" id=\"configure_networking\" tabindex=\"-1\">Configure networking</h2>\\n<p>Functions created using the <a href=\"/functions/docs/apis\">Cloud Functions v2 API</a>\\n(for example, by using `gcloud functions`, the REST API, or Terraform) can be\\nmanaged with the <a href=\"/run/docs/reference/cloud-run-admin-api-overview\">Cloud Run Admin API</a>\\nas well as the Cloud Functions v2 API.</p>\\n<aside class=\"note\"><strong>Note:</strong><span> If you created a Cloud Run function using\\n`gcloud run` commands or the Cloud Run Admin API, you can\\'t manage that function\\nwith `gcloud functions` commands or the Cloud Functions v2 API.</span></aside>\\n<p>To learn more about managing networks for functions, including how to route\\n<a href=\"/run/docs/configuring/connecting-vpc\">VPC network traffic</a>, see\\n<a href=\"/run/docs/configuring/networking-best-practices\">Best practices for Cloud Run networking</a>.</p>\\n<h2 data-text=\"Learn how to deploy Cloud Run functions on Cloud Run\" id=\"learn-about-cloud-run\" tabindex=\"-1\">Learn how to deploy Cloud Run functions on Cloud Run</h2>\\n<p>Deploying functions on Cloud Run is similar to the steps described in\\nthis document, but with some added advantages:</p>\\n<ul>\\n<li>You can use the Google Cloud console, as well as the gcloud CLI\\n(`gcloud run deploy`).</li>\\n<li>The steps for specifying triggers are slightly different. To learn more, see\\n<a href=\"/run/docs/functions/comparison#triggers_and_retries\">triggers and retries</a>\\nand <a href=\"/run/docs/function-triggers#triggers\">examples of function triggers</a>.</li>\\n<li>Cloud Run offers a broader array of configuration options:\\n<ul>\\n<li><a href=\"/run/docs/configuring/min-instances\">Minimum instances</a></li>\\n<li><a href=\"/run/docs/configuring/concurrency\">Concurrency</a></li>\\n<li><a href=\"/run/docs/configuring/services/containers\">Container configuration</a></li>\\n<li><a href=\"/run/docs/configuring/services/cpu\">CPU limits</a></li>\\n<li><a href=\"/run/docs/configuring/services/memory-limits\">Memory limits</a></li>\\n<li><a href=\"/run/docs/configuring/request-timeout\">Request timeout</a></li>\\n<li><a href=\"/run/docs/configuring/services/secrets\">Secrets</a></li>\\n<li><a href=\"/run/docs/configuring/services/environment-variables\">Environment variables</a></li>\\n<li><a href=\"/run/docs/configuring/execution-environments\">Execution environment</a></li>\\n<li><a href=\"/run/docs/configuring/http2\">HTTP/2</a></li>\\n<li><a href=\"/run/docs/configuring/services/service-identity\">Service accounts</a></li>\\n<li><a href=\"/run/docs/configuring/connect-cloudsql\">Cloud SQL connections</a></li>\\n<li><a href=\"/run/docs/configuring/session-affinity#affinity-and-traffic-splitting\">Session affinity and traffic splitting</a></li>\\n<li><a href=\"/run/docs/configuring/tags\">Tags</a></li>\\n<li><a href=\"/run/docs/configuring/networking-best-practices\">Networking</a></li>\\n</ul></li>\\n</ul>\\n<devsite-hats-survey class=\"nocontent\" hats-id=\"Nd7nTix2o0eU5NUYprb0ThtUc5jf\" listnr-id=\"83405\"></devsite-hats-survey>\\n</div>'" ] }, "execution_count": 222, "metadata": {}, "output_type": "execute_result" } ], "source": [ "str(art_body[0])\n" ] }, { "cell_type": "code", "execution_count": 204, "id": "eeb33044", "metadata": {}, "outputs": [], "source": [ "# def replace_pre_tags(soupy):\n", "# # soup = BeautifulSoup(html_content, 'html.parser')\n", "# for pre_tag in soupy.find_all('pre'):\n", "# pre_tag.replace_with(\"```\" + pre_tag.text.strip() + \"```\")\n", "# return str(soupy)" ] }, { "cell_type": "code", "execution_count": 213, "id": "985f97b7", "metadata": {}, "outputs": [], "source": [ "def normalize_newlines_and_spaces(text):\n", " # Replace multiple newlines (\\n\\n or more) with a single \\n\n", " text = re.sub(r'(?<!\\n)\\n(?!\\n)', ' ', text)\n", " text = re.sub(r'\\n{2,}', '\\n', text)\n", " text = re.sub(r' {2,}', ' ', text)\n", " # Replace single newlines (\\n) with a space\n", " return text\n" ] }, { "cell_type": "code", "execution_count": 214, "id": "9f6b9c92", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\"Deploy a function\\nThis guide shows you how to deploy a function from source code using the\\n`gcloud functions` command. To learn how to deploy a function using the\\n`gcloud run` command, see\\nDeploy a Cloud Run function using the gcloud CLI .\\nThe deployment process takes your source code and configuration settings and\\nbuilds a runnable image that Cloud Run functions manages automatically in order to handle requests to your function.\\nDeployment basics\\nFor an introduction on the type of functions you can deploy, see\\nWrite Cloud Run functions .\\nUsers deploying functions must have the\\nCloud Functions Developer\\nIAM role or a role that includes the same permissions. See also\\nAdditional configuration for deployment .\\nIn the Google Cloud console, activate Cloud Shell.\\nActivate Cloud Shell\\n At the bottom of the Google Cloud console, a Cloud Shell\\n session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize. \\nUse the `gcloud functions deploy`\\ncommand to deploy a function:\\n```gcloud functions deploy YOUR_FUNCTION_NAME \\\\ --region=YOUR_REGION \\\\ --runtime=YOUR_RUNTIME \\\\ --source=YOUR_SOURCE_LOCATION \\\\ --entry-point=YOUR_CODE_ENTRYPOINT \\\\ TRIGGER_FLAGS```\\nThe first argument, `YOUR_FUNCTION_NAME` , is a name for your deployed function. The function name must start with a letter followed by up to 62 letters, numbers, hyphens, or underscores, and must end with a letter or a number. The name of the Cloud Run service that is created for your function will replace underscores with hyphens and uppercase letters will be converted to lowercase. For example,\\n`Function_1` will be given the name `function-1` in Cloud Run.\\nNote: Run `gcloud config set functions/gen2 true` to set all future first time deployments.\\nThe `--region` flag specifies the region in which to deploy your function. See\\nLocations for a list of regions supported by Cloud Run.\\nThe `--runtime` flag specifies which language runtime your function uses. See\\nRuntime support for a list of supported runtime IDs.\\nThe `--source` flag specifies the location of your function source code.\\nThe `--entry-point`\\nflag specifies the entry point to your function in your source code. This is the code that will be executed when your function runs. The value of this flag must be a function name or fully-qualified class name that exists in your source code. For more information, see\\nFunction entry point .\\nTo specify the trigger for your function, additional flags (represented as\\n`TRIGGER_FLAGS` above) are required, depending on the trigger you want to use:\\nTrigger flags\\nTrigger description\\n`--trigger-http`\\nTrigger the function with an HTTP(S) request.\\n`--trigger-topic=YOUR_PUBSUB_TOPIC`\\nTrigger the function when a message is published to the specified Pub/Sub topic.\\n`--trigger-bucket=YOUR_STORAGE_BUCKET`\\nTrigger the function when an object is created or overwritten in the specified Cloud Storage bucket.\\n`--trigger-event-filters=EVENTARC_EVENT_FILTERS`\\nTrigger the function with Eventarc when an event that matches the specified filters occurs.\\nFor a complete reference on the deployment command and its flags, see the\\n`gcloud functions deploy`\\ndocumentation.\\nFor more details about `gcloud functions deploy` configuration flags, refer to Cloud Run documentation .\\nWhen deployment finishes successfully, functions appear with a green check mark in the Cloud Run overview page in the\\nGoogle Cloud console .\\nThe initial deployment of a function may take several minutes, while the underlying infrastructure is provisioned. Redeploying an existing function is faster, and incoming traffic is automatically migrated to the newest version.\\nNote: Instances provisioned with a previous version of a function may continue running and processing traffic for several minutes after a new deployment has finished. This ensures that traffic sent to your function while a deployment is in progress isn't dropped. Also note that when a deployment fails, if there is a previous version of the function, it will continue to be available in most cases.\\nHTTP endpoint URL\\nWhen you create a function with the `gcloud functions` command or the Cloud Functions v2 API, by default, the function has a\\n`cloudfunctions.net` HTTP endpoint URL. If you take this function and deploy it on Cloud Run, your function also receives a `run.app` HTTP endpoint URL. However, functions created in Cloud Run won't have an\\n`cloudfunctions.net` HTTP endpoint URL. A function's `cloudfunctions.net` URL and `run.app` URL behave in exactly the same way. They are interchangeable, and are used to trigger your function.\\nTerraform examples\\nFor examples about how to deploy functions using Terraform, see the\\nTerraform HTTP example and\\nTerraform Pub/Sub example .\\nConfigure networking\\nFunctions created using the Cloud Functions v2 API\\n(for example, by using `gcloud functions` , the REST API, or Terraform) can be managed with the Cloud Run Admin API\\nas well as the Cloud Functions v2 API.\\nNote: If you created a Cloud Run function using\\n`gcloud run` commands or the Cloud Run Admin API, you can't manage that function with `gcloud functions` commands or the Cloud Functions v2 API.\\nTo learn more about managing networks for functions, including how to route\\nVPC network traffic , see\\nBest practices for Cloud Run networking .\\nLearn how to deploy Cloud Run functions on Cloud Run\\nDeploying functions on Cloud Run is similar to the steps described in this document, but with some added advantages:\\nYou can use the Google Cloud console, as well as the gcloud CLI ( `gcloud run deploy` ).\\nThe steps for specifying triggers are slightly different. To learn more, see\\ntriggers and retries\\nand examples of function triggers .\\nCloud Run offers a broader array of configuration options:\\nMinimum instances\\nConcurrency\\nContainer configuration\\nCPU limits\\nMemory limits\\nRequest timeout\\nSecrets\\nEnvironment variables\\nExecution environment\\nHTTP/2\\nService accounts\\nCloud SQL connections\\nSession affinity and traffic splitting\\nTags\\nNetworking\"" ] }, "execution_count": 214, "metadata": {}, "output_type": "execute_result" } ], "source": [ "final_content = normalize_newlines_and_spaces(content)\n", "final_content" ] }, { "cell_type": "code", "execution_count": 215, "id": "771cfcaa", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Deploy a function\n", "This guide shows you how to deploy a function from source code using the\n", "`gcloud functions` command. To learn how to deploy a function using the\n", "`gcloud run` command, see\n", "Deploy a Cloud Run function using the gcloud CLI .\n", "The deployment process takes your source code and configuration settings and\n", "builds a runnable image that Cloud Run functions manages automatically in order to handle requests to your function.\n", "Deployment basics\n", "For an introduction on the type of functions you can deploy, see\n", "Write Cloud Run functions .\n", "Users deploying functions must have the\n", "Cloud Functions Developer\n", "IAM role or a role that includes the same permissions. See also\n", "Additional configuration for deployment .\n", "In the Google Cloud console, activate Cloud Shell.\n", "Activate Cloud Shell\n", " At the bottom of the Google Cloud console, a Cloud Shell\n", " session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize. \n", "Use the `gcloud functions deploy`\n", "command to deploy a function:\n", "```gcloud functions deploy YOUR_FUNCTION_NAME \\ --region=YOUR_REGION \\ --runtime=YOUR_RUNTIME \\ --source=YOUR_SOURCE_LOCATION \\ --entry-point=YOUR_CODE_ENTRYPOINT \\ TRIGGER_FLAGS```\n", "The first argument, `YOUR_FUNCTION_NAME` , is a name for your deployed function. The function name must start with a letter followed by up to 62 letters, numbers, hyphens, or underscores, and must end with a letter or a number. The name of the Cloud Run service that is created for your function will replace underscores with hyphens and uppercase letters will be converted to lowercase. For example,\n", "`Function_1` will be given the name `function-1` in Cloud Run.\n", "Note: Run `gcloud config set functions/gen2 true` to set all future first time deployments.\n", "The `--region` flag specifies the region in which to deploy your function. See\n", "Locations for a list of regions supported by Cloud Run.\n", "The `--runtime` flag specifies which language runtime your function uses. See\n", "Runtime support for a list of supported runtime IDs.\n", "The `--source` flag specifies the location of your function source code.\n", "The `--entry-point`\n", "flag specifies the entry point to your function in your source code. This is the code that will be executed when your function runs. The value of this flag must be a function name or fully-qualified class name that exists in your source code. For more information, see\n", "Function entry point .\n", "To specify the trigger for your function, additional flags (represented as\n", "`TRIGGER_FLAGS` above) are required, depending on the trigger you want to use:\n", "Trigger flags\n", "Trigger description\n", "`--trigger-http`\n", "Trigger the function with an HTTP(S) request.\n", "`--trigger-topic=YOUR_PUBSUB_TOPIC`\n", "Trigger the function when a message is published to the specified Pub/Sub topic.\n", "`--trigger-bucket=YOUR_STORAGE_BUCKET`\n", "Trigger the function when an object is created or overwritten in the specified Cloud Storage bucket.\n", "`--trigger-event-filters=EVENTARC_EVENT_FILTERS`\n", "Trigger the function with Eventarc when an event that matches the specified filters occurs.\n", "For a complete reference on the deployment command and its flags, see the\n", "`gcloud functions deploy`\n", "documentation.\n", "For more details about `gcloud functions deploy` configuration flags, refer to Cloud Run documentation .\n", "When deployment finishes successfully, functions appear with a green check mark in the Cloud Run overview page in the\n", "Google Cloud console .\n", "The initial deployment of a function may take several minutes, while the underlying infrastructure is provisioned. Redeploying an existing function is faster, and incoming traffic is automatically migrated to the newest version.\n", "Note: Instances provisioned with a previous version of a function may continue running and processing traffic for several minutes after a new deployment has finished. This ensures that traffic sent to your function while a deployment is in progress isn't dropped. Also note that when a deployment fails, if there is a previous version of the function, it will continue to be available in most cases.\n", "HTTP endpoint URL\n", "When you create a function with the `gcloud functions` command or the Cloud Functions v2 API, by default, the function has a\n", "`cloudfunctions.net` HTTP endpoint URL. If you take this function and deploy it on Cloud Run, your function also receives a `run.app` HTTP endpoint URL. However, functions created in Cloud Run won't have an\n", "`cloudfunctions.net` HTTP endpoint URL. A function's `cloudfunctions.net` URL and `run.app` URL behave in exactly the same way. They are interchangeable, and are used to trigger your function.\n", "Terraform examples\n", "For examples about how to deploy functions using Terraform, see the\n", "Terraform HTTP example and\n", "Terraform Pub/Sub example .\n", "Configure networking\n", "Functions created using the Cloud Functions v2 API\n", "(for example, by using `gcloud functions` , the REST API, or Terraform) can be managed with the Cloud Run Admin API\n", "as well as the Cloud Functions v2 API.\n", "Note: If you created a Cloud Run function using\n", "`gcloud run` commands or the Cloud Run Admin API, you can't manage that function with `gcloud functions` commands or the Cloud Functions v2 API.\n", "To learn more about managing networks for functions, including how to route\n", "VPC network traffic , see\n", "Best practices for Cloud Run networking .\n", "Learn how to deploy Cloud Run functions on Cloud Run\n", "Deploying functions on Cloud Run is similar to the steps described in this document, but with some added advantages:\n", "You can use the Google Cloud console, as well as the gcloud CLI ( `gcloud run deploy` ).\n", "The steps for specifying triggers are slightly different. To learn more, see\n", "triggers and retries\n", "and examples of function triggers .\n", "Cloud Run offers a broader array of configuration options:\n", "Minimum instances\n", "Concurrency\n", "Container configuration\n", "CPU limits\n", "Memory limits\n", "Request timeout\n", "Secrets\n", "Environment variables\n", "Execution environment\n", "HTTP/2\n", "Service accounts\n", "Cloud SQL connections\n", "Session affinity and traffic splitting\n", "Tags\n", "Networking\n" ] } ], "source": [ "print(final_content)" ] }, { "cell_type": "code", "execution_count": null, "id": "bc23520f", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.17" } }, "nbformat": 4, "nbformat_minor": 5 }