Skip to content

Commit

Permalink
fix(clients,resources): fix create resource and none response
Browse files Browse the repository at this point in the history
  • Loading branch information
heiruwu committed Dec 6, 2023
1 parent aa41246 commit 6d30636
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 21 deletions.
10 changes: 5 additions & 5 deletions instill/clients/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def get_operator_definition(
return RequestFactory(
method=self.hosts[self.instance].async_client.GetOperatorDefinition,
request=operator_interface.GetOperatorDefinitionRequest(
name=f"operator-definitions//{name}",
name=f"operator-definitions/{name}",
view=operator_interface.GetOperatorDefinitionRequest.VIEW_FULL,
),
metadata=self.hosts[self.instance].metadata,
Expand All @@ -154,7 +154,7 @@ def get_operator_definition(
return RequestFactory(
method=self.hosts[self.instance].client.GetOperatorDefinition,
request=operator_interface.GetOperatorDefinitionRequest(
name=f"operator-definitions//{name}",
name=f"operator-definitions/{name}",
view=operator_interface.GetOperatorDefinitionRequest.VIEW_FULL,
),
metadata=self.hosts[self.instance].metadata,
Expand All @@ -173,7 +173,7 @@ def create_pipeline(
)
if async_enabled:
return RequestFactory(
method=self.hosts[self.instance].async_client.CreateuserPipeline,
method=self.hosts[self.instance].async_client.CreateUserPipeline,
request=pipeline_interface.CreateUserPipelineRequest(
pipeline=pipeline, parent=self.namespace
),
Expand Down Expand Up @@ -204,7 +204,7 @@ def get_pipeline(
).send_async()

return RequestFactory(
method=self.hosts[self.instance].client.CreateUserPipeline,
method=self.hosts[self.instance].client.GetUserPipeline,
request=pipeline_interface.GetUserPipelineRequest(
name=f"{self.namespace}/pipelines/{name}"
),
Expand Down Expand Up @@ -364,7 +364,7 @@ def delete_pipeline(
self,
name: str,
async_enabled: bool = False,
) -> pipeline_interface.DeleteUserPipelineReleaseResponse:
) -> pipeline_interface.DeleteUserPipelineResponse:
if async_enabled:
return RequestFactory(
method=self.hosts[self.instance].async_client.DeleteUserPipeline,
Expand Down
8 changes: 4 additions & 4 deletions instill/resources/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ def __init__(
) -> None:
super().__init__()
self.client = client
connector = client.pipeline_service.get_connector(
name=name, silent=True
).connector
if connector is None:
get_resp = client.pipeline_service.get_connector(name=name, silent=True)
if get_resp is None:
connector = client.pipeline_service.create_connector(
name=name,
definition=definition,
configuration=configuration,
).connector
if connector is None:
raise BaseException("connector creation failed")
else:
connector = get_resp.connector

self.resource = connector

Expand Down
8 changes: 4 additions & 4 deletions instill/resources/connector_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ def __init__(
name: str,
server_url: str,
) -> None:
definition = "connector-definitions/ai-instill-model"
definition = "connector-definitions/instill-model"
configuration = {
"api_token": client.pipeline_service.hosts[
client.pipeline_service.instance
]["token"],
].token,
"server_url": server_url,
}
super().__init__(client, name, definition, configuration)
Expand All @@ -27,7 +27,7 @@ def __init__(
name: str,
api_key: str,
) -> None:
definition = "connector-definitions/ai-stability-ai"
definition = "connector-definitions/stability-ai"
configuration = {"api_key": api_key}
super().__init__(client, name, definition, configuration)

Expand All @@ -39,7 +39,7 @@ def __init__(
name: str,
api_key: str,
) -> None:
definition = "connector-definitions/ai-openai"
definition = "connector-definitions/openai"
configuration = {
"api_key": api_key,
}
Expand Down
2 changes: 1 addition & 1 deletion instill/resources/connector_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(
metadata_structured_data: bool,
metadata_metadata: bool,
) -> None:
definition = "connector-definitions/blockchain-numbers"
definition = "connector-definitions/numbers"
configuration = {
"capture_token": capture_token,
"asset_type": asset_type,
Expand Down
2 changes: 1 addition & 1 deletion instill/resources/connector_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ def __init__(
api_key: str,
server_url: str,
) -> None:
definition = "connector-definitions/data-pinecone"
definition = "connector-definitions/pinecone"
configuration = {"url": server_url, "api_key": api_key}
super().__init__(client, name, definition, configuration)
6 changes: 4 additions & 2 deletions instill/resources/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def __init__(
) -> None:
super().__init__()
self.client = client
model = client.model_service.get_model(model_name=name, silent=True)
if model is None:
get_resp = client.model_service.get_model(model_name=name, silent=True)
if get_resp is None:
operation = client.model_service.create_model(
name=name,
definition=definition,
Expand All @@ -42,6 +42,8 @@ def __init__(
model = client.model_service.get_model(model_name=name).model
else:
raise BaseException("model creation failed")
else:
model = get_resp.model

self.resource = model

Expand Down
4 changes: 2 additions & 2 deletions instill/resources/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def create_start_operator(config: dict) -> pipeline_pb.Component:
start_operator_component = pipeline_pb.Component()
start_operator_component.id = "start"
start_operator_component.definition_name = "operator-definitions/op-start"
start_operator_component.definition_name = "operator-definitions/start"
start_operator_component.configuration.update(config)

return start_operator_component
Expand All @@ -14,7 +14,7 @@ def create_start_operator(config: dict) -> pipeline_pb.Component:
def create_end_operator(config: dict) -> pipeline_pb.Component:
end_operator_component = pipeline_pb.Component()
end_operator_component.id = "end"
end_operator_component.definition_name = "operator-definitions/op-end"
end_operator_component.definition_name = "operator-definitions/end"
end_operator_component.configuration.update(config)

return end_operator_component
6 changes: 4 additions & 2 deletions instill/resources/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ def __init__(
) -> None:
super().__init__()
self.client = client
pipeline = client.pipeline_service.get_pipeline(name=name, silent=True).pipeline
if pipeline is None:
get_resp = client.pipeline_service.get_pipeline(name=name, silent=True)
if get_resp is None:
pipeline = client.pipeline_service.create_pipeline(
name=name, recipe=recipe
).pipeline
if pipeline is None:
raise BaseException("pipeline creation failed")
else:
pipeline = get_resp.pipeline

self.resource = pipeline

Expand Down

0 comments on commit 6d30636

Please sign in to comment.