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

[ATO-1652] Add gRPC support #1109

Merged
merged 19 commits into from
Jun 19, 2024
Merged

Conversation

radovanZRasa
Copy link
Contributor

@radovanZRasa radovanZRasa commented Jun 17, 2024

Add support to communicate with Rasa over gRPC protocol.

Status (please check what you already did):

  • made PR ready for code review
  • added some tests for the functionality
  • updated the documentation in the rasaHQ/rasa
  • updated the changelog (please check changelog for instructions)
  • reformat files using black (please check Readme for instructions)

@radovanZRasa
Copy link
Contributor Author

Still working on integration tests, unit tests and CI.

Makefile Outdated Show resolved Hide resolved
rasa_sdk/grpc_server.py Outdated Show resolved Hide resolved
initialise_interrupts(server)
executor = ActionExecutor()
executor.register_package(action_package_name)
# tracer_provider = get_tracer_provider(endpoints)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to add support for tracing.
@ancalita I might need your help on this one.

) -> Tuple[Any, Any, Text]:
"""Gets tracer and context."""
span_name = "create_app.webhook"
if tracer_provider is None:

if tracer_provider is None or isinstance(request, WebhookRequest):
Copy link
Member

Choose a reason for hiding this comment

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

Yeah we will need to update the code on rasa-private side too to inject the trace context in the grpc request. I am searching for some docs / looking in opentelemetry to see if there's any guidance.

Copy link
Member

Choose a reason for hiding this comment

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

Couldn't find any guidance I'm afraid :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try to look it up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ancalita I added tracing for GRPCActionServerWebhook.Webhook.

@radovanZRasa radovanZRasa force-pushed the feature/ATO-1652-add-grpc-support branch from c2fe5a6 to ed05393 Compare June 17, 2024 12:29
@radovanZRasa radovanZRasa force-pushed the feature/ATO-1652-add-grpc-support branch from 23461d5 to b49f874 Compare June 17, 2024 22:21
@radovanZRasa radovanZRasa force-pushed the feature/ATO-1652-add-grpc-support branch from a5ad38d to 6cf9bdb Compare June 18, 2024 09:19
@radovanZRasa radovanZRasa force-pushed the feature/ATO-1652-add-grpc-support branch from fb8cd95 to 1e593ef Compare June 18, 2024 10:16
@radovanZRasa radovanZRasa marked this pull request as ready for review June 18, 2024 11:37
Copy link
Member

@ancalita ancalita left a comment

Choose a reason for hiding this comment

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

Left a few minor comments, are you planning to tackle tracing in a future PR?

Makefile Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
proto/health.proto Outdated Show resolved Hide resolved
rasa_sdk/__main__.py Show resolved Hide resolved
rasa_sdk/grpc_server.py Show resolved Hide resolved
self.tracer_provider = tracer_provider
self.executor = executor

async def Actions(self, request: ActionsRequest, context) -> ActionsResponse:
Copy link
Member

Choose a reason for hiding this comment

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

Same question here about not using the method args as above. Also context is missing type hint.

Copy link
Contributor Author

@radovanZRasa radovanZRasa Jun 18, 2024

Choose a reason for hiding this comment

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

I tried but I could not find the type of the context anywhere.

Considering method args, this is the cleanest way to do it according to protobuf docs.
It provides good options for backwards compatibility later on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Found the type of context after some digging through docs. It's grpc.aio.ServicerContext.

Copy link
Member

Choose a reason for hiding this comment

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

Nice 💯 could we add it in?

Copy link
Member

@ancalita ancalita left a comment

Choose a reason for hiding this comment

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

Awesome 💯 🚀

@@ -17,10 +17,11 @@ def get_tracer_provider(endpoints_file: str) -> Optional[TracerProvider]:


def get_tracer_and_context(
tracer_provider: Optional[TracerProvider], request: Request
tracer_provider: Optional[TracerProvider], request: Union[Request]
Copy link
Member

Choose a reason for hiding this comment

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

This had the WebhookRequest before I think in the typing hint, could you please re-add 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.

No need. I create tracer in GRPCActionServerWebhook.Webhook.

Copy link
Member

Choose a reason for hiding this comment

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

But that serves a different purpose, we need this for passing the rasa-private context to the sdk 🤔

Copy link
Member

Choose a reason for hiding this comment

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

The tracer in the webhook instruments the webhook separately.

@radovanZRasa radovanZRasa merged commit 3794117 into main Jun 19, 2024
16 checks passed
@radovanZRasa radovanZRasa deleted the feature/ATO-1652-add-grpc-support branch June 19, 2024 09:58
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