-
Notifications
You must be signed in to change notification settings - Fork 1
Consolidate Instrument Protocols #128
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
base: master
Are you sure you want to change the base?
Changes from all commits
ed87adf
ece9077
0775317
fecc67d
092bfc8
f2227dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,65 @@ | ||
| name: Code quality | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| lockfile: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: astral-sh/setup-uv@v4 | ||
| - uses: actions/checkout@v5 | ||
| - uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| enable-cache: true | ||
| - run: uv lock --locked | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| needs: [lockfile] | ||
| needs: lockfile | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: astral-sh/setup-uv@v4 | ||
| - uses: actions/checkout@v5 | ||
| - uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| enable-cache: true | ||
| - run: uv run ruff check | ||
| format: | ||
| runs-on: ubuntu-latest | ||
| needs: [lockfile] | ||
| needs: lockfile | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: astral-sh/setup-uv@v4 | ||
| - uses: actions/checkout@v5 | ||
| - uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| enable-cache: true | ||
| - run: uv sync --locked --all-extras --dev | ||
| - run: uv run ruff format --check | ||
| typecheck: | ||
| runs-on: ubuntu-latest | ||
| needs: [lockfile] | ||
| needs: lockfile | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: astral-sh/setup-uv@v4 | ||
| - run: uv sync --extra webapp | ||
| - uses: actions/checkout@v5 | ||
| - uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| enable-cache: true | ||
| - run: uv sync --locked --all-extras --dev | ||
| - run: uv run mypy | ||
| tests: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| needs: [lockfile] | ||
| needs: lockfile | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: astral-sh/setup-uv@v4 | ||
| - run: uv run pytest -v --durations=0 | ||
| - uses: actions/checkout@v5 | ||
| - uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| enable-cache: true | ||
| - run: uv run scripts/test | ||
| build: | ||
| runs-on: [ubuntu-latest] | ||
| needs: [lint, format, typecheck, tests] | ||
| runs-on: ubuntu-latest | ||
| needs: [lint, format, typecheck, test] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: astral-sh/setup-uv@v4 | ||
| - uses: actions/checkout@v5 | ||
| - uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| enable-cache: true | ||
| - run: uv build |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/usr/bin/env bash | ||
| set -eux | ||
|
|
||
| ruff format src | ||
| ruff check src --fix |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/usr/bin/env bash | ||
| set -eux | ||
|
|
||
| mypy | ||
| ruff format src --check | ||
| ruff check src |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/usr/bin/env bash | ||
| set -eux | ||
|
|
||
| coverage run -m pytest | ||
| coverage report | ||
| coverage html --title "${@-coverage}" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,10 +4,21 @@ | |
| import httpx | ||
| from fastapi import Depends | ||
|
|
||
| from pqnstack.app.core.config import settings | ||
| from pqnstack.network.client import Client | ||
|
|
||
|
|
||
| async def get_http_client() -> AsyncGenerator[httpx.AsyncClient, None]: | ||
| async with httpx.AsyncClient(timeout=600_000) as client: | ||
| async with httpx.AsyncClient(timeout=60) as client: | ||
| yield client | ||
|
|
||
|
|
||
| type ClientDep = Annotated[httpx.AsyncClient, Depends(get_http_client)] | ||
|
|
||
|
|
||
| async def get_instrument_client() -> AsyncGenerator[Client, None]: | ||
| async with Client(host=settings.router_address, port=settings.router_port, timeout=60) as client: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. timeout is still in ms, if we want to switch to seconds, we need to make that conversion in the client file itself before setting the default
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can leave it in ms for now. We can think about if we want to switch later. |
||
| yield client | ||
|
|
||
|
|
||
| ClientDep = Annotated[httpx.AsyncClient, Depends(get_http_client)] | ||
| type InstrumentClientDep = Annotated[httpx.AsyncClient, Depends(get_instrument_client)] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a way of specifying the timeout for for different instrument clients. Specially if we are using this to get the timetagger since that timeout is longer than other instruments.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can make
timeouta parameter ofget_device. We could also pre-bake dependencies for particularInstruments if we always want the same timeout for the sameInstrument, but keeping it as an argument ofget_deviceis more flexible.In that case, do we still need to be able to set the
timeoutfor theClient?