From 4ef0a6f1217992741f826c9f783ccc2505c6428a Mon Sep 17 00:00:00 2001 From: David Otte <63399116+davidotte@users.noreply.github.com> Date: Mon, 14 Oct 2024 09:57:03 +0200 Subject: [PATCH 1/5] Add two minor fixes for data download (#41) * Add two minor fixes for data download * Add comment in client.py --- tabpfn_client/client.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tabpfn_client/client.py b/tabpfn_client/client.py index 4ed4339..1a0b58c 100644 --- a/tabpfn_client/client.py +++ b/tabpfn_client/client.py @@ -193,6 +193,10 @@ def _validate_response( # Read response. load = None try: + # This if clause is necessary for streaming responses (e.g. download) to + # prevent httpx.ResponseNotRead error. + if not response.is_closed: + response.read() load = response.json() except json.JSONDecodeError as e: logging.info(f"Failed to parse JSON from response in {method_name}: {e}") @@ -487,7 +491,12 @@ def download_all_data(self, save_dir: Path) -> Path | None: full_url = self.base_url + self.server_endpoints.download_all_data.path with httpx.stream( - "GET", full_url, headers={"Authorization": f"Bearer {self.access_token}"} + "GET", + full_url, + headers={ + "Authorization": f"Bearer {self.access_token}", + "client-version": get_client_version(), + }, ) as response: self._validate_response(response, "download_all_data") From 91785ed147760dbafc60d8e32a912fae7111b8f0 Mon Sep 17 00:00:00 2001 From: noahho Date: Wed, 23 Oct 2024 21:10:24 +0200 Subject: [PATCH 2/5] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9b0911f..14255f0 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # The client for the (all new) TabPFN -This is an alpha family and friends service, so please do not expect this to never be down or run into errors. It worked fine in the settings that we tried, though. +This is an alpha family and friends service, so please do not expect this to never be down or run into errors. It worked fine in the settings that we tried, though. What model is behind the API? It is a new TabPFN which we allow to handle up to 10K data points with up to 500 features. You can control all pre-processing, the amount of ensembling etc. -### We would really appreciate your feedback! If you encounter bugs or suggestions for improvement please create an issue or email me (samuelgabrielmuller (at) gmail com). +### We would really appreciate your feedback! Please join our discord community here https://discord.gg/VJRuU3bSxt or email us at hello@priorlabs.ai # How To From 015098bc0dc290f06ef4169e44de8d229062045f Mon Sep 17 00:00:00 2001 From: noahho Date: Thu, 31 Oct 2024 10:28:44 +0100 Subject: [PATCH 3/5] Update README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 14255f0..ebda66e 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,20 @@ tabpfn.predict(X_test) # or you can also use tabpfn.predict_proba(X_test) ``` +To login using your access token, skipping the interactive flow, use: + +```python +from tabpfn_client import config + +# Retrieve Token +with open(config.g_tabpfn_config.user_auth_handler.CACHED_TOKEN_FILE, 'r') as file: + token = file.read() +print(f"TOKEN: {token}") + +# Set Token +user_auth = config.g_tabpfn_config.user_auth_handler.set_token(token) +``` + # Development To encourage better coding practices, `ruff` has been added to the pre-commit hooks. This will ensure that the code is formatted properly before being committed. To enable pre-commit (if you haven't), run the following command: From 2b03cb337ef368c6d3abf05abefe88ee7c2e724d Mon Sep 17 00:00:00 2001 From: noahho Date: Thu, 31 Oct 2024 12:39:58 +0100 Subject: [PATCH 4/5] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index ebda66e..58b04cc 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,15 @@ from tabpfn_client import config with open(config.g_tabpfn_config.user_auth_handler.CACHED_TOKEN_FILE, 'r') as file: token = file.read() print(f"TOKEN: {token}") +``` + +```python +from tabpfn_client import config # Set Token +service_client = config.ServiceClient() +config.g_tabpfn_config.user_auth_handler = config.UserAuthenticationClient(service_client=service_client) +token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiZGIyMTA2NDQtYTdjOC00ZGQ3LTlkZWUtYjk4ZjQyY2YxZjExIiwiZXhwIjoxNzYxODk3NzY4fQ.2y0kE8jn-Bw-_9EBzg8OwqXhPM6AkgUIgoKLH_-EIZM" user_auth = config.g_tabpfn_config.user_auth_handler.set_token(token) ``` From a27447fe511fc967748ba7f5ae5c82fc15aff17d Mon Sep 17 00:00:00 2001 From: noahho Date: Thu, 31 Oct 2024 12:40:20 +0100 Subject: [PATCH 5/5] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 58b04cc..c5cb7fb 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,6 @@ from tabpfn_client import config # Set Token service_client = config.ServiceClient() config.g_tabpfn_config.user_auth_handler = config.UserAuthenticationClient(service_client=service_client) -token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiZGIyMTA2NDQtYTdjOC00ZGQ3LTlkZWUtYjk4ZjQyY2YxZjExIiwiZXhwIjoxNzYxODk3NzY4fQ.2y0kE8jn-Bw-_9EBzg8OwqXhPM6AkgUIgoKLH_-EIZM" user_auth = config.g_tabpfn_config.user_auth_handler.set_token(token) ```