diff --git a/mindsdb_sdk/connectors/rest_api.py b/mindsdb_sdk/connectors/rest_api.py index 687a263..27fc32c 100644 --- a/mindsdb_sdk/connectors/rest_api.py +++ b/mindsdb_sdk/connectors/rest_api.py @@ -139,4 +139,11 @@ def upload_file(self, name: str, df: pd.DataFrame): 'file': fd, } ) - _raise_for_status(r) \ No newline at end of file + _raise_for_status(r) + + def status(self) -> dict: + + r = self.session.get(self.url + f'/api/status') + _raise_for_status(r) + + return r.json() diff --git a/mindsdb_sdk/server.py b/mindsdb_sdk/server.py index 00dc0a4..ccb8671 100644 --- a/mindsdb_sdk/server.py +++ b/mindsdb_sdk/server.py @@ -48,6 +48,16 @@ def __init__(self, api): self.ml_handlers = Handlers(self.api, 'ml') self.data_handlers = Handlers(self.api, 'data') + def status(self) -> dict: + """ + Get server information. It could content version + Example of getting version for local: + >>> print(server.status()['mindsdb_version']) + + :return: server status info + """ + return self.api.status() + def __repr__(self): return f'{self.__class__.__name__}({self.api.url})' diff --git a/tests/test_sdk.py b/tests/test_sdk.py index fd5a517..decfca5 100644 --- a/tests/test_sdk.py +++ b/tests/test_sdk.py @@ -178,9 +178,11 @@ def check_table(self, table, mock_post): class Test(BaseFlow): + @patch('requests.Session.get') @patch('requests.Session.put') @patch('requests.Session.post') - def test_flow(self, mock_post, mock_put): + def test_flow(self, mock_post, mock_put, mock_get): + # check local server = mindsdb_sdk.connect() str(server) @@ -194,6 +196,11 @@ def test_flow(self, mock_post, mock_put): assert call_args[0][0] == 'https://cloud.mindsdb.com/cloud/login' assert call_args[1]['json']['email'] == 'a@b.com' + # server status + server.status() + call_args = mock_get.call_args + assert call_args[0][0] == 'https://cloud.mindsdb.com/api/status' + # --------- databases ------------- response_mock(mock_post, pd.DataFrame([{'NAME': 'db1'}]))