Skip to content

Commit b38df32

Browse files
authored
Merge branch 'main' into control-worker-timeout
2 parents cd1717e + d52d9b4 commit b38df32

File tree

7 files changed

+50
-269
lines changed

7 files changed

+50
-269
lines changed

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
# Changelog
22

3-
## [v3.5.4](https://github.com/BoostV/process-optimizer-api/tree/HEAD)
3+
## [v3.6.0](https://github.com/BoostV/process-optimizer-api/tree/v3.6.0) (2024-11-18)
4+
5+
[Full Changelog](https://github.com/BoostV/process-optimizer-api/compare/v3.5.5...v3.6.0)
6+
7+
**Merged pull requests:**
8+
9+
- Update to ProcessOptimizer 1.0.2 [\#86](https://github.com/BoostV/process-optimizer-api/pull/86) ([langdal](https://github.com/langdal))
10+
11+
## [v3.5.5](https://github.com/BoostV/process-optimizer-api/tree/v3.5.5) (2024-11-08)
12+
13+
[Full Changelog](https://github.com/BoostV/process-optimizer-api/compare/v3.5.4...v3.5.5)
14+
15+
**Merged pull requests:**
16+
17+
- Update to ProcessOptimizer 1.0.0 [\#85](https://github.com/BoostV/process-optimizer-api/pull/85) ([langdal](https://github.com/langdal))
18+
19+
## [v3.5.4](https://github.com/BoostV/process-optimizer-api/tree/v3.5.4) (2024-05-08)
420

521
[Full Changelog](https://github.com/BoostV/process-optimizer-api/compare/v3.5.3...v3.5.4)
622

optimizerapi/optimizer.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
The handler functions are mapped to the OpenAPI specification through the "operationId" field
55
in the specification.yml file found in the folder "openapi" in the root of this project.
66
"""
7+
78
import os
89
import platform
910
import time
@@ -21,14 +22,18 @@
2122
from rq.command import send_stop_job_command
2223
from redis import Redis
2324
from ProcessOptimizer import Optimizer, expected_minimum
24-
from ProcessOptimizer.plots import plot_objective, plot_convergence, plot_Pareto
25+
from ProcessOptimizer.plots import (
26+
plot_objective,
27+
plot_convergence,
28+
plot_Pareto,
29+
plot_brownie_bee_frontend,
30+
)
2531
from ProcessOptimizer.space import Real
2632
from ProcessOptimizer.space.constraints import SumEquals
2733
import matplotlib.pyplot as plt
2834
import numpy
2935
import connexion
3036

31-
from optimizerapi.plot_patch import plot_brownie_bee
3237
from .securepickle import pickleToString, get_crypto
3338

3439
numpy.random.seed(42)
@@ -82,7 +87,7 @@ def disconnect_check():
8287
except NoSuchJobError:
8388
print("Creating new job")
8489
job = queue.enqueue(do_run_work, body, job_id=job_id, result_ttl=TTL, timeout=WORKER_TIMEOUT)
85-
while job.return_value is None:
90+
while job.return_value() is None:
8691
if disconnect_check():
8792
try:
8893
print(f"Client disconnected, cancelling job {job.id}")
@@ -93,7 +98,7 @@ def disconnect_check():
9398
pass
9499
return {}
95100
time.sleep(0.2)
96-
return job.return_value
101+
return job.return_value()
97102
return do_run_work(body)
98103

99104

@@ -124,11 +129,13 @@ def __handle_run(body) -> dict:
124129
)
125130
space = [
126131
(
127-
convert_number_type(x["from"], x["type"]),
128-
convert_number_type(x["to"], x["type"]),
132+
(
133+
convert_number_type(x["from"], x["type"]),
134+
convert_number_type(x["to"], x["type"]),
135+
)
136+
if (x["type"] == "discrete" or x["type"] == "continuous")
137+
else tuple(x["categories"])
129138
)
130-
if (x["type"] == "discrete" or x["type"] == "continuous")
131-
else tuple(x["categories"])
132139
for x in cfg["space"]
133140
]
134141
dimensions = [x["name"] for x in cfg["space"]]
@@ -248,9 +255,10 @@ def process_result(result, optimizer, dimensions, cfg, extras, data, space):
248255
if "experimentSuggestionCount" in extras:
249256
experiment_suggestion_count = extras["experimentSuggestionCount"]
250257

251-
252258
if "constraints" in cfg and len(cfg["constraints"]) > 0:
253-
next_exp = optimizer.ask(n_points=experiment_suggestion_count, strategy="cl_min")
259+
next_exp = optimizer.ask(
260+
n_points=experiment_suggestion_count, strategy="cl_min"
261+
)
254262
else:
255263
next_exp = optimizer.ask(n_points=experiment_suggestion_count)
256264
if len(next_exp) > 0 and not any(isinstance(x, list) for x in next_exp):
@@ -264,7 +272,7 @@ def process_result(result, optimizer, dimensions, cfg, extras, data, space):
264272
if graph_format == "png":
265273
for idx, model in enumerate(result):
266274
if "single" in graphs_to_return:
267-
bb_plots = plot_brownie_bee(model, max_quality=max_quality)
275+
bb_plots = plot_brownie_bee_frontend(model, max_quality=max_quality)
268276
for i, plot in enumerate(bb_plots):
269277
pic_io_bytes = io.BytesIO()
270278
plot.savefig(pic_io_bytes, format="png")

optimizerapi/plot_patch.py

Lines changed: 0 additions & 217 deletions
This file was deleted.

optimizerapi/worker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Worker that will run all tasks published to redis using RQ
33
"""
44
import os
5-
from rq import Connection, Queue, Worker
5+
from rq import Queue, Worker
66
from redis import Redis
77

88

@@ -12,6 +12,6 @@
1212
REDIS_URL = "redis://localhost:6379"
1313

1414
if __name__ == "__main__":
15-
with Connection(Redis.from_url(REDIS_URL)):
16-
queue = Queue()
17-
Worker(queue).work()
15+
redis = Redis.from_url(REDIS_URL)
16+
queue = Queue(connection=redis)
17+
Worker(queue).work()

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
-r requirements.txt
2-
pytest==6.2.2
2+
pytest==8.3.3
33
pytest-watch==4.2.0

0 commit comments

Comments
 (0)