Skip to content

Commit c909d0b

Browse files
authored
Merge pull request #54 from mindsdb/fix-ci
Fixing release issues
2 parents dcbe1e5 + 90895d1 commit c909d0b

File tree

4 files changed

+16
-20
lines changed

4 files changed

+16
-20
lines changed

minds/datasources/datasources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def create(self, ds_config: DatabaseConfig, update=False):
3838
name = ds_config.name
3939

4040
if update:
41-
self.api.put('/datasources', data=ds_config.model_dump())
41+
self.api.put(f'/datasources/{name}', data=ds_config.model_dump())
4242
else:
4343
self.api.post('/datasources', data=ds_config.model_dump())
4444
return self.get(name)

minds/minds.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from typing import List, Union, Iterable
2-
import utils
32
from openai import OpenAI
43
import minds.utils as utils
54
import minds.exceptions as exc
@@ -278,11 +277,13 @@ def create(
278277

279278
if update:
280279
method = self.api.put
280+
url = f'/projects/{self.project}/minds/{name}'
281281
else:
282282
method = self.api.post
283+
url = f'/projects/{self.project}/minds'
283284

284285
method(
285-
f'/projects/{self.project}/minds',
286+
url,
286287
data={
287288
'name': name,
288289
'model_name': model_name,

tests/integration/test_base_flow.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_minds():
7373
# prepare datasources
7474
ds_cfg = copy.copy(example_ds)
7575
ds_cfg.name = ds_name
76-
ds = client.datasources.create(example_ds, replace=True)
76+
ds = client.datasources.create(example_ds, update=True)
7777

7878
# second datasource
7979
ds2_cfg = copy.copy(example_ds)
@@ -82,7 +82,7 @@ def test_minds():
8282

8383
# create
8484
with pytest.raises(MindNameInvalid):
85-
mind = client.minds.create(
85+
client.minds.create(
8686
invalid_mind_name,
8787
datasources=[ds],
8888
provider='openai'
@@ -110,9 +110,6 @@ def test_minds():
110110
mind = client.minds.get(mind_name)
111111
assert len(mind.datasources) == 2
112112
assert mind.prompt_template == prompt1
113-
114-
with pytest.raises(MindNameInvalid):
115-
client.minds.get(invalid_mind_name)
116113

117114
# list
118115
mind_list = client.minds.list()
@@ -179,6 +176,4 @@ def test_minds():
179176
client.minds.drop(mind_name2)
180177
client.datasources.drop(ds.name)
181178
client.datasources.drop(ds2_cfg.name)
182-
183-
with pytest.raises(MindNameInvalid):
184-
client.minds.drop(invalid_mind_name)
179+

tests/unit/test_unit.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ def test_create_datasources(self, mock_del, mock_post, mock_put, mock_get):
4444
response_mock(mock_get, example_ds.model_dump())
4545

4646
ds = client.datasources.create(example_ds)
47-
def check_ds_created(ds, mock_post):
47+
def check_ds_created(ds, mock_post, url):
4848
self._compare_ds(ds, example_ds)
4949
args, kwargs = mock_post.call_args
5050

5151
assert kwargs['headers'] == {'Authorization': 'Bearer ' + API_KEY}
5252
assert kwargs['json'] == example_ds.model_dump()
53-
assert args[0] == 'https://mdb.ai/api/datasources'
53+
assert args[0] == url
5454

55-
check_ds_created(ds, mock_post)
55+
check_ds_created(ds, mock_post, 'https://mdb.ai/api/datasources')
5656

5757
# with update
5858
ds = client.datasources.create(example_ds, update=True)
59-
check_ds_created(ds, mock_put)
59+
check_ds_created(ds, mock_put, f'https://mdb.ai/api/datasources/{ds.name}')
6060

6161
@patch('requests.get')
6262
def test_get_datasource(self, mock_get):
@@ -132,17 +132,17 @@ def test_create(self, mock_del, mock_post, mock_put, mock_get):
132132
}
133133
mind = client.minds.create(**create_params)
134134

135-
def check_mind_created(mind, mock_post, create_params):
135+
def check_mind_created(mind, mock_post, create_params, url):
136136
args, kwargs = mock_post.call_args
137-
assert args[0].endswith('/api/projects/mindsdb/minds')
137+
assert args[0].endswith(url)
138138
request = kwargs['json']
139139
for key in ('name', 'datasources', 'provider', 'model_name'),:
140140
assert request.get(key) == create_params.get(key)
141141
assert create_params.get('prompt_template') == request.get('parameters', {}).get('prompt_template')
142142

143143
self.compare_mind(mind, self.mind_json)
144144

145-
check_mind_created(mind, mock_post, create_params)
145+
check_mind_created(mind, mock_post, create_params, '/api/projects/mindsdb/minds')
146146

147147
# -- with replace --
148148
create_params = {
@@ -156,15 +156,15 @@ def check_mind_created(mind, mock_post, create_params):
156156
args, _ = mock_del.call_args
157157
assert args[0].endswith(f'/api/projects/mindsdb/minds/{mind_name}')
158158

159-
check_mind_created(mind, mock_post, create_params)
159+
check_mind_created(mind, mock_post, create_params, '/api/projects/mindsdb/minds')
160160

161161
# -- with update --
162162
mock_del.reset_mock()
163163
mind = client.minds.create(update=True, **create_params)
164164
# is not deleted
165165
assert not mock_del.called
166166

167-
check_mind_created(mind, mock_put, create_params)
167+
check_mind_created(mind, mock_put, create_params, f'/api/projects/mindsdb/minds/{mind_name}')
168168

169169
@patch('requests.get')
170170
@patch('requests.patch')

0 commit comments

Comments
 (0)