Skip to content

Commit

Permalink
Make yaml less important
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemartinlogan committed Feb 23, 2024
1 parent fa60993 commit e517331
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion jarvis_util/util/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,10 @@ def _convert_opt(self, opt, arg):
try:
if opt_type is list:
if isinstance(arg, str):
arg = yaml.safe_load(arg)
try:
arg = yaml.safe_load(arg)
except:
pass
if not isinstance(arg, list):
if arg is None:
arg = []
Expand Down
6 changes: 6 additions & 0 deletions test/unit/test_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ def test_list_arg4(self):
self.assertEqual(15, args.kwargs['steps'])
self.assertEqual([], args.kwargs['hosts'])

def test_list_arg5(self):
args = MyArgParse(
args='vpic run 15 --hosts="*.hdf5" --hosts="*.h5"')
self.assertEqual(15, args.kwargs['steps'])
self.assertEqual(['*.hdf5', '*.h5'], args.kwargs['hosts'])

def test_list_list_arg(self):
args = MyArgParse(args='vpic run 15 '
'--devices=\"[[nvme, 5], [sata, 25]]\"')
Expand Down

0 comments on commit e517331

Please sign in to comment.