From 4d68dc0840eff9b1654d98854503bc212c3c10ee Mon Sep 17 00:00:00 2001 From: rthallam Date: Thu, 19 Dec 2024 01:36:01 +0000 Subject: [PATCH 1/7] Add CODEOWNERS --- .github/workflows/update_notebook_links.py | 110 --------------------- CODEOWNERS | 6 ++ 2 files changed, 6 insertions(+), 110 deletions(-) delete mode 100644 .github/workflows/update_notebook_links.py create mode 100644 CODEOWNERS diff --git a/.github/workflows/update_notebook_links.py b/.github/workflows/update_notebook_links.py deleted file mode 100644 index 26551268..00000000 --- a/.github/workflows/update_notebook_links.py +++ /dev/null @@ -1,110 +0,0 @@ -"""Check links in notebooks for accuracy.""" - -import os -import sys -import urllib.parse - -import nbformat - -LINK_PREFIXES = { - "colab_link": "https://colab.research.google.com/github/GoogleCloudPlatform/generative-ai/blob/main/", - "colab_enterprise_link": "https://console.cloud.google.com/vertex-ai/colab/import/", - "github_link": "https://github.com/GoogleCloudPlatform/generative-ai/blob/main/", - "workbench_link": "https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=", - "bigquery_studio_link": "https://console.cloud.google.com/bigquery/import?url=", - "linkedin_link": "https://www.linkedin.com/sharing/share-offsite/?url=", - "bluesky_link": "https://bsky.app/intent/compose?text=", - "twitter_link": "https://twitter.com/intent/tweet?url=", - "reddit_link": "https://reddit.com/submit?url=", - "facebook_link": "https://www.facebook.com/sharer/sharer.php?u=", -} - -GITHUB_URL_PREFIX = LINK_PREFIXES["github_link"] -RAW_URL_PREFIX = ( - "https://raw.githubusercontent.com/GoogleCloudPlatform/generative-ai/main/" -) - - -def fix_markdown_links( - cell_source: str, relative_notebook_path: str -) -> tuple[str, bool]: - """Fixes links in a markdown cell and returns the updated source.""" - new_lines = [] - changes_made = False - - encoded_url = urllib.parse.quote(f"{GITHUB_URL_PREFIX}{relative_notebook_path}") - - for line in cell_source.splitlines(): - for key, prefix in LINK_PREFIXES.items(): - if prefix not in line or "**NOTE:**" in line: - continue - - start_index = line.find(prefix) + len(prefix) - end_index = line.find(".ipynb", start_index) + len(".ipynb") - correct_link = "" - - if key in {"colab_link", "github_link"}: - correct_link = relative_notebook_path - elif key == "colab_enterprise_link": - correct_link = urllib.parse.quote( - f"{RAW_URL_PREFIX}{relative_notebook_path}", - safe=":", - ) - elif key == "workbench_link": - correct_link = f"{RAW_URL_PREFIX}{relative_notebook_path}" - elif key == "bigquery_studio_link": - correct_link = f"{GITHUB_URL_PREFIX}{relative_notebook_path}" - elif key in { - "linkedin_link", - "bluesky_link", - "twitter_link", - "reddit_link", - "facebook_link", - }: - correct_link = encoded_url - - if correct_link.lower() not in line.lower(): - print(f"Incorrect link in {relative_notebook_path}: {line}\n") - print(f"Should be: {correct_link}\n") - line = line.replace(line[start_index:end_index], correct_link) - changes_made = True - - new_lines.append(line) - - return "\n".join(new_lines), changes_made - - -def fix_links_in_notebook(notebook_path: str) -> int: - """Fixes specific types of links in a Jupyter notebook.""" - with open(notebook_path, encoding="utf-8") as f: - notebook = nbformat.read(f, as_version=4) - - relative_notebook_path = os.path.relpath(notebook_path, start=os.getcwd()).lower() - - for cell in notebook.cells: - if cell.cell_type == "markdown" and " None: - """Recursively processes all notebooks in a directory.""" - for root, _, files in os.walk(directory_path): - for filename in files: - if filename.endswith(".ipynb"): - notebook_path = os.path.join(root, filename) - fix_links_in_notebook(notebook_path) - - -if __name__ == "__main__": - if len(sys.argv) != 2: - print("Usage: python update_notebook_links.py ") - sys.exit(1) - process_directory(sys.argv[1]) diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 00000000..92536d48 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,6 @@ +# See https://help.github.com/en/articles/about-code-owners +# for more info about CODEOWNERS file. + +# These owners will be the default owners for everything in +# the repo. Unless a later match takes precedence. +* @RajeshThallam @Abhishekbhagwat \ No newline at end of file From efd1a778dabcb3e84504819eea4b68556961b150 Mon Sep 17 00:00:00 2001 From: rthallam Date: Thu, 19 Dec 2024 01:43:13 +0000 Subject: [PATCH 2/7] Add spell check --- .github/spelling/allow.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/spelling/allow.txt b/.github/spelling/allow.txt index 400b4ba2..c3edceb5 100644 --- a/.github/spelling/allow.txt +++ b/.github/spelling/allow.txt @@ -1136,3 +1136,5 @@ ytd yticks zakarid zaxis +RajeshThallam +Abhishekbhagwat \ No newline at end of file From fc3d432268db98bdd9491e042b7cf839511b04a4 Mon Sep 17 00:00:00 2001 From: rthallam Date: Thu, 19 Dec 2024 01:46:18 +0000 Subject: [PATCH 3/7] Fix spell check --- .github/spelling/allow.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/spelling/allow.txt b/.github/spelling/allow.txt index c3edceb5..6954e9c0 100644 --- a/.github/spelling/allow.txt +++ b/.github/spelling/allow.txt @@ -1136,5 +1136,4 @@ ytd yticks zakarid zaxis -RajeshThallam -Abhishekbhagwat \ No newline at end of file +Thallam \ No newline at end of file From a1daf19615c440cdf8aa71124c3a8e4ca04052d0 Mon Sep 17 00:00:00 2001 From: rthallam Date: Thu, 19 Dec 2024 01:50:01 +0000 Subject: [PATCH 4/7] Fix spell check --- .github/spelling/excludes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/spelling/excludes.txt b/.github/spelling/excludes.txt index 89e48681..e2fe7970 100644 --- a/.github/spelling/excludes.txt +++ b/.github/spelling/excludes.txt @@ -114,3 +114,4 @@ ignore$ ^\Qowlbot.py\E$ ^\Q.github/workflows/issue_assigner/assign_issue.py\E$ ^\Qnoxfile.py\E$ +^allow.txt$ \ No newline at end of file From 489d2a5a0ee00021fb6327cd7c675cb2b23da6b8 Mon Sep 17 00:00:00 2001 From: rthallam Date: Thu, 19 Dec 2024 01:55:46 +0000 Subject: [PATCH 5/7] Fix spell check (again) --- .github/workflows/spelling.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/spelling.yaml b/.github/workflows/spelling.yaml index 7b3fa47d..81b38b9a 100644 --- a/.github/workflows/spelling.yaml +++ b/.github/workflows/spelling.yaml @@ -156,3 +156,7 @@ jobs: punctuation-pattern: "'" only_check_changed_files: true longest_word: "10" + exclude: | + .github/workflows/spelling.yaml + .github/spelling/allow.txt + .github/spelling/excludes.txt \ No newline at end of file From 199c946fd543cfdf71b6815f385554448b8fd370 Mon Sep 17 00:00:00 2001 From: rthallam Date: Thu, 19 Dec 2024 02:04:01 +0000 Subject: [PATCH 6/7] Add spelling to Github actions --- .github/{ => actions}/spelling/README.md | 0 .github/{ => actions}/spelling/advice.md | 0 .github/{ => actions}/spelling/allow.txt | 0 .github/{ => actions}/spelling/block-delimiters.list | 0 .github/{ => actions}/spelling/candidate.patterns | 0 .github/{ => actions}/spelling/excludes.txt | 0 .github/{ => actions}/spelling/expect.txt | 0 .github/{ => actions}/spelling/line_forbidden.patterns | 0 .github/{ => actions}/spelling/patterns.txt | 0 .github/{ => actions}/spelling/reject.txt | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename .github/{ => actions}/spelling/README.md (100%) rename .github/{ => actions}/spelling/advice.md (100%) rename .github/{ => actions}/spelling/allow.txt (100%) rename .github/{ => actions}/spelling/block-delimiters.list (100%) rename .github/{ => actions}/spelling/candidate.patterns (100%) rename .github/{ => actions}/spelling/excludes.txt (100%) rename .github/{ => actions}/spelling/expect.txt (100%) rename .github/{ => actions}/spelling/line_forbidden.patterns (100%) rename .github/{ => actions}/spelling/patterns.txt (100%) rename .github/{ => actions}/spelling/reject.txt (100%) diff --git a/.github/spelling/README.md b/.github/actions/spelling/README.md similarity index 100% rename from .github/spelling/README.md rename to .github/actions/spelling/README.md diff --git a/.github/spelling/advice.md b/.github/actions/spelling/advice.md similarity index 100% rename from .github/spelling/advice.md rename to .github/actions/spelling/advice.md diff --git a/.github/spelling/allow.txt b/.github/actions/spelling/allow.txt similarity index 100% rename from .github/spelling/allow.txt rename to .github/actions/spelling/allow.txt diff --git a/.github/spelling/block-delimiters.list b/.github/actions/spelling/block-delimiters.list similarity index 100% rename from .github/spelling/block-delimiters.list rename to .github/actions/spelling/block-delimiters.list diff --git a/.github/spelling/candidate.patterns b/.github/actions/spelling/candidate.patterns similarity index 100% rename from .github/spelling/candidate.patterns rename to .github/actions/spelling/candidate.patterns diff --git a/.github/spelling/excludes.txt b/.github/actions/spelling/excludes.txt similarity index 100% rename from .github/spelling/excludes.txt rename to .github/actions/spelling/excludes.txt diff --git a/.github/spelling/expect.txt b/.github/actions/spelling/expect.txt similarity index 100% rename from .github/spelling/expect.txt rename to .github/actions/spelling/expect.txt diff --git a/.github/spelling/line_forbidden.patterns b/.github/actions/spelling/line_forbidden.patterns similarity index 100% rename from .github/spelling/line_forbidden.patterns rename to .github/actions/spelling/line_forbidden.patterns diff --git a/.github/spelling/patterns.txt b/.github/actions/spelling/patterns.txt similarity index 100% rename from .github/spelling/patterns.txt rename to .github/actions/spelling/patterns.txt diff --git a/.github/spelling/reject.txt b/.github/actions/spelling/reject.txt similarity index 100% rename from .github/spelling/reject.txt rename to .github/actions/spelling/reject.txt From 1a32d2cf589ef674fd1c6b1dc602774e995e004d Mon Sep 17 00:00:00 2001 From: rthallam Date: Thu, 19 Dec 2024 02:05:46 +0000 Subject: [PATCH 7/7] Cleanup PR for CODEOWNERS --- .github/actions/spelling/excludes.txt | 3 +-- .github/workflows/spelling.yaml | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/actions/spelling/excludes.txt b/.github/actions/spelling/excludes.txt index e2fe7970..37c50762 100644 --- a/.github/actions/spelling/excludes.txt +++ b/.github/actions/spelling/excludes.txt @@ -113,5 +113,4 @@ ignore$ ^\Qworkshops/ai-agents/ai_agents_for_engineers.ipynb\E$ ^\Qowlbot.py\E$ ^\Q.github/workflows/issue_assigner/assign_issue.py\E$ -^\Qnoxfile.py\E$ -^allow.txt$ \ No newline at end of file +^\Qnoxfile.py\E$ \ No newline at end of file diff --git a/.github/workflows/spelling.yaml b/.github/workflows/spelling.yaml index 81b38b9a..ec0f2d77 100644 --- a/.github/workflows/spelling.yaml +++ b/.github/workflows/spelling.yaml @@ -155,8 +155,4 @@ jobs: not-upper-or-lower-pattern: "[^A-ZÁÉÍÓÚÑÇÜa-záéíóúñçü]" punctuation-pattern: "'" only_check_changed_files: true - longest_word: "10" - exclude: | - .github/workflows/spelling.yaml - .github/spelling/allow.txt - .github/spelling/excludes.txt \ No newline at end of file + longest_word: "10" \ No newline at end of file