From abcf53c853bf7ad2add98c6dfa99449a9cd458ac Mon Sep 17 00:00:00 2001 From: Lucas Koontz Date: Fri, 7 Jun 2024 20:17:06 -0400 Subject: [PATCH] feat: provide error context when creating mind --- mindsdb_sdk/__about__.py | 2 +- mindsdb_sdk/utils/mind.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/mindsdb_sdk/__about__.py b/mindsdb_sdk/__about__.py index 5732b35..f5f9a75 100755 --- a/mindsdb_sdk/__about__.py +++ b/mindsdb_sdk/__about__.py @@ -1,6 +1,6 @@ __title__ = 'mindsdb_sdk' __package_name__ = 'mindsdb_sdk' -__version__ = '2.4.1' +__version__ = '2.4.2' __description__ = "MindsDB Python SDK, provides an SDK to use a remote mindsdb instance" __email__ = "jorge@mindsdb.com" __author__ = 'MindsDB Inc' diff --git a/mindsdb_sdk/utils/mind.py b/mindsdb_sdk/utils/mind.py index 0c83b02..7108e9b 100644 --- a/mindsdb_sdk/utils/mind.py +++ b/mindsdb_sdk/utils/mind.py @@ -1,4 +1,7 @@ import requests +from logging import getLogger + +logger = getLogger(__name__) # Define the Mind entity @@ -46,8 +49,12 @@ def create_mind( "data_source_type": data_source_type, "data_source_connection_args": data_source_connection_args } - response = requests.post(url, json=payload, headers=headers) - response.raise_for_status() + try: + response = requests.post(url, json=payload, headers=headers) + response.raise_for_status() + except requests.exceptions.HTTPError as e: + logger.error(f"Failed to create mind: {e.response.json()}") + raise e name = response.json()['name']