Open koettert opened 7 months ago
I just did a test on Mac M2 with KNIME 5.2.3, below is what I found,
import os
os.environ['HTTP_PROXY'] = 'http://localhost:8080'
os.environ['HTTPS_PROXY'] = 'http://localhost:8080'
os.setenv(...)
not work but os.environ
dose?Once os.environ was set all nodes that use the request package used the proxy. But the OSMnx nodes still didn't work even so the documentation states that it uses the request package that can be configure via _kwargs.
@koettert to check with the Python team about: "Does os.setenv(...) not work but os.environ dose?"
@wybert please check out the above mentioned solutions and try to understand from reading their code and the OSMnx code why setting the proxy via os.environ doesn't work
I just did a test on Mac M2 with KNIME 5.2.3, below is what I found,
- Our extension will not use the proxies set in KNIME preferences.
- The Python Script node will not use the proxies set in KNIME preferences.
- To enable Python Script node and one of our extension node to use proxies set in KNIME preferences, we need add some code like in the following,
import os os.environ['HTTP_PROXY'] = 'http://localhost:8080' os.environ['HTTPS_PROXY'] = 'http://localhost:8080'
- It will work for most of the code, but not for the OSMNx package, I find an issue here, but I can't get it work.
- Dose
os.setenv(...)
not work butos.environ
dose?- The OSMnx also have a setting module with requests_kwargs, which could specify the proxies, but I can't get it work too.
@koettert There is a mistake when testing with OSMNx, OSMNx will use cache for executed query. That's why OSMNx seems never use proxy during my test (It actually doesn't make a request at all).
After setting ox.settings.use_cache = False
, OSMNx will use proxies both set by
import os
os.environ['HTTP_PROXY'] = 'http://localhost:8080'
os.environ['HTTPS_PROXY'] = 'http://localhost:8080'
Or
proxies = {
"http": "http://localhost:8080",
"https": "http://localhost:8080",
}
ox.settings.requests_kwargs = {'proxies': proxies, 'verify': False}
The goal of this ticket is to ensure that all geospatial nodes use the newly available proxy settings. With AP-20960 that was released with KNIME AP 5.2 the Python framework sets the proxy information configured via the HTTP_PROXY and HTTPS_PROXY environment variables (via
os.setenv(...)os.environ). In addition the proxy settings can be retrieved viaknext.get_proxy_settings()
For debugging and testing we can use https://mitmproxy.org/ and Ask Adrian for help.
Steps to do: