Skip to content

Commit

Permalink
add beamlineparameters from file and feature flags from redis
Browse files Browse the repository at this point in the history
  • Loading branch information
dperl-dls committed May 23, 2024
1 parent c5a1bf5 commit 9e2e285
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ name = "config-service"
classifiers = [
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
description = "an service to put and get your config values from"
dependencies = [] # Add project dependencies here, e.g. ["click", "numpy"]
dependencies = ["fastapi", "hiredis", "dls-dodal"]
dynamic = ["version"]
license.file = "LICENSE"
readme = "README.md"
Expand Down
29 changes: 19 additions & 10 deletions src/config_service/__main__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
from argparse import ArgumentParser
import redis
from dodal.common.beamlines.beamline_parameters import (
BEAMLINE_PARAMETER_PATHS,
GDABeamlineParameters,
)
from fastapi import FastAPI

from . import __version__
app = FastAPI()
r = redis.Redis(host="localhost", port=6379, decode_responses=True)
beamline_params = GDABeamlineParameters.from_file(BEAMLINE_PARAMETER_PATHS["i03"])

__all__ = ["main"]

@app.get("/beamlineparameters/{item_id}")
def beamlineparameter(item_id: str):
return {item_id: beamline_params.params.get(item_id)}

def main(args=None):
parser = ArgumentParser()
parser.add_argument("-v", "--version", action="version", version=__version__)
args = parser.parse_args(args)

@app.post("/featureflag/{item_id}")
def set_featureflag(item_id: str, value):
return {item_id: r.set(item_id, value)}

# test with: python -m config_service
if __name__ == "__main__":
main()

@app.get("/featureflag/{item_id}")
def get_featureflag(item_id: str):
return {item_id: r.get(item_id)}
2 changes: 2 additions & 0 deletions valkey/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM valkey/valkey:7.2.5-alpine3.19

0 comments on commit 9e2e285

Please sign in to comment.