Skip to content

Commit 9d0b22e

Browse files
authored
Merge pull request #89 from mindsdb/server-info
Server info
2 parents 2824a9a + 7898fdb commit 9d0b22e

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

mindsdb_sdk/connectors/rest_api.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,11 @@ def upload_file(self, name: str, df: pd.DataFrame):
139139
'file': fd,
140140
}
141141
)
142-
_raise_for_status(r)
142+
_raise_for_status(r)
143+
144+
def status(self) -> dict:
145+
146+
r = self.session.get(self.url + f'/api/status')
147+
_raise_for_status(r)
148+
149+
return r.json()

mindsdb_sdk/server.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ def __init__(self, api):
4848
self.ml_handlers = Handlers(self.api, 'ml')
4949
self.data_handlers = Handlers(self.api, 'data')
5050

51+
def status(self) -> dict:
52+
"""
53+
Get server information. It could content version
54+
Example of getting version for local:
55+
>>> print(server.status()['mindsdb_version'])
56+
57+
:return: server status info
58+
"""
59+
return self.api.status()
60+
5161
def __repr__(self):
5262
return f'{self.__class__.__name__}({self.api.url})'
5363

tests/test_sdk.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,11 @@ def check_table(self, table, mock_post):
178178

179179
class Test(BaseFlow):
180180

181+
@patch('requests.Session.get')
181182
@patch('requests.Session.put')
182183
@patch('requests.Session.post')
183-
def test_flow(self, mock_post, mock_put):
184+
def test_flow(self, mock_post, mock_put, mock_get):
185+
184186
# check local
185187
server = mindsdb_sdk.connect()
186188
str(server)
@@ -194,6 +196,11 @@ def test_flow(self, mock_post, mock_put):
194196
assert call_args[0][0] == 'https://cloud.mindsdb.com/cloud/login'
195197
assert call_args[1]['json']['email'] == 'a@b.com'
196198

199+
# server status
200+
server.status()
201+
call_args = mock_get.call_args
202+
assert call_args[0][0] == 'https://cloud.mindsdb.com/api/status'
203+
197204
# --------- databases -------------
198205
response_mock(mock_post, pd.DataFrame([{'NAME': 'db1'}]))
199206

0 commit comments

Comments
 (0)