diff --git a/minds/datasources/datasources.py b/minds/datasources/datasources.py index f46a645..688faa4 100644 --- a/minds/datasources/datasources.py +++ b/minds/datasources/datasources.py @@ -38,7 +38,7 @@ def create(self, ds_config: DatabaseConfig, replace=False): if replace: try: self.get(name) - self.drop(name) + self.drop(name, force=True) except exc.ObjectNotFound: ... @@ -76,11 +76,15 @@ def get(self, name: str) -> Datasource: raise exc.ObjectNotSupported(f'Wrong type of datasource: {name}') return Datasource(**data) - def drop(self, name: str): + def drop(self, name: str, force=False): """ Drop datasource by name :param name: name of datasource + :param force: if True - remove from all minds, default: False """ + data = None + if force: + data = {'cascade': True} - self.api.delete(f'/datasources/{name}') + self.api.delete(f'/datasources/{name}', data=data) diff --git a/minds/rest_api.py b/minds/rest_api.py index 569a62a..5bc00d5 100644 --- a/minds/rest_api.py +++ b/minds/rest_api.py @@ -37,8 +37,12 @@ def get(self, url): _raise_for_status(resp) return resp - def delete(self, url): - resp = requests.delete(self.base_url + url, headers=self._headers()) + def delete(self, url, data=None): + resp = requests.delete( + self.base_url + url, + headers=self._headers(), + json=data + ) _raise_for_status(resp) return resp diff --git a/tests/integration/test_base_flow.py b/tests/integration/test_base_flow.py index 8d7aa1d..8356d77 100644 --- a/tests/integration/test_base_flow.py +++ b/tests/integration/test_base_flow.py @@ -31,7 +31,7 @@ def test_datasources(): # remove previous object try: - client.datasources.drop(example_ds.name) + client.datasources.drop(example_ds.name, force=True) except ObjectNotFound: ...