Skip to content

Commit

Permalink
fixed and simplifications to USING syntax parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
George3d6 committed Feb 1, 2022
1 parent fbce36b commit 4edabd4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
13 changes: 8 additions & 5 deletions mindsdb/interfaces/model/learn_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,18 @@ def run_generate(df: DataFrame, problem_definition: ProblemDefinition, predictor
print('Override of: ', json_ai_override)
if json_ai_override is None:
json_ai_override = {}

print(1)
for k in json_ai_override:
json_ai_override[k] = json.loads(json_ai_override[k])

if isinstance(json_ai_override[k], str):
if '{' in json_ai_override[k] and '}' in json_ai_override[k]:
json_ai_override[k] = json.loads(json_ai_override[k])
print(2)
json_ai_override = brack_to_mod(json_ai_override)

print(3)
json_ai = json_ai.to_dict()
print(4)
rep_recur(json_ai, json_ai_override)
print(json_ai, json_ai_override)
print('Result: ', json_ai, 'Override: ', json_ai_override)

json_ai = JsonAI.from_dict(json_ai)

Expand Down
12 changes: 9 additions & 3 deletions mindsdb/interfaces/model/model_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,19 @@ def _unpack_old_args(
f"Predict target must be 'str' or 'list' with 1 element. Got: {to_predict}"
)

print(kwargs)
while '.' in str(list(kwargs.keys())):
for k in list(kwargs.keys()):
if '.' in k:
lhs = '.'.join(k.split('.')[:-1])
rhs = {k.split('.')[-1]: kwargs[k]}
kwargs[lhs] = rhs
nks = k.split('.')
obj = kwargs
for nk in nks[:-1]:
if nk not in obj:
obj[nk] = {}
obj = obj[nk]
obj[nks[-1]] = kwargs[k]
del kwargs[k]
print(kwargs)

join_learn_process = kwargs.get('join_learn_process', False)
if 'join_learn_process' in kwargs:
Expand Down

0 comments on commit 4edabd4

Please sign in to comment.