Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send password in request body #32

Merged
merged 4 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "tabpfn-client"
version = "0.0.20"
version = "0.0.21"
requires-python = ">=3.10"
dependencies = [
"httpx>=0.24.1",
Expand Down
2 changes: 1 addition & 1 deletion tabpfn_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def register(

response = self.httpx_client.post(
self.server_endpoints.register.path,
params={
json={
"email": email,
"password": password,
"password_confirm": password_confirm,
Expand Down
16 changes: 12 additions & 4 deletions tabpfn_client/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def __init__(
self.remove_outliers = remove_outliers
self.add_fingerprint_features = add_fingerprint_features
self.subsample_samples = subsample_samples
self.last_train_set_uid = None

def _validate_targets_and_classes(self, y) -> np.ndarray:
from sklearn.utils import column_or_1d
Expand All @@ -206,7 +207,7 @@ def fit(self, X, y):
), "Only 'latest_tabpfn_hosted' model is supported at the moment for init(use_server=True)"
except AssertionError as e:
print(e)
config.g_tabpfn_config.inference_handler.fit(X, y)
self.last_train_set_uid = config.g_tabpfn_config.inference_handler.fit(X, y)
self.fitted_ = True
else:
raise NotImplementedError(
Expand All @@ -223,7 +224,10 @@ def predict(self, X):
def predict_proba(self, X):
check_is_fitted(self)
return config.g_tabpfn_config.inference_handler.predict(
X, task="classification", config=self.get_params()
X,
task="classification",
train_set_uid=self.last_train_set_uid,
config=self.get_params(),
)["probas"]


Expand Down Expand Up @@ -323,6 +327,7 @@ def __init__(
self.cancel_nan_borders = cancel_nan_borders
self.super_bar_dist_averaging = super_bar_dist_averaging
self.subsample_samples = subsample_samples
self.last_train_set_uid = None

def fit(self, X, y):
# assert init() is called
Expand All @@ -335,7 +340,7 @@ def fit(self, X, y):
), "Only 'latest_tabpfn_hosted' model is supported at the moment for init(use_server=True)"
except AssertionError as e:
print(e)
config.g_tabpfn_config.inference_handler.fit(X, y)
self.last_train_set_uid = config.g_tabpfn_config.inference_handler.fit(X, y)
self.fitted_ = True
else:
raise NotImplementedError(
Expand All @@ -357,5 +362,8 @@ def predict(self, X):
def predict_full(self, X):
check_is_fitted(self)
return config.g_tabpfn_config.inference_handler.predict(
X, task="regression", config=self.get_params()
X,
task="regression",
train_set_uid=self.last_train_set_uid,
config=self.get_params(),
)
15 changes: 10 additions & 5 deletions tabpfn_client/service_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,25 @@ class InferenceClient(ServiceClientWrapper):

def __init__(self, service_client=ServiceClient()):
super().__init__(service_client)
self.last_train_set_uid = None

def fit(self, X, y) -> None:
def fit(self, X, y) -> str:
if not self.service_client.is_initialized:
raise RuntimeError(
"Dear TabPFN User, please initialize the client first by verifying your E-mail address sent to your registered E-mail account."
"Please Note: The email verification token expires in 30 minutes."
)

self.last_train_set_uid = self.service_client.upload_train_set(X, y)
return self.service_client.upload_train_set(X, y)

def predict(self, X, task: Literal["classification", "regression"], config=None):
def predict(
self,
X,
task: Literal["classification", "regression"],
train_set_uid: str,
config=None,
):
return self.service_client.predict(
train_set_uid=self.last_train_set_uid,
train_set_uid=train_set_uid,
x_test=X,
tabpfn_config=config,
task=task,
Expand Down
2 changes: 1 addition & 1 deletion tabpfn_client/tabpfn_common_utils
Loading