Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions instill/clients/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ def set_instance(self, instance: str):
self.pipeline_service.instance = instance
self.model_service.instance = instance

def close(self):
if self.mgmt_service.is_serving():
for host in self.mgmt_service.hosts.values():
host["channel"].close()
if self.connector_service.is_serving():
for host in self.connector_service.hosts.values():
host["channel"].close()
if self.pipeline_service.is_serving():
for host in self.pipeline_service.hosts.values():
host["channel"].close()
if self.model_service.is_serving():
for host in self.model_service.hosts.values():
host["channel"].close()


def get_client() -> InstillClient:
global _client
Expand Down
8 changes: 4 additions & 4 deletions instill/resources/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ def __init__(

self.resource = connector

def __del__(self):
if self.resource is not None:
self.client.connector_service.delete_connector(self.resource.id)

def __call__(self, task_inputs: list, mode="execute") -> list:
if mode == "execute":
return self.client.connector_service.execute_connector(
Expand Down Expand Up @@ -73,3 +69,7 @@ def get_state(self) -> connector_interface.ConnectorResource.State:

def test(self) -> connector_interface.ConnectorResource.State:
return self.client.connector_service.test_connector(self.resource.id)

def delete(self):
if self.resource is not None:
self.client.connector_service.delete_connector(self.resource.id)
8 changes: 4 additions & 4 deletions instill/resources/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ def __init__(

self.resource = model

def __del__(self):
if self.resource is not None:
self.client.model_service.delete_model(self.resource.id)

def __call__(self, task_inputs: list) -> list:
return self.client.model_service.trigger_model(self.resource.id, task_inputs)

Expand Down Expand Up @@ -72,6 +68,10 @@ def undeploy(self) -> model_interface.Model:
self._update()
return self._resource

def delete(self):
if self.resource is not None:
self.client.model_service.delete_model(self.resource.id)


class GithubModel(Model):
def __init__(
Expand Down
8 changes: 4 additions & 4 deletions instill/resources/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ def __init__(

self.resource = pipeline

def __del__(self):
if self.resource is not None:
self.client.pipeline_service.delete_pipeline(self.resource.id)

def __call__(
self, task_inputs: list
) -> Tuple[list, pipeline_interface.TriggerMetadata]:
Expand Down Expand Up @@ -58,3 +54,7 @@ def get_recipe(self) -> str:

def validate_pipeline(self) -> pipeline_interface.Pipeline:
return self.client.pipeline_service.validate_pipeline(name=self.resource.id)

def delete(self):
if self.resource is not None:
self.client.pipeline_service.delete_pipeline(self.resource.id)