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

Task/kiota core dependency #141

Merged
merged 41 commits into from
Nov 4, 2022

Conversation

samwelkanda
Copy link
Contributor

Overview

Refactors the python core library to take a dependency on Kiota core

@samwelkanda samwelkanda self-assigned this Oct 24, 2022
@samwelkanda samwelkanda marked this pull request as ready for review October 27, 2022 15:17
Pipfile Outdated Show resolved Hide resolved
return wrapper


class GraphClient:
Copy link
Member

Choose a reason for hiding this comment

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

is inheritance from multiple parents supported in Python? If not, I'm not sure how the GraphServiceClient will inherit from this one.

Copy link
Contributor Author

@samwelkanda samwelkanda Oct 28, 2022

Choose a reason for hiding this comment

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

GraphServiceClient will be passed a GraphRequestAdapter instance. GraphRequestAdapter in turn accepts a GraphClient as one of the arguments

Copy link
Member

Choose a reason for hiding this comment

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

I think the naming here is leading to confusion, if this is not a client in the sense of http client or a client in the sense of a service client, what is its function? so we can find a better name for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

GraphClient is indeed a http client, and will be used to make raw string requests to the graph API by users who do not want the service library. Alse added a separate GraphRequestAdapter class that will be used for the full sdk/self-serve sdks.

Copy link
Member

Choose a reason for hiding this comment

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

We may not need the separation of the two , I believe it should be possible to build an instance of RequestInformation using the raw string and then pass it to the RequestAdapter to send the request. This would mean one GraphClient which holds a RequestAdapter inside it.
This way we can possibly avoid implementation/functional drifts due to slight variations in configuration of the client e.g Auth which is handled by the RequestAdapter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could work. Lemme test it out. I'll revert with findings.

msgraph/core/graph_client_factory.py Show resolved Hide resolved
msgraph/core/graph_client_factory.py Outdated Show resolved Hide resolved
from .middleware import GraphRequest


class GraphRedirectHandler(RedirectHandler):
Copy link
Member

Choose a reason for hiding this comment

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

do we still need this at all since we should already have it in kiota http?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extends the one in kiota_http to add graph specific stuff such as request context and setting FeatureUsageFlags

Copy link
Member

Choose a reason for hiding this comment

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

Just for my benefit, is there any other extra customization being done apart from FeatureUsageFlags and request context.
I believe that FeatureUsageFlags can all be inferred at one place like the telemetry handler by simply checking the items in the middleware collection or computed once beforehand when the client is initialized.
Similarly, request context can be copied over to new requests if its held within a RequestOption instance.
This way we can have only one redirect handler from the core abstractions.

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 other customizations other than setting, RequestContext and updating FeatureUsage. I can definitely refactor the implementation to avoid extending the middleware.

Copy link
Member

Choose a reason for hiding this comment

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

thanks for the additional context, please do so Python implementation is not diverging from other languages.

msgraph/core/middleware/middleware.py Outdated Show resolved Hide resolved
msgraph/core/middleware/request_context.py Show resolved Hide resolved
msgraph/core/middleware/retry.py Outdated Show resolved Hide resolved
msgraph/core/middleware/middleware.py Outdated Show resolved Hide resolved
@baywet baywet mentioned this pull request Nov 2, 2022
async def send(self, request: GraphRequest, transport: AsyncKiotaTransport):
"""Adds telemetry headers and sends the http request.
"""
self.set_request_context_and_feature_usage(request, transport)
Copy link
Member

Choose a reason for hiding this comment

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

👍🏼

@samwelkanda samwelkanda merged commit db356dd into kiota/long-term-branch Nov 4, 2022
@samwelkanda samwelkanda deleted the task/kiota-core-dependency branch November 4, 2022 10:15
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