Skip to content

Commit

Permalink
Merge branch 'main' into patch-liam
Browse files Browse the repository at this point in the history
  • Loading branch information
liam-sbhoo authored Nov 1, 2024
2 parents 16eafb0 + a27447f commit 2bbce53
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 [email protected]


# How To
Expand Down Expand Up @@ -38,6 +38,26 @@ 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}")
```

```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)
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:
Expand Down
11 changes: 10 additions & 1 deletion tabpfn_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit 2bbce53

Please sign in to comment.