Skip to content

Commit

Permalink
Handle case when runtime parameters list is passed as string (click b…
Browse files Browse the repository at this point in the history
…eing click..)

Signed-off-by: Merel Theisen <merel.theisen@quantumblack.com>
  • Loading branch information
merelcht committed Oct 4, 2024
1 parent eb209b5 commit d18291a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions kedro/framework/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

import ast
import difflib
import importlib
import logging
Expand Down Expand Up @@ -469,6 +470,15 @@ def _split_params(ctx: click.Context, param: Any, value: Any) -> Any:
return value
if isinstance(value, list) and len(value) == 1:
value = value[0]
# Try evaluating the string as a Python literal in case it contains a list
if isinstance(value, str):
try:
evaluated_value = ast.literal_eval(value)
if isinstance(evaluated_value, list) and len(evaluated_value) == 1:
value = evaluated_value[0]
except (ValueError, SyntaxError):
pass # Safely continue if the evaluation fails

dot_list = []
for item in split_string(ctx, param, value):
equals_idx = item.find("=")
Expand Down

0 comments on commit d18291a

Please sign in to comment.