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

Adding ConfigClass for HTTPX #118

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mattjacksoncello
Copy link

This PR is to implement a config class to allow more control over httpx for things like certificate verification.

I have also merged in the changes from #92

Note: I have used Claude to help with the changes. I have reviewed everything but I am not the strongest coder so there may be mistakes that I have missed

Copy link

⚠️ This PR contains unsigned commits. To get your PR merged, please sign those commits (git rebase --exec 'git commit -S --amend --no-edit -n' @{upstream}) and force push them to this branch (git push --force-with-lease).

If you're new to commit signing, there are different ways to set it up:

Sign commits with gpg

Follow the steps below to set up commit signing with gpg:

  1. Generate a GPG key
  2. Add the GPG key to your GitHub account
  3. Configure git to use your GPG key for commit signing
Sign commits with ssh-agent

Follow the steps below to set up commit signing with ssh-agent:

  1. Generate an SSH key and add it to ssh-agent
  2. Add the SSH key to your GitHub account
  3. Configure git to use your SSH key for commit signing
Sign commits with 1Password

You can also sign commits using 1Password, which lets you sign commits with biometrics without the signing key leaving the local 1Password process.

Learn how to use 1Password to sign your commits.

Watch the demo

Comment on lines 7 to 15

__all__ = [
"client",
"load",
"load_dict",
"models",
"new_client",
"new_client_from_environment"
]

Choose a reason for hiding this comment

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

Won't deleting this block avoid these components from being properly exported from this package?

Comment on lines 10 to 15
SS_CLIENT_ASYNC = client.new_client(HOST, TOKEN, True)
# Create clients using new config pattern
client_config = ClientConfig(url=HOST, token=TOKEN)
SS_CLIENT = client.Client(client_config)

async_config = AsyncClientConfig(url=HOST, token=TOKEN)
SS_CLIENT_ASYNC = async_client.AsyncClient(async_config)
Copy link

@AndyTitu AndyTitu Jan 28, 2025

Choose a reason for hiding this comment

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

@mattjacksoncello could you also add a section in the description about the use-case you are trying to unlock by passing certificate paths to the client and to httpx, and manual steps for testing this new feature you are attempting to add, as well as maybe add some unit tests that attempt to retrieve items while having this certificate setting turned on?

All these would help speed up the review.

Comment on lines 384 to 391
def new_client(url: str, token: str, is_async: bool = False) -> Union[AsyncClient, Client]:
def new_client(url: str, token: str, **kwargs) -> Client:

Choose a reason for hiding this comment

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

This change is not backwards compatible unfortunately, and other existing user scripts will break if we ever released this and those users updated to this new version. To support this new separation we'd have to release a new major version of the SDK, namely 2.0, and I'm not sure it's worth it only to separate the client initialisation function.

Don't get me wrong, I do agree that this would probably be a better pattern, it's just that I don't believe that this improvement alone is worth releasing a 2.0. Can we maybe revert this client separation and only keep the client config part of this PR?

@mattjacksoncello
Copy link
Author

Thanks for the review Andy, will refactor the code

@mattjacksoncello
Copy link
Author

@AndyTitu,

I've updated the PR to focus solely on the config class changes as requested. Here are the key updates:

  1. Documentation:

    • Added a new section in USAGE.md documenting the primary use case for CA certificate verification with Connect server
  2. Testing:

    • Created a new test file specifically for the config class implementation
    • Looking for feedback on test coverage and potential edge cases
  3. Examples:

    • Added a new example demonstrating CA file usage in practice

Please review these changes and let me know if any adjustments are needed.

@mattjacksoncello mattjacksoncello marked this pull request as ready for review January 29, 2025 22:04
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