Skip to content

Commit

Permalink
Add simple output to optimizer request
Browse files Browse the repository at this point in the history
  • Loading branch information
langdal committed Apr 19, 2021
1 parent e04fbaf commit 5811799
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ Alternatively the project can be build and run with the following commands:

Now open [http://localhost:9090/v1.0/ui/](http://localhost:9090/v1.0/ui/) in a browser to explore the API through Swagger UI

# Running tests

Unit tetsts are located in the "tests" folder and can be run witht the following command

python -m pytest
28 changes: 27 additions & 1 deletion optimizerapi/openapi/specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,37 @@ paths:
responses:
'200':
description: Result of running the optimizer with the specified parameters
content:
text/plain:
schema:
type: string
example: hello
parameters:
- name: params
in: query
description: Parameters for the optimizer
required: false
schema:
type: string
example: "test"
example: "[1,2,3]"
- name: Xi
in: query
description: "Xi value to be passed to ProcessOptimizer"
required: false
schema:
type: number
example: 0.01
- name: yi
in: query
description: "yi value to be passed to ProcessOptimizer"
required: false
schema:
type: number
example: 1.0
- name: kappa
in: query
description: "Kappa value to be passed to ProcessOptimizer"
required: false
schema:
type: number
example: 1.96
2 changes: 1 addition & 1 deletion optimizerapi/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def run(params: str = None, Xi: [float] = [0.01], yi: [Number] = [1], kappa: flo
}
optimizer = Optimizer(space, **hyperparams)
# TODO call optimizer with proper Xi and Yi values
result = optimizer.tell(Xi, yi)
result = optimizer.tell([Xi], yi)
if params:
return 'Run with {params} = {result}'.format(params=params, result=result)
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
def test_first_sample():
Xi = [0.01]
yi = 1
result = optimizer.run(params=None, Xi=Xi, yi=yi)
result = optimizer.run(params="{}", Xi=Xi, yi=yi)
print(result)
assert "Run with" in result

0 comments on commit 5811799

Please sign in to comment.