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

Announce new features and version compatibility check #16

Merged
merged 11 commits into from
Mar 11, 2024

Conversation

davidotte
Copy link
Collaborator

Update client for retrieving new messages of a user and supporting the client version compatibility check of the server.

More detail:

  • Add current client version to the header of each request
  • Update error raising such that e.g. exceptions from the server regarding the client version are shown the user (which was not the case before)
  • Retrieve and print messages during init() call

I rebased to the fix_tests_client branch from Anshul, which is not merged yet.

@liam-sbhoo liam-sbhoo changed the title Announce new features and version compatibility check (Merge registration flow first) Announce new features and version compatibility check Feb 22, 2024
@liam-sbhoo liam-sbhoo changed the title (Merge registration flow first) Announce new features and version compatibility check Announce new features and version compatibility check Feb 22, 2024
Copy link
Collaborator

@SamuelGabriel SamuelGabriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much! Very tiny things. I did not look too thoroughly at the tests, but think it is ready to be merged.

quick_test.py Outdated Show resolved Hide resolved
tabpfn_client/client.py Show resolved Hide resolved
tabpfn_client/client.py Outdated Show resolved Hide resolved
tabpfn_client/tabpfn_classifier.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@liam-sbhoo liam-sbhoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment:

  • Including comments are strategic spots might help readers to understand your thought process.
  • There may be room for improvement (for better robustness)

Other TODO:

  • Rebase on main - easier to review

tabpfn_client/client.py Outdated Show resolved Hide resolved
tabpfn_client/client.py Outdated Show resolved Hide resolved
tabpfn_client/client.py Outdated Show resolved Hide resolved
tabpfn_client/client.py Outdated Show resolved Hide resolved
tabpfn_client/tabpfn_classifier.py Outdated Show resolved Hide resolved
tabpfn_client/client.py Outdated Show resolved Hide resolved
@davidotte davidotte force-pushed the announce-new-features branch from f530d56 to 2dd9fec Compare March 9, 2024 15:16
@davidotte
Copy link
Collaborator Author

davidotte commented Mar 11, 2024

Hey @SamuelGabriel @liam-sbhoo , I just rebased to main and applied the requested changes :)

@@ -251,6 +278,7 @@ def login(self, email: str, password: str) -> str | None:
data=common_utils.to_oauth_request_form(email, password)
)

self._validate_response(response, "login", only_version_check=True)
Copy link
Collaborator

@SamuelGabriel SamuelGabriel Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please set only_version check to false here

@SamuelGabriel
Copy link
Collaborator

This all looks nice!

this is good to be merged (without another look) after you:

  1. set only_version_check=False in line 281 client.py
  2. make sure the quick_test.py runs through without error, sorry for adding this to this PR, but I think it is just nice if this works.
  3. use "426: Upgrade required

Thanks :)

@davidotte
Copy link
Collaborator Author

@SamuelGabriel Done.

@liam-sbhoo liam-sbhoo self-requested a review March 11, 2024 15:02
Copy link
Collaborator

@liam-sbhoo liam-sbhoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only very minor things, good to merge after this improvement.

load = None
try:
load = response.json()
except Exception:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I forgot to mention this, could we only catch known Exception and log the non-expected one? It seems a little dangerous.

I got the following from ChatGPT:

try:
    response_payload = response.json()
except json.JSONDecodeError as e:
    logging.error(f"Failed to parse JSON from response in {method_name}: {e}")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to log it.

@@ -27,6 +28,14 @@ def test_try_connection_with_invalid_server(self, mock_server):
mock_server.router.get(mock_server.endpoints.root.path).respond(404)
self.assertFalse(self.client.try_connection())

@with_mock_server()
def test_try_connection_with_outdated_client(self, mock_server):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, a better practice for the naming the test cases should include:

  • test condition
  • expected result

In this case, you could call it def test_try_connection_with_outdated_client_raises_xxx

ps. I figured that the old test cases were following this naming convention, but let's start applying this now :)

Copy link
Collaborator

@SamuelGabriel SamuelGabriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@davidotte davidotte merged commit 87fa78f into main Mar 11, 2024
1 check passed
@davidotte davidotte deleted the announce-new-features branch June 2, 2024 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants