You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, if the REANA_SERVER_URL env variable is set after importing reana-client (or reana-commons), then the first request is always made to the default URL http://0.0.0.0:80:
The issue is due to the fact that the env variable is loaded after the bravado client has been created (source):
### default value is read here ###server_url, spec_file=OPENAPI_SPECS[service]
json_spec=self._get_spec(spec_file)
current_instance=BaseAPIClient._bravado_client_instance# We reinstantiate the bravado client instance if# 1. The current instance doesn't exist, or# 2. We're passing an http client (likely a mock), or# 3. The current instance is a Mock, meaning that either we want to# use the `RequestClient` or we're passing a different mock.if (
current_instanceisNoneorhttp_clientorisinstance(current_instance.swagger_spec.http_client, Mock)
):
BaseAPIClient._bravado_client_instance=SwaggerClient.from_spec(
json_spec,
http_client=http_clientorRequestsClient(ssl_verify=False),
config={"also_return_response": True},
)
### custom value is read after creating the client ###self._load_config_from_env()
PS: let's also check the usage of LocalProxy here, because the get_current_api_client is called anyway on each API call:
Note that LocalProxy is probably not doing what we think it should do, in particular it's NOT keeping one instance per thread, but it's instead recreating the client on each call
Reported by @rubenperezm
Consider this example publish on our blog: https://blog.reana.io/posts/2021/reana-client-python-api/
However, if the
REANA_SERVER_URL
env variable is set after importing reana-client (or reana-commons), then the first request is always made to the default URLhttp://0.0.0.0:80
:The issue is due to the fact that the env variable is loaded after the bravado client has been created (source):
PS: let's also check the usage of LocalProxy here, because the
get_current_api_client
is called anyway on each API call:reana-client/reana_client/api/client.py
Lines 34 to 36 in 822a538
The text was updated successfully, but these errors were encountered: