-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add beamlineparameters from file and feature flags from redis
- Loading branch information
Showing
3 changed files
with
22 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM valkey/valkey:7.2.5-alpine3.19 | ||
|