tableau / TabPy

Execute Python code on the fly and display results in Tableau visualizations:
https://tableau.github.io/TabPy/
MIT License
1.56k stars 598 forks source link

Can not override the deployment #461

Closed GavinYang-LR closed 3 years ago

GavinYang-LR commented 3 years ago

When I deploy the same function in override mode, the error will raise

2020-11-05,22:59:37 [DEBUG] (state.py:state:616): Loading option 'demo_sum_v1' from section [Query Objects Docstrings]...
2020-11-05,22:59:37 [DEBUG] (state.py:state:638): Returning value '-- no docstring found in query function --'
2020-11-05,22:59:37 [DEBUG] (state.py:state:148): Collected endpoints: {'add_demo': {'description': 'add_demo', 'type': 'model', 'version': 8, 'dependencies': [], 'target': '', 'creation_time': 1604585045, 'last_modified_time': 1604585955, 'schema': None, 'docstring': '-- no docstring found in query function --'}, 'demo_sum': {'description': 'demo_sum', 'type': 'model', 'version': 1, 'dependencies': [], 'target': '', 'creation_time': 1604588290, 'last_modified_time': 1604588290, 'schema': None, 'docstring': '-- no docstring found in query function --'}, 'demo_sum_v1': {'description': 'demo_sum_v1', 'type': 'model', 'version': 1, 'dependencies': [], 'target': '', 'creation_time': 1604588371, 'last_modified_time': 1604588371, 'schema': None, 'docstring': '-- no docstring found in query function --'}}
2020-11-05,22:59:37 [ERROR] (state.py:state:178): ---------> Gavin Test <---------
2020-11-05,22:59:37 [ERROR] (state.py:state:179): None
2020-11-05,22:59:37 [ERROR] (state.py:state:180): None
2020-11-05,22:59:37 [ERROR] (state.py:state:363): Error in update_endpoint: target must be a string.
2020-11-05,22:59:37 [ERROR] (base_handler.py:base_handler:115): Responding with status=400, message="Error when changing TabPy state: target must be a string.", info="None"
2020-11-05,22:59:37 [WARNING] (web.py:web:2246): 400 PUT /endpoints/demo_sum_v1 (127.0.0.1) 11.34ms
2020-11-05,22:59:37 [ERROR] (web.py:web:1788): Uncaught exception PUT /endpoints/demo_sum_v1 (127.0.0.1)
HTTPServerRequest(protocol='http', host='127.0.0.1:9004', method='PUT', uri='/endpoints/demo_sum_v1', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tabpy/tabpy_server/handlers/endpoint_handler.py", line 81, in put
    self.finish()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tornado/web.py", line 1123, in finish
    raise RuntimeError("finish() called twice")
RuntimeError: finish() called twice

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tornado/web.py", line 1703, in _execute
    result = await result
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tornado/gen.py", line 748, in run
    yielded = self.gen.send(value)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tabpy/tabpy_server/handlers/endpoint_handler.py", line 88, in put
    self.error_out(500, err_msg)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tabpy/tabpy_server/handlers/base_handler.py", line 140, in error_out
    self.write(json.dumps({"message": log_message, "info": info or {}}))
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tornado/web.py", line 826, in write
    raise RuntimeError("Cannot write() after finish()")
RuntimeError: Cannot write() after finish()

I checked the code, when we first deploy the function the service will run _check_and_set_target(param,'') https://github.com/tableau/TabPy/blob/a45b4671ddbb74917ebf19be610e7c65bad7f833/tabpy/tabpy_server/management/state.py#L235 When we deploy override mode, the TabPy service will run _check_and_set_target(param, None) https://github.com/tableau/TabPy/blob/a45b4671ddbb74917ebf19be610e7c65bad7f833/tabpy/tabpy_server/management/state.py#L334 I realized that it will fail anyway, otherwise something wrong in my config?

0golovatyi commented 3 years ago

@GavinYang-LR Looks like a bug, thanks for reporting.

GavinYang-LR commented 3 years ago

@0golovatyi Hi Could you make a hotfix for this? I want to do but, don't have permission to push a branch.

0golovatyi commented 3 years ago

@GavinYang-LR You can create a merge request from your fork to the master branch.

I will try to work on it this week, but can't really promise.

0golovatyi commented 3 years ago

@GavinYang-LR I prepared this fix - https://github.com/tableau/TabPy/pull/462. If you could confirm it works for you.

0golovatyi commented 3 years ago

@GavinYang-LR I just published pre-release version of TabPy with the fix in it. You can update to it with pip install --upgrade -i https://test.pypi.org/simple/ tabpy command.

Let me know if it worked for you.

0golovatyi commented 3 years ago

Published tabpy 2.3.1 with the fix, closing the issue.

GavinYang-LR commented 3 years ago

@0golovatyi Hey man, Sorry missed tons of comments, going to test with the team today, appreciate hard work this week. Thanks