Skip to content

Commit c61f506

Browse files
authored
Merge pull request #10 from UMass-Rescue/add-github-actions
update github flows file
2 parents b0c10cf + 95b3649 commit c61f506

File tree

13 files changed

+170
-63
lines changed

13 files changed

+170
-63
lines changed

.github/workflows/lint.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: Lint
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
76

87
jobs:
98
build:
9+
if: github.event.pull_request.draft == false
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
@@ -16,4 +16,4 @@ jobs:
1616
- name: Run linter
1717
run: |
1818
pip install ruff
19-
ruff check
19+
ruff check

.github/workflows/test.yml

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
name: Pytest
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
76

87
jobs:
98
build:
9+
if: github.event.pull_request.draft == false
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
1313
- uses: actions/setup-python@v5
1414
with:
15-
python-version: "3.11"
16-
- name: Run tests
15+
python-version: "3.12"
16+
17+
- name: Install ffmpeg
18+
run: sudo apt-get update && sudo apt-get install -y ffmpeg
19+
20+
- name: Install Poetry and dependencies
1721
run: |
1822
pip install poetry
19-
poetry install --with api --with dev
20-
poetry run pytest
21-
23+
poetry install --with api --with dev
24+
25+
- name: Run tests
26+
run: poetry run pytest

poetry.lock

+51-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ rb-doc-parser = { path = "src/rb-doc-parser", develop = true }
2828
rb-audio-transcription = { path = "src/rb-audio-transcription", develop = true }
2929

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

3233

3334

src/rb-api/rb/api/main.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
from logging.config import dictConfig
21
import multiprocessing
32
import os
4-
import logging
53
import sys
6-
from starlette.middleware.base import BaseHTTPMiddleware
74
from fastapi import FastAPI
85
from fastapi.staticfiles import StaticFiles
96
from rb.api import routes

src/rb-api/rb/api/routes/cli.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def wrapper(*args, **kwargs) -> ResponseBody:
157157
)
158158
# FIXME: prefix /api to make desktop call happy for now , eventually this will go away
159159
# GOAL : /audio/routes is valid /api/routes should no longer work
160-
cli_to_api_router.include_router(router,prefix=f'/api', tags=[plugin.name])
160+
cli_to_api_router.include_router(router,prefix='/api', tags=[plugin.name])
161161

162162
logger.debug(f"Registering FastAPI route for {plugin.name} desktop call: {command.callback.__name__}")
163163
else:

src/rb-api/rb/api/utils.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
from typing import Any, Callable
21
import argparse
2+
from typing import Any, Callable
3+
34
from rb.api.models import FloatRangeDescriptor, IntRangeDescriptor
45

56

67
def get_int_range_check_func_arg_parser(range: IntRangeDescriptor) -> Callable[[Any], int]:
78
def check_func(value: Any) -> int:
89
try:
910
value = int(value)
10-
except:
11+
except Exception:
1112
raise argparse.ArgumentTypeError(f"{value} is not a valid integer")
1213
if value < range.min or value > range.max:
1314
raise argparse.ArgumentTypeError(f"{value} is not in the range [{range.min}, {range.max}]")
@@ -18,7 +19,7 @@ def get_float_range_check_func_arg_parser(range: FloatRangeDescriptor) -> Callab
1819
def check_func(value: Any) -> float:
1920
try:
2021
value = float(value)
21-
except:
22+
except Exception:
2223
raise argparse.ArgumentTypeError(f"{value} is not a valid float")
2324
if value < range.min or value > range.max:
2425
raise argparse.ArgumentTypeError(f"{value} is not in the range [{range.min}, {range.max}]")

