# Buggy code
def assign_operand_workers(self, op_keys, input_chunk_metas=None, analyzer=None):
    operand_infos = self._operand_infos
    chunk_graph = self.get_chunk_graph()

    if analyzer is None:
        analyzer = GraphAnalyzer(chunk_graph, self._get_worker_slots())
    assignments = analyzer.calc_operand_assignments(
        op_keys, input_chunk_metas=input_chunk_metas
    )
    for k, v in assignments.items():
        operand_infos[k]["target_worker"] = v
    return assignments


# Traceback (ValueError)
500 GET /worker?endpoint
Traceback (most recent call last):
File "/opt/conda/lib/python3.6/site-packages/tornado/web.py", line 1592, in _execute
result = yield result
File "/opt/conda/lib/python3.6/site-packages/tornado/gen.py", line 1133, in run
value = future.result()
File "/opt/conda/lib/python3.6/site-packages/tornado/gen.py", line 1147, in run
yielded = self.gen.send(value)
File "/opt/conda/lib/python3.6/site-packages/bokeh/server/views/doc_handler.py", line 27, in get
template_variables=session.document.template_variables)
File "/opt/conda/lib/python3.6/site-packages/bokeh/embed/server.py", line 230, in server_html_page_for_session
template=template, template_variables=template_variables)
File "/opt/conda/lib/python3.6/site-packages/bokeh/embed/elements.py", line 133, in html_page_for_render_items
html = template.render(context)
File "/opt/conda/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/opt/conda/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/opt/conda/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/opt/conda/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/home/admin/work/public-mars-0.2.0b1-cupid.zip/mars/web/templates/worker_detail.html", line 1, in top-level template code
{% extends "base.html" %}
File "/home/admin/work/public-mars-0.2.0b1-cupid.zip/mars/web/templates/base.html", line 65, in top-level template code
{% block body %}{% endblock %}
File "/home/admin/work/public-mars-0.2.0b1-cupid.zip/mars/web/templates/worker_detail.html", line 252, in block "body"
<td>{{ stats['min_est_finish_time'] | format_ts }}</td>
File "/home/admin/work/public-mars-0.2.0b1-cupid.zip/mars/web/server.py", line 49, in format_ts
return datetime.fromtimestamp(value).strftime('%Y-%m-%d %H:%M:%S')
ValueError: Invalid value NaN (not a number)
500 GET /worker?endpoint=10.101.216.148:53630 (10.101.202.142) 137.45ms

# Fixed code
def assign_operand_workers(self, op_keys, input_chunk_metas=None, analyzer=None):
    operand_infos = self._operand_infos
    chunk_graph = self.get_chunk_graph()

    if analyzer is None:
        analyzer = GraphAnalyzer(chunk_graph, self._get_worker_slots())
    assignments = analyzer.calc_operand_assignments(
        op_keys, input_chunk_metas=input_chunk_metas
    )
    for idx, (k, v) in enumerate(assignments.items()):
        operand_infos[k]["optimize"]["placement_order"] = idx
        operand_infos[k]["target_worker"] = v
    return assignments