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

[ENH] use httpx over requests #2336

Merged
merged 9 commits into from
Jun 18, 2024
Merged

[ENH] use httpx over requests #2336

merged 9 commits into from
Jun 18, 2024

Conversation

codetheweb
Copy link
Contributor

No description provided.

Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link

Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas

@codetheweb codetheweb changed the title Use httpx over requests [ENH] use httpx over requests Jun 13, 2024
@@ -1614,19 +1613,3 @@ def test_ssl_self_signed_without_ssl_verify(client_ssl):
)
client_ssl.clear_system_cache()
assert "CERTIFICATE_VERIFY_FAILED" in "".join(stack_trace)


def test_ssl_self_signed_with_verify_false(client_ssl):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

httpx does not emit warnings when verify is explicitly set to False.

Copy link
Collaborator

Choose a reason for hiding this comment

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

does it error or give any indication?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, which imo is more correct behavior

@codetheweb codetheweb marked this pull request as ready for review June 13, 2024 23:32
@@ -62,27 +62,35 @@ def __init__(self, system: System):
default_api_path=system.settings.chroma_server_api_default_path,
)

self._session = requests.Session()
self._session = httpx.Client(timeout=None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

checking (seems to be yes) default behavior was previously no timeout? We should probably add config here - let me cut a ticket.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, requests doesn't have a default timeout but httpx does

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the default timeout was causing issues in CI

url = self._api_url + escaped_path

response = self._session.request(method, url, **cast(Any, kwargs))
BaseHTTPClient._raise_chroma_error(response)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice encapsulation

@@ -3,16 +3,16 @@ name = "chromadb-client"
dynamic = ["version"]

authors = [
{ name="Jeff Huber", email="[email protected]" },
{ name="Anton Troynikov", email="[email protected]" }
{ name = "Jeff Huber", email = "[email protected]" },
Copy link
Collaborator

Choose a reason for hiding this comment

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

whats with the formatting thrashing here lol - i've seen 2-3 prs where this file is only getting formatted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

adding httpx here ;)

I just tested and VS Code added the formatting changes upon save, I assume because .vscode/settings.json->editor.formatOnSave is true
not sure what formatter it's actually using for that though

@codetheweb codetheweb requested a review from HammadB June 15, 2024 00:03
@codetheweb codetheweb merged commit 8be43ae into main Jun 18, 2024
63 checks passed
@codetheweb codetheweb deleted the feat-unified-http-library branch June 18, 2024 23:17
Anush008 pushed a commit to Anush008/chroma that referenced this pull request Jun 27, 2024
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.

2 participants