Changing the ouput files dir after fitting in cmdstanpy

Hey all, I am running my code on a server for which I give input to fit = model.sampling(..., output_dit='output_files/')

After the fit is done, I save my fit object as a .pkl file(saved in binary) and I move the .pkl file to my local laptop along with the .csv and .txt files from the cmdstan output. I then use a pickle load to get the fit object for which I can extract stan_variables and method_variables but can not access the .csv files through the fit object. I want to know if there is a way to change the fit attributes which points to the “.csv” and “.txt” output files?

You can use .save_csvfiles on a fit object, and then re-create it with from_csv. We recommend this over pickling

https://cmdstanpy.readthedocs.io/en/v1.2.0/api.html#cmdstanpy.CmdStanMCMC.save_csvfiles

https://cmdstanpy.readthedocs.io/en/v1.2.0/api.html#cmdstanpy.from_csv

1 Like