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

Bump dls-dodal from 1.25.0 to 1.26.0 in the dev-dependencies group #2

Merged
merged 2 commits into from
Jun 4, 2024
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
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.7"

[project.optional-dependencies]
server = ["fastapi", "redis", "hiredis", "dls-dodal==1.25.0"]
server = ["fastapi", "redis", "hiredis", "dls-dodal==1.26.0"]
dev = [
"copier",
"pipdeptree",
Expand Down
45 changes: 7 additions & 38 deletions src/config_service/__main__.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,18 @@
from argparse import ArgumentParser

from fastapi import dependencies

from . import __version__
from .constants import ENDPOINTS

try:
import redis
import uvicorn
from dodal.beamlines.beamline_parameters import (
BEAMLINE_PARAMETER_PATHS,
GDABeamlineParameters,
)
from fastapi import FastAPI

app = FastAPI()
valkey = redis.Redis(host="localhost", port=6379, decode_responses=True)
import redis # noqa
import uvicorn # noqa
from fastapi import FastAPI # noqa

server_dependencies_exist = True
except ImportError:
server_dependencies_exist = False

__all__ = ["main"]

BEAMLINE_PARAM_PATH = ""
BEAMLINE_PARAMS: GDABeamlineParameters | None = None


@app.get(ENDPOINTS.BL_PARAM + "{item_id}")
def beamlineparameter(item_id: str):
assert BEAMLINE_PARAMS is not None
return {item_id: BEAMLINE_PARAMS.params.get(item_id)}


@app.post(ENDPOINTS.FEATURE + "{item_id}")
def set_featureflag(item_id: str, value: bool):
return {"success": valkey.set(item_id, int(value))}


@app.get(ENDPOINTS.FEATURE + "{item_id}")
def get_featureflag(item_id: str):
ret = int(valkey.get(item_id)) # type: ignore
return {item_id: bool(ret) if ret is not None else None, "raw": ret}
__all__ = ["main"]


def main():
Expand All @@ -57,12 +28,10 @@ def main():
"importing the client, you must install this package with [server] "
"optional dependencies"
)
if args.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)
uvicorn.run(app="config_service.__main__:app", host="0.0.0.0", port=8555)
from .app import main

main(args)


# test with: python -m config_service
Expand Down
Loading