open-research / sumatra

http://neuralensemble.org/sumatra/
BSD 2-Clause "Simplified" License
127 stars 48 forks source link

unexpected keyword argument 'add_extension' when a YAML file is named '*.yml' #357

Closed frexvahi closed 7 years ago

frexvahi commented 7 years ago
$ smt run --executable=/usr/bin/python3 --main=job.py data.yml
Traceback (most recent call last):
  File "/home/cjk/.conda/envs/sumatra/bin/smt", line 31, in <module>
    main(sys.argv[2:])
  File "/home/cjk/.conda/envs/sumatra/lib/python2.7/site-packages/sumatra/commands.py", line 403, in run
    version=args.version or 'current')
  File "/home/cjk/.conda/envs/sumatra/lib/python2.7/site-packages/sumatra/projects.py", line 217, in launch
    record.run(with_label=self.data_label)
  File "/home/cjk/.conda/envs/sumatra/lib/python2.7/site-packages/sumatra/records.py", line 153, in run
    self.parameter_file = self.executable.write_parameters(self.parameters, parameter_file_basename)
  File "/home/cjk/.conda/envs/sumatra/lib/python2.7/site-packages/sumatra/programs.py", line 126, in write_parameters
    filename = parameters.save(filebasename, add_extension=True)
TypeError: save() got an unexpected keyword argument 'add_extension'
frexvahi commented 7 years ago

job.py is just print("Hello, world!"). data.yml is some random YAML.

$ cat data.yml
a:
  b:
  - 3
  - 7
frexvahi commented 7 years ago

After renaming to 'data.yaml' it works

$ smt run --executable=/usr/bin/python3 --main=job.py data.yaml
Hello, world
Record label for this run: '20170512-175829'
No data produced.
frexvahi commented 7 years ago

This happens both with the latest release (pip install sumatra) and the github master (pip install git+ssh://git@github.com/open-research/sumatra.git)

frexvahi commented 7 years ago

Running in the debugger shows that the parameters file has been detected as a NTParameterSet. The YAML has however been parsed correctly.

$ python -m pdb `which smt` run --executable=/usr/bin/python3 --main=job.py data.yml
> /home/cjk/.conda/envs/sumatra/bin/smt(4)<module>()
-> """
(Pdb) c
Traceback (most recent call last):
 . . .
TypeError: save() got an unexpected keyword argument 'add_extension'
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /home/cjk/.conda/envs/sumatra/lib/python2.7/site-packages/sumatra/programs.py(126)write_parameters()
-> filename = parameters.save(filebasename, add_extension=True)
(Pdb) p type(parameters)
<class 'sumatra.parameters.NTParameterSet'>
(Pdb) p parameters
{'a': {'b': [3, 7]}}
apdavison commented 7 years ago

The specific error was fixed in #359, so you should be ok with the latest master.

The file is still not detected as a YAML file, however. I've created #367 to address this.