Skip to content

Commit

Permalink
Merge pull request #89 from mindsdb/server-info
Browse files Browse the repository at this point in the history
Server info
  • Loading branch information
ea-rus authored Jan 15, 2024
2 parents 2824a9a + 7898fdb commit 9d0b22e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
9 changes: 8 additions & 1 deletion mindsdb_sdk/connectors/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,11 @@ def upload_file(self, name: str, df: pd.DataFrame):
'file': fd,
}
)
_raise_for_status(r)
_raise_for_status(r)

def status(self) -> dict:

r = self.session.get(self.url + f'/api/status')
_raise_for_status(r)

return r.json()
10 changes: 10 additions & 0 deletions mindsdb_sdk/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})'

Expand Down
9 changes: 8 additions & 1 deletion tests/test_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'] == '[email protected]'

# 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'}]))

Expand Down

0 comments on commit 9d0b22e

Please sign in to comment.