Skip to content

Commit

Permalink
feat: init pytest workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
RaoHai committed Aug 21, 2024
1 parent 236e660 commit 99bdebc
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with Ruff
run: |
pip install ruff
ruff check --output-format=github .
- name: Test with pytest
run: |
pip install pytest pytest-cov
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ venv
.next/
out/

.ruff_cache/

# production
build
Expand Down
10 changes: 5 additions & 5 deletions petercat_utils/rag_helper/task.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import json
from typing import Optional
from github import Github

import boto3

from .git_doc_task import GitDocTask
from .git_issue_task import GitIssueTask
from .git_task import GitTask

# Create SQS client
sqs = boto3.client("sqs")

from github import Github

from ..utils.env import get_env_variable
from ..data_class import TaskStatus, TaskType
from ..db.client.supabase import get_client

# Create SQS client
sqs = boto3.client("sqs")


g = Github()

TABLE_NAME = "rag_tasks"
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ authors = ["raoha.rh <[email protected]>"]
readme = "README.md"
packages = [{include = "petercat_utils"}]

[tool.ruff]
builtins = ["_"]

[tool.poetry.dependencies]
python = "^3.8"
langchain_community = "^0.2.11"
Expand Down
9 changes: 5 additions & 4 deletions server/auth/get_user_info.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Annotated
from fastapi import Cookie, HTTPException
from fastapi import Cookie
import httpx
import secrets
import random
Expand All @@ -8,7 +8,8 @@
from .get_oauth_token import get_oauth_token
from petercat_utils import get_client, get_env_variable

random_str = lambda N: ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(N))
def random_str(N):
return ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(N))

AUTH0_DOMAIN = get_env_variable("AUTH0_DOMAIN")

Expand Down Expand Up @@ -70,7 +71,7 @@ async def get_user_id(petercat_user_token: Annotated[str | None, Cookie()] = Non
user_info = await getUserInfoByToken(petercat_user_token)
return user_info['id']

except Exception as e:
except Exception:
return None

async def get_user_access_token(petercat_user_token: Annotated[str | None, Cookie()] = None):
Expand All @@ -83,5 +84,5 @@ async def get_user_access_token(petercat_user_token: Annotated[str | None, Cooki
access_token = await getUserAccessToken(user_id=user_info['id'])
print(f"get_user_access_token: user_info={user_info}, access_token={access_token}")
return access_token
except Exception as e:
except Exception:
return None
2 changes: 0 additions & 2 deletions server/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import os

import uvicorn
from fastapi import FastAPI
from starlette.middleware.sessions import SessionMiddleware
from fastapi.middleware.cors import CORSMiddleware
Expand Down
2 changes: 1 addition & 1 deletion server/models/authorization.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import datetime
import json
from pydantic import BaseModel, field_serializer
from typing import Any, Dict
from typing import Dict

class Authorization(BaseModel):
token: str
Expand Down
1 change: 0 additions & 1 deletion server/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ mangum
langserve
langchain_community
langchain
langchain-openai
PyGithub
GitPython
python-multipart
Expand Down
2 changes: 1 addition & 1 deletion server/routers/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_app_installations_access_token(installation_id: str, jwt: str):
return resp.json()

def get_installation_repositories(access_token: str):
url = f"https://api.github.com/installation/repositories"
url = "https://api.github.com/installation/repositories"
print("get_installation_repositories", url)
resp = requests.get(url, headers={
'X-GitHub-Api-Version': '2022-11-28',
Expand Down
1 change: 0 additions & 1 deletion server/tools/bot_builder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
from typing import List, Optional
from fastapi.responses import JSONResponse
from langchain.tools import tool
Expand Down

0 comments on commit 99bdebc

Please sign in to comment.