-
Notifications
You must be signed in to change notification settings - Fork 4
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
generic requests using the api client #330
Conversation
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! This is certainly helpful for what I'm trying to do. The architecture here still feels wonky in that this stuff which feels like "standard way to format a request" is happening all over the place, and not in a single method like this which everything else is relying on. I guess that's the price we pay for relying on the openapi generator, which has a bunch of other benefits.
src/groundlight/experimental_api.py
Outdated
headers["Accept"] = "application/json" | ||
return headers | ||
|
||
def make_raw_rest_request(self, method: str, endpoint: str, body: Union[dict, None] = None) -> dict: |
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'd leave this out unless we have a really good reason to include it. One of these feels helpful, two starts to sound confusing.
return response.json() | ||
|
||
def make_generic_api_request( # noqa: PLR0913 # pylint: disable=too-many-arguments | ||
self, |
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.
self, | |
self, | |
*, |
We could require the arguments to be named, not positionally-ordered. Feels like a good practice for these methods with tons of arguments, although this one is mercifully more succinct than the openapi provided ones.
Is this the right syntax for that?
Provides a way to custom construct your own requests to groundlight. There's potential to clean it up when we deprecate the GroundlightApiClient class