stan-dev / cmdstan

CmdStan, the command line interface to Stan
https://mc-stan.org/users/interfaces/cmdstan
BSD 3-Clause "New" or "Revised" License
210 stars 93 forks source link

Allow comma seperated list of names for inits, output files, etc. #1255

Open SteveBronder opened 5 months ago

SteveBronder commented 5 months ago

Summary:

Right now we have a very ad hoc approach to figure out the names for multiple chains. For a users id and the number of chains they have requested we just append _1..{num_chains} to the end of the file name for output. For inits we look if the user gave us a file ending with _id. and if so we search for num_chain arguments ending in _1...{num_chains}.

We chose this scheme at the time because I was calling cmdstan myself from the terminal and it was a clever shorthand so I didn't have to write out a bunch of file names.

But with the number of upstream packages calling Stan it might be easier for them to programatically generate the names of the files they want and pass a comma separated list of file names.

Additional Information:

Provide any additional information here.

Current Version:

v2.34.1

mitzimorris commented 5 months ago

what if the comma separated list of file names doesn't match the number of chains?

this makes more work for the user, since they'd need to pass in lists of file names for the output file and diagnostic file?

SteveBronder commented 5 months ago

what if the comma separated list of file names doesn't match the number of chains?

Then we would throw an error

this makes more work for the user, since they'd need to pass in lists of file names for the output file and diagnostic file?

Yes that's why we originally didn't do it. But now upstream packages are just writing the bash command with code so it might be easier for them to just supply the actual filenames instead of having to deal with the shorthand logic

mitzimorris commented 5 months ago

you're suggesting that the code that generates the command supply full file names? this feels like pushing bumps around under a rug. it's the same amount of work for the interfaces. as for CmdStan, don't want to touch the argument parser, which can't really handle lists - it would have to do a buncha processing to grab the filenames.

WardBrian commented 5 months ago

The parser wouldn't need to handle lists, just return the string which we can then split on ','

I think it would be nice from a cmdstan standpoint to remove all the implicit filename stuff we currently do. This would definitely create more work for users on the command line, but lead to more obvious behavior once they do that work.

The in-code interfaces need to generate the names anyway to read them, so it's 0 extra effort for those