diff --git a/notebooks/notebook_template.ipynb b/notebooks/notebook_template.ipynb index 476cbdb86..694557b4c 100644 --- a/notebooks/notebook_template.ipynb +++ b/notebooks/notebook_template.ipynb @@ -289,22 +289,7 @@ }, "outputs": [], "source": [ - "PROJECT_ID = \"\"\n", - "\n", - "# Get your Google Cloud project ID from gcloud\n", - "if not os.getenv(\"IS_TESTING\"):\n", - " shell_output = !gcloud config list --format 'value(core.project)' 2>/dev/null\n", - " PROJECT_ID = shell_output[0]\n", - " print(\"Project ID: \", PROJECT_ID)" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "qJYoRfYng0XZ" - }, - "source": [ - "Otherwise, set your project ID here." + "PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}" ] }, { @@ -315,8 +300,11 @@ }, "outputs": [], "source": [ - "if PROJECT_ID == \"\" or PROJECT_ID is None:\n", - " PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}" + "if PROJECT_ID == \"\" or PROJECT_ID is None or PROJECT_ID == \"[your-project-id]\":\n", + " # Get your GCP project id from gcloud\n", + " shell_output = ! gcloud config list --format 'value(core.project)' 2>/dev/null\n", + " PROJECT_ID = shell_output[0]\n", + " print(\"Project ID:\", PROJECT_ID)" ] }, { @@ -363,7 +351,7 @@ "#### Region\n", "\n", "You can also change the `REGION` variable, which is used for operations\n", - "throughout the rest of this notebook. Below are regions supported for Vertex AI. We recommend that you choose the region closest to you.\n", + "throughout the rest of this notebook. Below are regions supported for Vertex AI. It is recommended that you choose the region closest to you.\n", "\n", "- Americas: `us-central1`\n", "- Europe: `europe-west4`\n", diff --git a/notebooks/notebook_template_review.py b/notebooks/notebook_template_review.py index 809b77baf..87485848c 100644 --- a/notebooks/notebook_template_review.py +++ b/notebooks/notebook_template_review.py @@ -223,6 +223,22 @@ def parse_notebook(path): report_error(path, 32, "Set project ID code section not found") elif not cell['source'][0].startswith('PROJECT_ID = "[your-project-id]"'): report_error(path, 33, f"Set project ID not match template: {line}") + + cell, nth = get_cell(path, cells, nth) + if cell['cell_type'] != 'code' or 'or PROJECT_ID == "[your-project-id]":' not in cell['source'][0]: + report_error(path, 33, f"Set project ID not match template: {line}") + + cell, nth = get_cell(path, cells, nth) + if cell['cell_type'] != 'code' or '! gcloud config set project' not in cell['source'][0]: + report_error(path, 33, f"Set project ID not match template: {line}") + + ''' + # Region + cell, nth = get_cell(path, cells, nth) + if cell['source'][0].startswith("### Region"): + report_error(path, 34, "Region section not found") + ''' + def get_cell(path, cells, nth): while empty_cell(path, cells, nth): @@ -313,17 +329,33 @@ def parse_objective(path, cell): in_desc = False in_steps = False in_uses = True + uses += line + continue elif line.startswith('The steps performed'): in_desc = False in_uses = False in_steps = True + steps += line + continue if in_desc: desc += line elif in_uses: - uses += line + sline = line.strip() + if len(sline) == 0: + uses += '\n' + else: + ch = sline[0] + if ch in ['-', '*', '1', '2', '3', '4', '5', '6', '7', '8', '9']: + uses += line elif in_steps: - steps += line + sline = line.strip() + if len(sline) == 0: + steps += '\n' + else: + ch = sline[0] + if ch in ['-', '*', '1', '2', '3', '4', '5', '6', '7', '8', '9']: + steps += line if desc == '': report_error(path, 17, "Objective section missing desc")