Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update github flows file #10

Merged
merged 5 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Lint

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
build:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -16,4 +16,4 @@ jobs:
- name: Run linter
run: |
pip install ruff
ruff check
ruff check
21 changes: 13 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
name: Pytest

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
build:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Run tests
python-version: "3.12"

- name: Install ffmpeg
run: sudo apt-get update && sudo apt-get install -y ffmpeg

- name: Install Poetry and dependencies
run: |
pip install poetry
poetry install --with api --with dev
poetry run pytest

poetry install --with api --with dev

- name: Run tests
run: poetry run pytest
67 changes: 51 additions & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ rb-doc-parser = { path = "src/rb-doc-parser", develop = true }
rb-audio-transcription = { path = "src/rb-audio-transcription", develop = true }

# Don't add new packages here, add them appropriately in the list above
beautifulsoup4 = "^4.13.3"



Expand Down
3 changes: 0 additions & 3 deletions src/rb-api/rb/api/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from logging.config import dictConfig
import multiprocessing
import os
import logging
import sys
from starlette.middleware.base import BaseHTTPMiddleware
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from rb.api import routes
Expand Down
2 changes: 1 addition & 1 deletion src/rb-api/rb/api/routes/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def wrapper(*args, **kwargs) -> ResponseBody:
)
# FIXME: prefix /api to make desktop call happy for now , eventually this will go away
# GOAL : /audio/routes is valid /api/routes should no longer work
cli_to_api_router.include_router(router,prefix=f'/api', tags=[plugin.name])
cli_to_api_router.include_router(router,prefix='/api', tags=[plugin.name])

logger.debug(f"Registering FastAPI route for {plugin.name} desktop call: {command.callback.__name__}")
else:
Expand Down
7 changes: 4 additions & 3 deletions src/rb-api/rb/api/utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from typing import Any, Callable
import argparse
from typing import Any, Callable

from rb.api.models import FloatRangeDescriptor, IntRangeDescriptor


def get_int_range_check_func_arg_parser(range: IntRangeDescriptor) -> Callable[[Any], int]:
def check_func(value: Any) -> int:
try:
value = int(value)
except:
except Exception:
raise argparse.ArgumentTypeError(f"{value} is not a valid integer")
if value < range.min or value > range.max:
raise argparse.ArgumentTypeError(f"{value} is not in the range [{range.min}, {range.max}]")
Expand All @@ -18,7 +19,7 @@ def get_float_range_check_func_arg_parser(range: FloatRangeDescriptor) -> Callab
def check_func(value: Any) -> float:
try:
value = float(value)
except:
except Exception:
raise argparse.ArgumentTypeError(f"{value} is not a valid float")
if value < range.min or value > range.max:
raise argparse.ArgumentTypeError(f"{value} is not in the range [{range.min}, {range.max}]")
Expand Down
10 changes: 4 additions & 6 deletions src/rb-audio-transcription/rb_audio_transcription/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""audio transcribe plugin"""
import sys, os
import sys
import json
import logging
from pathlib import Path
Expand All @@ -8,7 +8,6 @@
from rb.api.models import (
BatchTextResponse,
DirectoryInput,
FileInput,
FloatParameterDescriptor,
InputSchema,
InputType,
Expand All @@ -21,7 +20,6 @@
TextParameterDescriptor,
TextResponse,
)
from rb.api.models import BatchFileInput
from rb.api.models import API_APPMETDATA, API_ROUTES, PLUGIN_SCHEMA_SUFFIX
from rb.api.utils import (
get_int_range_check_func_arg_parser,
Expand Down Expand Up @@ -190,7 +188,7 @@ def alternate_params_parser(p: str) -> ParameterSchema:
# this fucntion is not used , just an example
try:
params = string_to_dict(p)
logger.info(f"-----DEBUG parser ---")
logger.info("-----DEBUG parser ---")
range_object = IntRangeDescriptor(min=params["c"], max=params["d"])
func = get_int_range_check_func_arg_parser(range_object)
if func(params["e"]):
Expand Down Expand Up @@ -221,15 +219,15 @@ def validate_inputs(inputs: DirInputs):
files = [file for file in dirpath.iterdir() if file.is_file()]
logger.debug(files)
if len(files) < 1:
raise HTTPException(status_code=400, detail=f"no 'files_in given directory' for transcribe command")
raise HTTPException(status_code=400, detail="no 'files_in given directory' for transcribe command")
logger.debug("------validate inputs done ---")
## this return object is now ready for use in transcribe function
return inputs
except (Exception) as e:
logger.error("validate bad inputs: %s", e)
raise HTTPException(status_code=400, detail=f"Invalid path inputs for transcribe command: {e}")

@app.command(f'transcribe')
@app.command('transcribe')
def transcribe(
inputs: Annotated[
DirInputs,
Expand Down
6 changes: 3 additions & 3 deletions src/rb-audio-transcription/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
def test_routes_command():
''' call typer cli to get routes'''
result = runner.invoke(cli_app, [API_ROUTES])
assert result is not ""
assert result != ""
assert result.exit_code == 0


def test_metadata_command():
result = runner.invoke(cli_app, [API_APPMETDATA])
assert result is not ""
assert result != ""
assert result.exit_code == 0


def test_schema_command():
result = runner.invoke(cli_app, [f"task{PLUGIN_SCHEMA_SUFFIX}"])
assert result is not ""
assert result != ""
assert result.exit_code == 0

def test_negative_test():
Expand Down
8 changes: 4 additions & 4 deletions src/rb-doc-parser/rb_doc_parser/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import typer
from rb.lib.docs import DOCS_GITHUB_URL, download_reference_doc # type: ignore
from rb.lib.docs import BASE_WIKI_URL, download_all_wiki_pages # type: ignore
from rb.lib.ollama import use_ollama # type: ignore
from rb_doc_parser.chat import load_chat_config, stream_output

Expand All @@ -11,8 +11,8 @@ def open() -> str:
"""
Open docs in the browser
"""
typer.launch(DOCS_GITHUB_URL)
return DOCS_GITHUB_URL
typer.launch(BASE_WIKI_URL)
return BASE_WIKI_URL


@use_ollama
Expand All @@ -23,7 +23,7 @@ def ask(
"""
Ask a question against the docs
"""
reference_doc = download_reference_doc()
reference_doc = download_all_wiki_pages()
chat_config = load_chat_config()
chat_config["prompt"]["system"] = chat_config["prompt"]["system"].format(
reference_doc=reference_doc
Expand Down
Loading