src/rb-audio-transcription/rb_audio_transcription/main.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""audio transcribe plugin"""
2-
import sys, os
2+
import sys
33
import json
44
import logging
55
from pathlib import Path
@@ -8,7 +8,6 @@
88
from rb.api.models import (
99
BatchTextResponse,
1010
DirectoryInput,
11-
FileInput,
1211
FloatParameterDescriptor,
1312
InputSchema,
1413
InputType,
@@ -21,7 +20,6 @@
2120
TextParameterDescriptor,
2221
TextResponse,
2322
)
24-
from rb.api.models import BatchFileInput
2523
from rb.api.models import API_APPMETDATA, API_ROUTES, PLUGIN_SCHEMA_SUFFIX
2624
from rb.api.utils import (
2725
get_int_range_check_func_arg_parser,
@@ -190,7 +188,7 @@ def alternate_params_parser(p: str) -> ParameterSchema:
190188
# this fucntion is not used , just an example
191189
try:
192190
params = string_to_dict(p)
193-
logger.info(f"-----DEBUG parser ---")
191+
logger.info("-----DEBUG parser ---")
194192
range_object = IntRangeDescriptor(min=params["c"], max=params["d"])
195193
func = get_int_range_check_func_arg_parser(range_object)
196194
if func(params["e"]):
@@ -221,15 +219,15 @@ def validate_inputs(inputs: DirInputs):
221219
files = [file for file in dirpath.iterdir() if file.is_file()]
222220
logger.debug(files)
223221
if len(files) < 1:
224-
raise HTTPException(status_code=400, detail=f"no 'files_in given directory' for transcribe command")
222+
raise HTTPException(status_code=400, detail="no 'files_in given directory' for transcribe command")
225223
logger.debug("------validate inputs done ---")
226224
## this return object is now ready for use in transcribe function
227225
return inputs
228226
except (Exception) as e:
229227
logger.error("validate bad inputs: %s", e)
230228
raise HTTPException(status_code=400, detail=f"Invalid path inputs for transcribe command: {e}")
231229

232-
@app.command(f'transcribe')
230+
@app.command('transcribe')
233231
def transcribe(
234232
inputs: Annotated[
235233
DirInputs,

src/rb-audio-transcription/tests/test_main.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@
2424
def test_routes_command():
2525
''' call typer cli to get routes'''
2626
result = runner.invoke(cli_app, [API_ROUTES])
27-
assert result is not ""
27+
assert result != ""
2828
assert result.exit_code == 0
2929

3030

3131
def test_metadata_command():
3232
result = runner.invoke(cli_app, [API_APPMETDATA])
33-
assert result is not ""
33+
assert result != ""
3434
assert result.exit_code == 0
3535

3636

3737
def test_schema_command():
3838
result = runner.invoke(cli_app, [f"task{PLUGIN_SCHEMA_SUFFIX}"])
39-
assert result is not ""
39+
assert result != ""
4040
assert result.exit_code == 0
4141

4242
def test_negative_test():

src/rb-doc-parser/rb_doc_parser/main.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import typer
2-
from rb.lib.docs import DOCS_GITHUB_URL, download_reference_doc # type: ignore
2+
from rb.lib.docs import BASE_WIKI_URL, download_all_wiki_pages # type: ignore
33
from rb.lib.ollama import use_ollama # type: ignore
44
from rb_doc_parser.chat import load_chat_config, stream_output
55

@@ -11,8 +11,8 @@ def open() -> str:
1111
"""
1212
Open docs in the browser
1313
"""
14-
typer.launch(DOCS_GITHUB_URL)
15-
return DOCS_GITHUB_URL
14+
typer.launch(BASE_WIKI_URL)
15+
return BASE_WIKI_URL
1616

1717

1818
@use_ollama
@@ -23,7 +23,7 @@ def ask(
2323
"""
2424
Ask a question against the docs
2525
"""
26-
reference_doc = download_reference_doc()
26+
reference_doc = download_all_wiki_pages()
2727
chat_config = load_chat_config()
2828
chat_config["prompt"]["system"] = chat_config["prompt"]["system"].format(
2929
reference_doc=reference_doc

0 commit comments

Comments
 (0)