tidy3d icon indicating copy to clipboard operation
tidy3d copied to clipboard

Add timeout to web functions

Open tylerflex opened this issue 2 years ago • 5 comments

Running the linter, it complains that the requests calls don't have a timeout. Could we add these if applicable? For now, I disabled the missing-timeout in the .pylintrc file, so we can remove that when this is fixed.

************* Module tidy3d.plugins.dispersion.fit
tidy3d/plugins/dispersion/fit.py:649:15: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)
************* Module tidy3d.plugins.dispersion.fit_web
tidy3d/plugins/dispersion/fit_web.py:157:15: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)
tidy3d/plugins/dispersion/fit_web.py:164:15: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)
tidy3d/plugins/dispersion/fit_web.py:265:15: W3101: Missing timeout argument for method 'requests.post' can cause your program to hang indefinitely (missing-timeout)
************* Module tidy3d.web.httputils
tidy3d/web/httputils.py:90:11: W3101: Missing timeout argument for method 'requests.post' can cause your program to hang indefinitely (missing-timeout)
tidy3d/web/httputils.py:98:11: W3101: Missing timeout argument for method 'requests.put' can cause your program to hang indefinitely (missing-timeout)
tidy3d/web/httputils.py:106:11: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)
tidy3d/web/httputils.py:114:11: W3101: Missing timeout argument for method 'requests.delete' can cause your program to hang indefinitely (missing-timeout)
************* Module tidy3d.web.auth
tidy3d/web/auth.py:28:11: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)

tylerflex avatar Aug 26 '22 15:08 tylerflex

I'm not sure what is the right number for timeout, due to Weiliang's requirement, fit method could run in couple of minutes. If the number is less than that, it will be forcely interrupted. @weiliangjin2021 do you have any idea about this?

In the meanwhile, the web version of fitting is online, I'm planning to add the api into python client, hence we could retire this fitter from it.

an-li-the-dev avatar Aug 29 '22 01:08 an-li-the-dev

ok, I think just an upper bound would be ok for the fitter. Note that the main webapi Simulation functions also require timeout parameter (web.upload() for example).

tylerflex avatar Aug 29 '22 08:08 tylerflex

Can we have different timeout values for different functions?

weiliangjin2021 avatar Aug 29 '22 16:08 weiliangjin2021

Yea, it's just a kwarg to requests.get, requests.post, etc. https://requests.readthedocs.io/en/latest/api/#requests.request see timeout

tylerflex avatar Aug 29 '22 17:08 tylerflex

I think we can set the timeout for fitter to be 2 min.

weiliangjin2021 avatar Aug 30 '22 04:08 weiliangjin2021

consolidating in #544

tylerflex avatar Oct 08 '22 11:10 tylerflex