polaris-hub / polaris

Foster the development of impactful AI models in drug discovery.
https://polaris-hub.github.io/polaris/
Apache License 2.0
94 stars 6 forks source link

Error loading a dataset #163

Closed PatWalters closed 3 months ago

PatWalters commented 3 months ago

Polaris version

dev

Python Version

3.10.11

Operating System

Linux

Installation

mamba install -c conda-forge polaris

Description

import polaris as po dataset = po.load_dataset("polaris/hello-world")

💥 ERROR: Failed to fetch dataset.

/home/pwalters/anaconda3/envs/rdkit_2023_03/lib/python3.10/site-packages/yaspin/core.py:171: UserWarning: color, on_color and attrs are not supported when running in jupyter
  self._color = self._set_color(value) if value else value
---------------------------------------------------------------------------
MissingTokenError                         Traceback (most recent call last)
File ~/anaconda3/envs/rdkit_2023_03/lib/python3.10/site-packages/polaris/hub/client.py:213, in PolarisHubClient.request(self, method, url, withhold_token, auth, **kwargs)
    212 try:
--> 213     return super().request(method, url, withhold_token, auth, **kwargs)
    214 except httpx.ConnectError as error:
    215     # NOTE (cwognum): In the stack-trace, the more specific SSLCertVerificationError is raised.
    216     #   We could use the traceback module to cactch this specific error, but that would be overkill here.

File ~/anaconda3/envs/rdkit_2023_03/lib/python3.10/site-packages/authlib/integrations/httpx_client/oauth2_client.py:199, in OAuth2Client.request(self, method, url, withhold_token, auth, **kwargs)
    198 if not self.token:
--> 199     raise MissingTokenError()
    201 if not self.ensure_active_token(self.token):

MissingTokenError: missing_token: 

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
Cell In[2], line 1
----> 1 dataset = po.load_dataset("polaris/hello-world")

File ~/anaconda3/envs/rdkit_2023_03/lib/python3.10/site-packages/polaris/loader/load.py:40, in load_dataset(path, verify_checksum)
     37 if not is_file:
     38     # Load from the Hub
     39     client = PolarisHubClient()
---> 40     return client.get_dataset(*path.split("/"), verify_checksum=verify_checksum)
     42 # Load from local file
     43 if extension == "json":

File ~/anaconda3/envs/rdkit_2023_03/lib/python3.10/site-packages/polaris/hub/client.py:297, in PolarisHubClient.get_dataset(self, owner, name, verify_checksum)
    280 """Load a dataset from the Polaris Hub.
    281 
    282 Args:
   (...)
    289     A `Dataset` instance, if it exists.
    290 """
    292 with ProgressIndicator(
    293     start_msg="Fetching dataset...",
    294     success_msg="Fetched dataset.",
    295     error_msg="Failed to fetch dataset.",
    296 ):
--> 297     response = self._base_request_to_hub(url=f"/dataset/{owner}/{name}", method="GET")
    298     storage_response = self.get(response["tableContent"]["url"])
    300     # This should be a 307 redirect with the signed URL

File ~/anaconda3/envs/rdkit_2023_03/lib/python3.10/site-packages/polaris/hub/client.py:165, in PolarisHubClient._base_request_to_hub(self, url, method, **kwargs)
    163 def _base_request_to_hub(self, url: str, method: str, **kwargs):
    164     """Utility function since most API methods follow the same pattern"""
--> 165     response = self.request(url=url, method=method, **kwargs)
    167     try:
    168         response.raise_for_status()

File ~/anaconda3/envs/rdkit_2023_03/lib/python3.10/site-packages/polaris/hub/client.py:229, in PolarisHubClient.request(self, method, url, withhold_token, auth, **kwargs)
    227 if isinstance(error, httpx.HTTPStatusError) and error.response.status_code != 401:
    228     raise
--> 229 raise PolarisUnauthorizedError(response=error.response) from error

AttributeError: 'MissingTokenError' object has no attribute 'response'

Steps to reproduce

import polaris as po dataset = po.load_dataset("polaris/hello-world")

Additional output

No response

Andrewq11 commented 3 months ago

Hi @PatWalters, thank you for raising this issue! We mistakenly did not include instructions on authenticating to the Polaris Hub in our quickstart documentation. This caused the token error you've encountered. We also recognize the need to improve that error message for better clarity.

PR #165 should address these issues. Thanks again for bringing this to our attention.

PatWalters commented 3 months ago

Thanks for addressing this so quickly.