Skip to content

Commit

Permalink
fix(client): fix async pipeline trigger and get user (#53)
Browse files Browse the repository at this point in the history
Because

- cannot get user
- cannot trigger pipeline with async model

This commit

- add `users/me` alias in get user method
- fix trigger async method
  • Loading branch information
heiruwu authored Nov 24, 2023
1 parent b4611d9 commit c86274b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 0 additions & 1 deletion instill/clients/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from instill.utils.logger import Logger

_mgmt_client = None
_connector_client = None
_pipeline_client = None
_model_client = None
_client = None
Expand Down
2 changes: 1 addition & 1 deletion instill/clients/mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def get_user(self) -> mgmt_interface.User:
resp: mgmt_interface.GetUserResponse = self.hosts[self.instance][
"client"
].GetUser(
request=mgmt_interface.GetUserRequest(),
request=mgmt_interface.GetUserRequest(name="users/me"),
metadata=self.hosts[self.instance]["metadata"],
)
return resp.user
Expand Down
2 changes: 1 addition & 1 deletion instill/clients/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def trigger_async_pipeline(
) -> operations_pb2.Operation:
resp: pipeline_interface.TriggerAsyncUserPipelineResponse = self.hosts[
self.instance
]["client"].TriggerUserPipeline(
]["client"].TriggerAsyncUserPipeline(
request=pipeline_interface.TriggerAsyncUserPipelineRequest(
name=f"{self.namespace}/pipelines/{name}", inputs=inputs
),
Expand Down
10 changes: 10 additions & 0 deletions instill/resources/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# pylint: disable=no-member,wrong-import-position,no-name-in-module
from typing import Tuple, Union

from google.longrunning import operations_pb2

import instill.protogen.vdp.pipeline.v1alpha.pipeline_pb2 as pipeline_interface
from instill.clients import InstillClient
from instill.resources.resource import Resource
Expand Down Expand Up @@ -49,6 +51,14 @@ def resource(self, resource: pipeline_interface.Pipeline):
def _update(self):
self.resource = self.client.pipeline_service.get_pipeline(name=self.resource.id)

def get_operation(self, operation: operations_pb2.Operation):
return self.client.pipeline_service.get_operation(operation.name)

def trigger_async(self, task_inputs: list) -> operations_pb2.Operation:
return self.client.pipeline_service.trigger_async_pipeline(
self.resource.id, task_inputs
)

def get_recipe(self) -> str:
return self.resource.recipe

Expand Down

0 comments on commit c86274b

Please sign in to comment.