Skip to content

Commit

Permalink
Merge branch 'main' into github-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
holtskinner authored Aug 6, 2024
2 parents 37d205f + f0b4c3c commit 4573eb3
Show file tree
Hide file tree
Showing 10 changed files with 2,140 additions and 2,543 deletions.
1 change: 1 addition & 0 deletions .github/actions/spelling/excludes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,5 @@
ignore$
^\Qowlbot.py\E$
^\Qsearch/bulk-question-answering/bulk_question_answering_output.tsv\E$
^\Q.github/workflows/issue_assigner/assign_issue.py\E$
^\Q.github/actions/summarizer/gemini_summarize_pr.py\E$
4 changes: 2 additions & 2 deletions .github/actions/spelling/line_forbidden.patterns
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@
# Should be BigQuery
\b(?!BigQuery\b)(?!bigquery\b)[Bb]ig\s?[Qq]uery\b

# Should be DataFrame
\b(?!DataFrame\b)(?!.*[\(\)\{\}\.,=])[Dd]ata\s?[Ff]rame\b
# Should be DataFrame or DataFrames
\b(?!DataFrames?\b)(?!.*[\(\)\{\}\.,=])[Dd]ata\s?[Ff]rames?\b

# Should be Google Cloud
\s[Gg][Cc][Pp]\s
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/assign-issue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Assign Issue

on:
issues:
types: [opened, edited]

jobs:
assign:
runs-on: ubuntu-latest
permissions:
issues: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install Dependencies
run: |
python -m pip install --upgrade PyGithub
- name: Assign Issue
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python .github/workflows/issue_assigner/assign_issue.py
64 changes: 64 additions & 0 deletions .github/workflows/issue_assigner/assign_issue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"""Assigns the issue based on who created the file mentioned."""

# pylint: disable=line-too-long,too-many-arguments
import base64
import json
import os
import re

from github import Github


def get_issue_number(event_path: str) -> int:
"""Retrieves the issue number from GitHub event data."""
# Load event data
with open(event_path, "r", encoding="utf-8") as f:
event_data = json.load(f)

# Determine the issue number based on the event
if "issue" in event_data:
return int(event_data["issue"]["number"])

raise ValueError("Unable to determine issue number from event data.")


def main() -> None:
"""Gets filename mentioned in issue, finds author username in file, assigns issue to user."""
# Get GitHub token and repository details
repo_name = os.getenv("GITHUB_REPOSITORY", "")
token = os.getenv("GITHUB_TOKEN")
issue_number = get_issue_number(os.getenv("GITHUB_EVENT_PATH", ""))

g = Github(token)
repo = g.get_repo(repo_name)
issue = repo.get_issue(number=issue_number)

file_match = re.search(r"\b([\w-]+\.ipynb)\b", issue.body, re.IGNORECASE)

if not file_match:
print("No file found in issue.")
return

file_name = file_match.group(1)
result = g.search_code(f"repo:{repo_name} filename:{file_name}")

if result.totalCount == 0:
result = g.search_code(f"repo:{repo_name} {file_name}")
if result.totalCount == 0:
print(f"No files found for {file_name}")
return
print(result[0])
file = str(base64.b64decode(result[0].content))[:4000]
match = re.search(r"Author.+https://github\.com/([^/\)]+)", file)

if not match:
print(f"No User Found for {file_name}")
return

username = match.group(1)
print(f"Assigning {username} to Issue #{issue_number} for File {result[0].path}")
issue.add_to_assignees(username)


if __name__ == "__main__":
main()
12 changes: 6 additions & 6 deletions .github/workflows/notebook_linter/run_linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ if [ ${#notebooks[@]} -gt 0 ]; then
MYPY_RTN="0"

if [ "$is_test" = true ]; then
echo "Running nbfmt..."
python3 -m tensorflow_docs.tools.nbfmt --test "$notebook"
NBFMT_RTN=$?
echo "Running isort..."
python3 -m nbqa isort "$notebook" --check --profile black
ISORT_RTN=$?
echo "Running black..."
python3 -m nbqa black "$notebook" --check
BLACK_RTN=$?
Expand All @@ -91,9 +91,9 @@ if [ ${#notebooks[@]} -gt 0 ]; then
echo "Running pyupgrade..."
python3 -m nbqa pyupgrade --exit-zero-even-if-changed "$notebook"
PYUPGRADE_RTN=$?
echo "Running isort..."
python3 -m nbqa isort "$notebook" --check --profile black
ISORT_RTN=$?
echo "Running nbfmt..."
python3 -m tensorflow_docs.tools.nbfmt --test "$notebook"
NBFMT_RTN=$?
echo "Running flake8..."
python3 -m nbqa flake8 "$notebook" --show-source --extend-ignore=W391,E501,F821,E402,F404,F704,W503,E203,E722,W293,W291
FLAKE8_RTN=$?
Expand Down
14 changes: 3 additions & 11 deletions gemini/qa-ops/building_DIY_multimodal_qa_system_with_mRAG.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -318,21 +318,13 @@
"outputId": "eef6a25d-f66d-403c-b420-82c541f52ec1",
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Your project ID is: lavi-llm-experiment\n"
]
}
],
"outputs": [],
"source": [
"# Define project information\n",
"\n",
"import sys\n",
"\n",
"PROJECT_ID = \"\" # @param {type:\"string\"}\n",
"PROJECT_ID = \"YOUR_PROJECT_ID\" # @param {type:\"string\"}\n",
"LOCATION = \"us-central1\" # @param {type:\"string\"}\n",
"\n",
"# if not running on Colab, try to get the PROJECT_ID automatically\n",
Expand Down Expand Up @@ -889,7 +881,7 @@
"# Specify the PDF folder with multiple PDF ~7m\n",
"\n",
"print(\n",
" \"Removing pre-exsisting images folder, since you are running the logic from scratch\"\n",
" \"Removing pre-existing images folder, since you are running the logic from scratch\"\n",
")\n",
"! rm -rf images/\n",
"\n",
Expand Down
Loading

0 comments on commit 4573eb3

Please sign in to comment.