Skip to content

Fix redis for later started workers #410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions pyabc/sampler/redis_eps/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,30 @@ def _work(host="localhost", port=6379, runtime="2h", password=None,
except AttributeError:
data = msg["data"]

if data == START:
# extract population definition
# analysis id
analysis_id = str(redis.get(ANALYSIS_ID).decode())
if data == START or isinstance(data, int):
# Sometimes, redis weirdly only publishes an int (1) at the
# beginning, but not the actual START message if the workers
# were started later.
# Therefore make sure all variables are really there.

# analysis id
analysis_id_b = redis.get(ANALYSIS_ID)
if analysis_id_b is None:
continue
analysis_id = str(analysis_id_b.decode())

# current time index
t = int(redis.get(idfy(GENERATION, analysis_id)).decode())
mode = str(redis.get(idfy(MODE, analysis_id, t)).decode())
t_b = redis.get(idfy(GENERATION, analysis_id))
if t_b is None:
continue
t = int(t_b.decode())

# parallelization mode
mode_b = redis.get(idfy(MODE, analysis_id, t))
if mode_b is None:
continue
mode = str(mode_b.decode())

# work on the specified population in dynamic or static mode
if mode == DYNAMIC:
work_on_population_dynamic(
Expand Down