Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to parse list parameter from cli argument: JSONDecodeError #3210

Open
ymentha14 opened this issue Nov 28, 2022 · 1 comment
Open

Fails to parse list parameter from cli argument: JSONDecodeError #3210

ymentha14 opened this issue Nov 28, 2022 · 1 comment

Comments

@ymentha14
Copy link

foo.py

import luigi

class Foo(luigi.Task):
    bar = luigi.ListParameter(default="['foo']")
    def run(self):
        print(f"Running task {self}")
    def output(self):
        return luigi.LocalTarget("./foo.txt")

Running luigi --module foo Foo --bar 'bar' results in json.decoder.JSONDEcodeError: Expecting value: line1 column 1 (char 0)

Stacktrace:

ERROR: Uncaught exception in luigi
Traceback (most recent call last):
  File "/home/lib/python3.8/site-packages/luigi/retcodes.py", line 75, in run_with_retcodes
    worker = luigi.interface._run(argv).worker
  File "/home/lib/python3.8/site-packages/luigi/interface.py", line 213, in _run
    return _schedule_and_run([cp.get_task_obj()], worker_scheduler_factory)
  File "/home/lib/python3.8/site-packages/luigi/cmdline_parser.py", line 114, in get_task_obj
    return self._get_task_cls()(**self._get_task_kwargs())
  File "/home/lib/python3.8/site-packages/luigi/cmdline_parser.py", line 131, in _get_task_kwargs
    res.update(((param_name, param_obj.parse(attr)),))
  File "/home/lib/python3.8/site-packages/luigi/parameter.py", line 1140, in parse
    i = json.loads(x, object_pairs_hook=FrozenOrderedDict)
  File "/usr/lib/python3.8/json/__init__.py", line 370, in loads
    return cls(**kw).decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Expected Behavior:
The command should complete successfully

OS: Ubuntu
python: 3.8.10
luigi : 3.1.1

@lallea
Copy link
Contributor

lallea commented Nov 28, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants