Get client
Deduce how to initialize or retrieve the client.
This is meant to be a zero configuration for the user.
Create and set a client globally
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client_or_creds |
Optional[Union[Client, dict, str, Path]]
|
Client to forward or credentials for initialization |
None
|
set_as_global |
bool
|
If |
False
|
wait_for_auth |
bool
|
If |
True
|
Returns:
Type | Description |
---|---|
Client
|
Client instance |
Source code in /opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/ydata/sdk/common/client/utils.py
Main Client class used to abstract the connection to the backend.
A normal user should not have to instanciate a Client
by itself.
However, in the future it will be useful for power-users to manage projects and connections.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
credentials |
Optional[dict]
|
(optional) Credentials to connect |
None
|
project |
Optional[Project]
|
(optional) Project to connect to. If not specified, the client will connect to the default user's project. |
None
|
Source code in /opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/ydata/sdk/common/client/client.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
__build_url(endpoint, params=None, data=None, json=None, files=None, cookies=None)
Build a request for the backend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint |
str
|
backend endpoint |
required |
params |
Optional[dict]
|
URL parameters |
None
|
data |
Optional[Project]
|
(optional) multipart form data |
None
|
json |
Optional[dict]
|
(optional) json data |
None
|
files |
Optional[dict]
|
(optional) files to be sent |
None
|
cookies |
Optional[dict]
|
(optional) cookies data |
None
|
Returns:
Type | Description |
---|---|
Dict
|
dictionary containing the information to perform a request |
Source code in /opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/ydata/sdk/common/client/client.py
__raise_for_status(response)
Raise an exception if the response is not OK.
When an exception is raised, we try to convert it to a ResponseError which is a wrapper around a backend error. This usually gives enough context and provides nice error message.
If it cannot be converted to ResponseError, it is re-raised.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
response |
Response
|
response to analyze |
required |
Source code in /opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/ydata/sdk/common/client/client.py
__set_global()
Sets a client instance as global.
get(endpoint, params=None, cookies=None, raise_for_status=True)
GET request to the backend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint |
str
|
GET endpoint |
required |
cookies |
Optional[dict]
|
(optional) cookies data |
None
|
raise_for_status |
bool
|
raise an exception on error |
True
|
Returns:
Type | Description |
---|---|
Response
|
Response object |
Source code in /opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/ydata/sdk/common/client/client.py
get_static_file(endpoint, raise_for_status=True)
Retrieve a static file from the backend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint |
str
|
GET endpoint |
required |
raise_for_status |
bool
|
raise an exception on error |
True
|
Returns:
Type | Description |
---|---|
Response
|
Response object |
Source code in /opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/ydata/sdk/common/client/client.py
post(endpoint, data=None, json=None, files=None, raise_for_status=True)
POST request to the backend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint |
str
|
POST endpoint |
required |
data |
Optional[dict]
|
(optional) multipart form data |
None
|
json |
Optional[dict]
|
(optional) json data |
None
|
files |
Optional[dict]
|
(optional) files to be sent |
None
|
raise_for_status |
bool
|
raise an exception on error |
True
|
Returns:
Type | Description |
---|---|
Response
|
Response object |