-
Notifications
You must be signed in to change notification settings - Fork 5
feat: adds boilerplate for config with factories. #1
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
Conversation
Adds support for setting api_key and endpoint. Each value may be set by the caller or via enviornment variables. Values supplied by the user take precedance over variables set by environment variables. The following environment variables are supported: - CONNECT_API_KEY_KEY - CONNECT_ENDPOINT Example Usage: main.py ```python from posit.client import Client client = Client(endpoint="http://localhost:8080") ``` ```console CONNECT_API_KEY=foobar python main.py ```
@@ -19,7 +19,7 @@ classifiers = [ | |||
] | |||
dynamic = ["version"] | |||
dependencies = [ | |||
"requests==2.31.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will sync vs async be a concern? I know httpx
supports both but I don't know how important that might be for users of this client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure. I started with requests since it is the most popular HTTP library after urllib3. And the simplest to use, in my opinion.
Are there situations when calling the Connect API where asynchronous design becomes necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pyshiny (and other fastapi-base apps) rely heavily on python's asyncio apis. This has come up in the databricks sql client as well. There are a few justifications for the request for async in this issue that might also be applicable for our client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! httpx
looks great, but it's marked as beta. Do you have opinions on aiohttp
? That seems like the most stable library to bring in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't used it but that sounds like a good option to me. FWIW Joe also recommended aiohttp
when we were asking him some questions about async shiny: https://positpbc.slack.com/archives/C03HH2ZUU/p1702668760303599
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm skeptical that we'll want to bother with async queries against the Connect API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we expect the sdk to be used from inside Connect-hosted content like fastapi then a non-blocking api could be important. Based off of Joe's comment from the slack thread, it sounds like request's blocking IO is a problem for uvicorn apps.
uvicorn is single threaded, so requests.get(...) blocks any traffic from being served.
We should test this to confirm the behavior but if all other requests are blocked while we're waiting for a request to the Connect API to resolve then that could be a blocker for obtaining an access token inside a piece of content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could someone write a uvicorn
application that async wraps calls to this library?
I also wouldn't want to force a consumer to set up asyncio
and into await
'ing everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could someone write a
uvicorn
application that async wraps calls to this library?
Sure, probably. Let's table this for now. I think this is something that warrants more discussion though. We should test what it feels like to use this SDK from different content types in Connect. Especially single-threaded uvicorn content like pyshiny and fastapi. I'm interested to see whether the content can service multiple requests at the same time without using an async requests library
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, let's defer, this feels like YAGNI in PR #1. If we find out that we are bottlenecking because of this, we should totally revisit.
ci: adds action to test on push
9fe7ca2
to
d674b7f
Compare
d674b7f
to
219d4ba
Compare
Should all of this go under |
Since this is starting to balloon, I will merge this and split discussions downstream. |
Yes, it should. |
Adds support for setting api_key and endpoint. Each value may be set by the caller or via environment variables. Values supplied by the user take precedence over variables set by environment variables.
The following environment variables are supported:
Example Usage:
main.py
CONNECT_API_KEY=foobar python main.py