Subaru-PFS / spt_target_uploader

A web application to validate and upload target lists with pointing simulations for PFS observation
https://pfs-etc.naoj.hawaii.edu/uploader/
MIT License
1 stars 0 forks source link

`UnboundLocalError` for a specific input list #313

Open monodera opened 2 months ago

monodera commented 2 months ago

Describe the bug When I used cosmos_001000.csv as an input target list, the online PPP raise an UnboundLocalError as follows. This does not happen with cosmos_002000.csv.

ERROR:bokeh.server.protocol_handler:error handling message
 message: Message 'PATCH-DOC' content: {'events': [{'kind': 'MessageSent', 'msg_type': 'bokeh_event', 'msg_data': {'type': 'event', 'name': 'button_click', 'values': {'type': 'map', 'entries': [['model', {'id': 'p1211'}]]}}}]}
 error: UnboundLocalError("cannot access local variable 'status' where it is not associated with a value")
Traceback (most recent call last):
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/bokeh/server/protocol_handler.py", line 97, in handle
    work = await handler(message, connection)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/bokeh/server/session.py", line 94, in _needs_document_lock_wrapper
    result = func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/bokeh/server/session.py", line 286, in _handle_patch
    message.apply_to_document(self.document, self)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/bokeh/protocol/messages/patch_doc.py", line 104, in apply_to_document
    invoke_with_curdoc(doc, lambda: doc.apply_json_patch(self.payload, setter=setter))
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/bokeh/document/callbacks.py", line 444, in invoke_with_curdoc
    return f()
           ^^^
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/bokeh/protocol/messages/patch_doc.py", line 104, in <lambda>
    invoke_with_curdoc(doc, lambda: doc.apply_json_patch(self.payload, setter=setter))
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/bokeh/document/document.py", line 391, in apply_json_patch
    DocumentPatchedEvent.handle_event(self, event, setter)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/bokeh/document/events.py", line 245, in handle_event
    event_cls._handle_event(doc, event)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/bokeh/document/events.py", line 280, in _handle_event
    cb(event.msg_data)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/bokeh/document/callbacks.py", line 391, in trigger_event
    model._trigger_event(event)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/bokeh/util/callback_manager.py", line 113, in _trigger_event
    self.document.callbacks.notify_event(cast(Model, self), event, invoke)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/bokeh/document/callbacks.py", line 261, in notify_event
    invoke_with_curdoc(doc, callback_invoker)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/bokeh/document/callbacks.py", line 444, in invoke_with_curdoc
    return f()
           ^^^
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/bokeh/util/callback_manager.py", line 109, in invoke
    cast(EventCallbackWithEvent, callback)(event)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/panel/reactive.py", line 501, in _server_event
    self._comm_event(doc, event)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/panel/reactive.py", line 488, in _comm_event
    state._handle_exception(e)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/panel/io/state.py", line 458, in _handle_exception
    raise exception
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/panel/reactive.py", line 486, in _comm_event
    self._process_bokeh_event(doc, event)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/panel/reactive.py", line 423, in _process_bokeh_event
    self._process_event(event)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/panel/widgets/button.py", line 242, in _process_event
    self.clicks += 1
    ^^^^^^^^^^^
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/param/parameterized.py", line 528, in _f
    instance_param.__set__(obj, val)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/param/parameterized.py", line 530, in _f
    return f(self, obj, val)
           ^^^^^^^^^^^^^^^^^
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/param/parameters.py", line 543, in __set__
    super().__set__(obj,val)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/param/parameterized.py", line 530, in _f
    return f(self, obj, val)
           ^^^^^^^^^^^^^^^^^
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/param/parameterized.py", line 1553, in __set__
    obj.param._call_watcher(watcher, event)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/param/parameterized.py", line 2526, in _call_watcher
    self_._execute_watcher(watcher, (event,))
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/.venv/lib/python3.11/site-packages/param/parameterized.py", line 2506, in _execute_watcher
    watcher.fn(*args, **kwargs)
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/src/pfs_target_uploader/pn_app.py", line 435, in cb_PPP
    panel_ppp.run_ppp(
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/src/pfs_target_uploader/widgets/PppResultWidgets.py", line 320, in run_ppp
    ) = PPPrunStart(
        ^^^^^^^^^^^^
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/src/pfs_target_uploader/utils/ppp.py", line 1106, in PPPrunStart
    obj_allo_M_fin, status_ = netflow_iter(
                              ^^^^^^^^^^^^^
  File "/Users/monodera/Dropbox/NAOJ/PFS/spt_target_uploader/src/pfs_target_uploader/utils/ppp.py", line 955, in netflow_iter
    return obj_allo, status
                     ^^^^^^
UnboundLocalError: cannot access local variable 'status' where it is not associated with a value

It seems that the status variable is not defined in this specific if statement.

Computer Environment:

wanqqq31 commented 2 months ago

sorry for my late response. I fixed the bug under issue/313-status-error branch.

monodera commented 2 months ago

Thanks! I'll merge it.