Skip to content

Commit 62c5c8e

Browse files
hamishfaggStpMax
andauthored
Testing fixes (#11006)
Co-authored-by: Max Stepanov <stpmax@yandex.ru>
1 parent 2c5e7b2 commit 62c5c8e

4 files changed

Lines changed: 234 additions & 228 deletions

File tree

mindsdb/utilities/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,9 @@ def fetch_auto_config(self) -> bool:
404404
try:
405405
self._auto_config = json.loads(self.auto_config_path.read_text())
406406
except json.JSONDecodeError as e:
407-
raise ValueError(f"The 'auto' configuration file ({self.auto_config_path}) contains invalid JSON: {e}")
407+
raise ValueError(
408+
f"The 'auto' configuration file ({self.auto_config_path}) contains invalid JSON: {e}\nFile content: {self.auto_config_path.read_text()}"
409+
)
408410
self.auto_config_mtime = self.auto_config_path.stat().st_mtime
409411
return True
410412
return False

mindsdb/utilities/ml_task_queue/task.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,32 @@
88

99

1010
class Task:
11-
""" Abstraction for ML task. Should have interface similat to concurrent.futures.Future
11+
"""Abstraction for ML task. Should have interface similat to concurrent.futures.Future
1212
13-
Attributes:
14-
db (Redis): database object
15-
redis_key (RedisKey): redis keys associated with task
16-
dataframe (DataFrame): task result
17-
exception (Exception): task exeuton runtime exception
18-
_timeout (int): max time without status updating
13+
Attributes:
14+
db (Redis): database object
15+
redis_key (RedisKey): redis keys associated with task
16+
dataframe (DataFrame): task result
17+
exception (Exception): task exeuton runtime exception
18+
_timeout (int): max time without status updating
1919
"""
2020

2121
def __init__(self, connection: redis.Redis, redis_key: RedisKey) -> None:
2222
self.db = connection
2323
self.redis_key = redis_key
2424
self.dataframe = None
2525
self.exception = None
26-
self._timeout = 30
26+
self._timeout = 60
2727

2828
def subscribe(self) -> ML_TASK_STATUS:
29-
""" return tasks status untill it is not done or failed
30-
"""
29+
"""return tasks status untill it is not done or failed"""
3130
pubsub = self.db.pubsub()
3231
cache = self.db.cache()
3332
pubsub.subscribe(self.redis_key.status)
34-
while (msg := pubsub.get_message(timeout=self._timeout)):
35-
if msg['type'] not in pubsub.PUBLISH_MESSAGE_TYPES:
33+
while msg := pubsub.get_message(timeout=self._timeout):
34+
if msg["type"] not in pubsub.PUBLISH_MESSAGE_TYPES:
3635
continue
37-
ml_task_status = ML_TASK_STATUS(msg['data'])
36+
ml_task_status = ML_TASK_STATUS(msg["data"])
3837
if ml_task_status == ML_TASK_STATUS.COMPLETE:
3938
dataframe_bytes = cache.get(self.redis_key.dataframe)
4039
if dataframe_bytes is not None:
@@ -51,32 +50,30 @@ def subscribe(self) -> ML_TASK_STATUS:
5150
yield ml_task_status
5251

5352
def wait(self, status: ML_TASK_STATUS = ML_TASK_STATUS.COMPLETE) -> None:
54-
""" block threasd untill task is not done or failed
55-
"""
53+
"""block threasd untill task is not done or failed"""
5654
for status in self.subscribe():
5755
if status in (ML_TASK_STATUS.WAITING, ML_TASK_STATUS.PROCESSING):
5856
continue
5957
if status == ML_TASK_STATUS.ERROR:
6058
if self.exception is not None:
6159
raise self.exception
6260
else:
63-
raise Exception('Unknown error during ML task execution')
61+
raise Exception("Unknown error during ML task execution")
6462
if status == ML_TASK_STATUS.TIMEOUT:
6563
raise Exception(f"Can't get answer in {self._timeout} seconds")
6664
if status == ML_TASK_STATUS.COMPLETE:
6765
return
68-
raise KeyError('Unknown task status')
66+
raise KeyError("Unknown task status")
6967

7068
def result(self) -> DataFrame:
71-
""" wait task is done and return result
69+
"""wait task is done and return result
7270
73-
Returns:
74-
DataFrame: task result
71+
Returns:
72+
DataFrame: task result
7573
"""
7674
self.wait()
7775
return self.dataframe
7876

7977
def add_done_callback(self, fn: Callable) -> None:
80-
""" need for compatability with concurrent.futures.Future interface
81-
"""
78+
"""need for compatability with concurrent.futures.Future interface"""
8279
pass

0 commit comments

Comments
 (0)