def get_request_state_from_pond_blocks(request_state, acceptability_threshold, request_blocks):
active_blocks = False
future_blocks = False
now = timezone.now()
for block in request_blocks:
start_time = dateutil.parser.parse(block['start']).replace(tzinfo=timezone.utc)
end_time = dateutil.parser.parse(block['end']).replace(tzinfo=timezone.utc)
# mark a block as complete if a % of the total exposures of all its molecules are complete
completion_percent = exposure_completion_percentage_from_pond_block(block)
if isclose(acceptability_threshold, completion_percent) or completion_percent >= acceptability_threshold:
return 'COMPLETED'
if (not block['canceled'] and not any(molecule['failed'] for molecule in block['molecules'])
and start_time < now < end_time):
active_blocks = True
if now < start_time:
future_blocks = True
if not (future_blocks or active_blocks):
return 'FAILED'
return request_state
评论列表
文章目录