Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
* make uvicorn a dependency

* change when ci runs

* fix fetch multiple params with optional body
  • Loading branch information
dperl-dls committed Aug 13, 2024
1 parent fb0e6de commit af30194
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/backend_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ name: backend CI
on:
push:
paths:
- gui/**
- pyproject.toml
- src/**
- tests/**
pull_request:
paths:
- gui/**
- pyproject.toml
- src/**
- tests/**

jobs:
check:
Expand Down
23 changes: 10 additions & 13 deletions .github/workflows/gui_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,25 @@ name: GUI CI
on:
push:
paths:
- src/**
- tests/**
- gui/**
pull_request:
paths:
- src/**
- tests/**
- gui/**

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ readme = "README.md"
requires-python = ">=3.11"

[project.optional-dependencies]
server = ["fastapi", "redis", "hiredis"]
server = ["fastapi", "uvicorn", "redis", "hiredis"]
dev = [
"copier",
"httpx",
Expand Down
18 changes: 13 additions & 5 deletions src/daq_config_server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ParamList(BaseModel):


@app.get(ENDPOINTS.BL_PARAM)
def get_all_beamline_parameters(param_list_data: ParamList | None):
def get_all_beamline_parameters(param_list_data: ParamList | None = None):
"""Get a dict of all the current beamline parameters."""
assert BEAMLINE_PARAMS is not None
if param_list_data is None:
Expand Down Expand Up @@ -140,12 +140,20 @@ async def catch_all(request: Request, full_path: str):
}


def main(args):
global BEAMLINE_PARAM_PATH
def _load_beamline_params():
global BEAMLINE_PARAMS
if args.dev:
BEAMLINE_PARAMS = GDABeamlineParameters.from_file(BEAMLINE_PARAM_PATH)


def _set_beamline_param_path(dev: bool = True):
global BEAMLINE_PARAM_PATH
if dev:
BEAMLINE_PARAM_PATH = "tests/test_data/beamline_parameters.txt"
else:
BEAMLINE_PARAM_PATH = BEAMLINE_PARAMETER_PATHS["i03"]
BEAMLINE_PARAMS = GDABeamlineParameters.from_file(BEAMLINE_PARAM_PATH)


def main(args):
_set_beamline_param_path(args.dev)
_load_beamline_params()
uvicorn.run(app="daq_config_server.app:app", host="0.0.0.0", port=8555)
6 changes: 4 additions & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from fastapi.testclient import TestClient
from mockito import when

from daq_config_server.app import app
from daq_config_server import app
from daq_config_server.beamline_parameters import GDABeamlineParameters
from daq_config_server.constants import ENDPOINTS

Expand All @@ -17,7 +17,9 @@

@pytest.fixture
def mock_app():
return TestClient(app)
app._set_beamline_param_path(True)
app._load_beamline_params()
return TestClient(app.app)


async def _assert_get_and_response(
Expand Down

0 comments on commit af30194

Please sign in to comment.