Skip to content

Refactor API endpoints #386

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

Closed
wants to merge 2 commits into from
Closed
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
1 change: 0 additions & 1 deletion src/murfey/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

import murfey
import murfey.server.prometheus as prom
import murfey.server.websocket
from murfey.client.contexts.tomo import _midpoint
from murfey.server.murfey_db import url # murfey_db
from murfey.util.config import (
Expand Down
4 changes: 2 additions & 2 deletions src/murfey/server/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
from sqlmodel import col, select
from werkzeug.utils import secure_filename

import murfey.server.api.websocket as ws
import murfey.server.ispyb
import murfey.server.prometheus as prom
import murfey.server.websocket as ws
import murfey.util.eer
from murfey.client.contexts.tomo import _midpoint
from murfey.server import (
_midpoint,
_murfey_id,
_transport_object,
check_tilt_series_mc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
T = TypeVar("T")

ws = APIRouter(prefix="/ws", tags=["websocket"])
log = logging.getLogger("murfey.server.websocket")
log = logging.getLogger("murfey.server.api.websocket")


class ConnectionManager(Generic[T]):
Expand Down
6 changes: 3 additions & 3 deletions src/murfey/server/demo_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from werkzeug.utils import secure_filename

import murfey.server.api.bootstrap
import murfey.server.api.websocket as ws

Check warning on line 24 in src/murfey/server/demo_api.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/server/demo_api.py#L24

Added line #L24 was not covered by tests
import murfey.server.prometheus as prom
import murfey.server.websocket as ws
import murfey.util.eer
from murfey.server import (
_flush_grid_square_records,
Expand Down Expand Up @@ -1067,7 +1067,7 @@
.where(SPARelionParameters.pj_id == collected_ids[2].id)
.where(SPAFeedbackParameters.pj_id == SPARelionParameters.pj_id)
).one()
proc_params: dict | None = dict(params[0])
proc_params: Optional[dict] = dict(params[0])

Check warning on line 1070 in src/murfey/server/demo_api.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/server/demo_api.py#L1070

Added line #L1070 was not covered by tests
feedback_params = params[1]
except sqlalchemy.exc.NoResultFound:
proc_params = None
Expand Down Expand Up @@ -1281,7 +1281,7 @@
def suggest_path(
visit_name: str, session_id: int, params: SuggestedPathParameters, db=murfey_db
):
count: int | None = router.raw_count
count: Optional[int] = router.raw_count

Check warning on line 1284 in src/murfey/server/demo_api.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/server/demo_api.py#L1284

Added line #L1284 was not covered by tests
instrument_name = (
db.exec(select(Session).where(Session.id == session_id)).one().instrument_name
)
Expand Down
2 changes: 1 addition & 1 deletion src/murfey/server/ispyb.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def do_buffer_lookup(self, app_id: int, uuid: int) -> Optional[int]:
return reference


def _get_session() -> sqlalchemy.orm.Session:
def _get_session() -> sqlalchemy.orm.Session: # type: ignore
db = Session()
try:
yield db
Expand Down
4 changes: 2 additions & 2 deletions src/murfey/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import murfey.server.api.hub
import murfey.server.api.instrument
import murfey.server.api.spa
import murfey.server.websocket
import murfey.server.api.websocket
import murfey.util.models
from murfey.server import template_files
from murfey.util.config import get_security_config
Expand Down Expand Up @@ -80,7 +80,7 @@ class Settings(BaseSettings):
app.include_router(murfey.server.api.display.router)
app.include_router(murfey.server.api.instrument.router)
app.include_router(murfey.server.api.hub.router)
app.include_router(murfey.server.websocket.ws)
app.include_router(murfey.server.api.websocket.ws)

for r in entry_points(group="murfey.routers"):
app.include_router(r.load())