Skip to content

Commit

Permalink
fix(pipeline): fixed pipeline create/validate/trigger client code
Browse files Browse the repository at this point in the history
  • Loading branch information
joremysh committed Jul 25, 2024
1 parent 0c83760 commit 6bd071c
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions instill/clients/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,15 @@ def is_serving(self) -> bool:
def create_pipeline(
self,
name: str,
description: str,
recipe: Struct,
async_enabled: bool = False,
) -> pipeline_interface.CreateUserPipelineResponse:
pipeline = pipeline_interface.Pipeline(
id=name,
recipe=recipe,
description=description,
)
pipeline.recipe.update(recipe)
if async_enabled:
return RequestFactory(
method=self.hosts[self.instance].async_client.CreateUserPipeline,
Expand Down Expand Up @@ -306,24 +308,28 @@ def trigger_pipeline(
data: list,
async_enabled: bool = False,
) -> pipeline_interface.TriggerUserPipelineResponse:
request=pipeline_interface.TriggerUserPipelineRequest(
name=f"{self.target_namespace}/pipelines/{name}",
)
for input in inputs:
trigger_inputs = Struct()
trigger_inputs.update(input)
request.inputs.append(trigger_inputs)
for d in data:
trigger_data = Struct()
trigger_data.update(d)
request.data.append(trigger_data)

if async_enabled:
return RequestFactory(
method=self.hosts[self.instance].async_client.TriggerUserPipeline,
request=pipeline_interface.TriggerUserPipelineRequest(
name=f"{self.target_namespace}/pipelines/{name}",
inputs=inputs,
data=data,
),
request=request,
metadata=self.hosts[self.instance].metadata,
).send_async()

return RequestFactory(
method=self.hosts[self.instance].client.TriggerUserPipeline,
request=pipeline_interface.TriggerUserPipelineRequest(
name=f"{self.target_namespace}/pipelines/{name}",
inputs=inputs,
data=data,
),
request=request,
metadata=self.hosts[self.instance].metadata,
).send_sync()

Expand Down

0 comments on commit 6bd071c

Please sign in to comment.