From a900b84d69c7403ecc5696453b313451b11e781a Mon Sep 17 00:00:00 2001 From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de> Date: Mon, 3 May 2021 22:00:09 +0200 Subject: [PATCH] minor code enhancements --- slope-evaluator/README.md | 22 ++++++++++--------- slope-evaluator/app/main.py | 12 +++------- .../theodolite/evaluation/AnalysisExecutor.kt | 2 +- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/slope-evaluator/README.md b/slope-evaluator/README.md index 5929fb157..25178d713 100644 --- a/slope-evaluator/README.md +++ b/slope-evaluator/README.md @@ -5,7 +5,7 @@ For development: ```sh -uvicorn main:app --reload +uvicorn main:app --reload # run this command inside the app/ folder ``` Build the docker image: @@ -32,7 +32,7 @@ The running webserver provides a REST API with the following route: * /evaluate-slope * Method: POST * Body: - * total_lag + * total_lags * threshold * warmup @@ -40,14 +40,16 @@ The body of the request must be a JSON string that satisfies the following condi * **total_lag**: This property is based on the [Range Vector type](https://www.prometheus.io/docs/prometheus/latest/querying/api/#range-vectors) from Prometheus and must have the following JSON structure: ``` - { - "metric": { - "group": "<label_value>" - }, - "values": [ - [ - <unix_timestamp>, - "<sample_value>" + { + [ + "metric": { + "group": "<label_value>" + }, + "values": [ + [ + <unix_timestamp>, + "<sample_value>" + ] ] ] } diff --git a/slope-evaluator/app/main.py b/slope-evaluator/app/main.py index 13df2481a..48e9c6100 100644 --- a/slope-evaluator/app/main.py +++ b/slope-evaluator/app/main.py @@ -46,13 +46,7 @@ def execute(results, threshold, warmup): @app.post("/evaluate-slope",response_model=bool) async def evaluate_slope(request: Request): data = json.loads(await request.body()) - results = [] - for total_lag in data['total_lags']: - results.append(execute(total_lag, data['threshold'], data['warmup'] )) - - for result in results: - if not result: - return False - return True + results = [execute(total_lag, data['threshold'], data['warmup']) for total_lag in data['total_lags']] + return all(results) -logger.info("Slope evaluator is online") \ No newline at end of file +logger.info("SLO evaluator is online") \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt index 7037e8856..59a793bd7 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt @@ -52,7 +52,7 @@ class AnalysisExecutor( val fileName= "${resultsFolder}exp${executionId}_${load.get()}_${res.get()}_${slo.sloType.toSlug()}" prometheusData.forEach{ data -> - exporter.toCsv(name = "${fileName}_rep_${repetitionCounter++}", prom = data) } + exporter.toCsv(name = "${fileName}_${repetitionCounter++}", prom = data) } val sloChecker = SloCheckerFactory().create( -- GitLab