Skip to content

Commit faef616

Browse files
committed
Merge branch 'staging' of https://github.com/mindsdb/mindsdb_python_sdk into agents-base
2 parents 0716324 + 99d9616 commit faef616

File tree

6 files changed

+25
-17
lines changed

6 files changed

+25
-17
lines changed

.github/workflows/mindsdb_python_sdk.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ jobs:
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip==22.0.4
25-
pip install -r requirements.txt
25+
pip install -r requirements.txt
26+
pip install -r requirements_test.txt
2627
pip install --no-cache-dir .
2728
- name: Run tests
2829
run: |
@@ -54,8 +55,9 @@ jobs:
5455
- name: Install dependencies
5556
run: |
5657
python -m pip install --upgrade pip
57-
pip install flake8 pytest pytest-cov
58-
pip install -r requirements.txt
58+
pip install flake8
59+
pip install -r requirements.txt
60+
pip install -r requirements_test.txt
5961
6062
- name: Build coverage file
6163
run: |

mindsdb_sdk/jobs.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,7 @@ def __init__(self, project, api):
5555
self.project = project
5656
self.api = api
5757

58-
def list(self, name: str = None) -> List[Job]:
59-
"""
60-
Show list of jobs in project
61-
62-
:return: list of Job objects
63-
"""
58+
def _list(self, name: str = None) -> List[Job]:
6459

6560
ast_query = Select(targets=[Star()], from_table=Identifier('jobs'))
6661

@@ -78,6 +73,15 @@ def list(self, name: str = None) -> List[Job]:
7873
for item in df.to_dict('records')
7974
]
8075

76+
def list(self) -> List[Job]:
77+
"""
78+
Show list of jobs in project
79+
80+
:return: list of Job objects
81+
"""
82+
83+
return self._list()
84+
8185
def get(self, name: str) -> Job:
8286
"""
8387
Get job by name from project
@@ -86,7 +90,7 @@ def get(self, name: str) -> Job:
8690
:return: Job object
8791
"""
8892

89-
jobs = self.list(name)
93+
jobs = self._list(name)
9094
if len(jobs) == 1:
9195
return jobs[0]
9296
elif len(jobs) == 0:
@@ -133,7 +137,7 @@ def create(self, name: str, query_str: str,
133137
self.api.sql_query(ast_query.to_string(), database=self.project.name)
134138

135139
# job can be executed and remove it is not repeatable
136-
jobs = self.list(name)
140+
jobs = self._list(name)
137141
if len(jobs) == 1:
138142
return jobs[0]
139143

mindsdb_sdk/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Model:
3030
3131
Get info
3232
33-
>>> print(model.status)
33+
>>> print(model.get_status())
3434
>>> print(model.data)
3535
3636
Update model data from server

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
requests
22
pandas >= 1.3.5
3-
mindsdb-sql >= 0.7.0, < 0.11.0
3+
mindsdb-sql >= 0.12.0, < 0.13.0

requirements_test.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pytest
2+
pytest-cov

tests/test_sdk.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def check_model(self, model, database, mock_post):
108108
model.predict(query)
109109

110110
check_sql_call(mock_post,
111-
f"SELECT m.* FROM (SELECT * FROM t1 WHERE (type = 'house') AND (saledate > LATEST)) as t JOIN {model.project.name}.{model_name} AS m")
111+
f"SELECT m.* FROM (SELECT * FROM t1 WHERE type = 'house' AND saledate > LATEST) as t JOIN {model.project.name}.{model_name} AS m")
112112
assert (pred_df == pd.DataFrame(data_out)).all().bool()
113113

114114
# ----------- model managing --------------
@@ -166,7 +166,7 @@ def check_model(self, model, database, mock_post):
166166
# get call before last call
167167
mock_call = mock_post.call_args_list[-2]
168168
assert mock_call[1]['json'][
169-
'query'] == f"update models_versions set active=1 where (name = '{model2.name}') AND (version = 3)"
169+
'query'] == f"update models_versions set active=1 where name = '{model2.name}' AND version = 3"
170170

171171
@patch('requests.Session.post')
172172
def check_table(self, table, mock_post):
@@ -176,7 +176,7 @@ def check_table(self, table, mock_post):
176176
table = table.limit(3)
177177
table.fetch()
178178
str(table)
179-
check_sql_call(mock_post, f'SELECT * FROM {table.name} WHERE (a = 3) AND (b = \'2\') LIMIT 3')
179+
check_sql_call(mock_post, f'SELECT * FROM {table.name} WHERE a = 3 AND b = \'2\' LIMIT 3')
180180

181181

182182
class Test(BaseFlow):
@@ -977,7 +977,7 @@ def check_database(self, database, mock_post):
977977

978978
# -- delete in table --
979979
table2.delete(a=1, b='2')
980-
check_sql_call(mock_post, f"DELETE FROM {database.name}.t2 WHERE (a = 1) AND (b = '2')")
980+
check_sql_call(mock_post, f"DELETE FROM {database.name}.t2 WHERE a = 1 AND b = '2'")
981981

982982
# -- update table --
983983
# from query

0 commit comments

Comments
 (0)