radiasoft / sirepo

Sirepo is a framework for scientific cloud computing. Try it out!
https://sirepo.com
Apache License 2.0
64 stars 32 forks source link

srw prepare_for_client saves data that prepare_for_save should handle #6521

Open robnagler opened 1 year ago

robnagler commented 1 year ago

Working #5198 which changes the way saves happen. In the current srw.import_file, the import of import_data/srw_6.py produces a result that is invalid: models.electronBeam does not have an id. There is an ad hoc fixup that happens at the end via a call_api of simulationData. The data has already been saved with modified set to false, which if true, would fail here in srw.prepare_for_save. That is, the data on disk (in sirepo-data.json) is invalid at this point but the call to simulationData fixes it up via a call to prepare_for_client, which calls save_simulation_json.

In the new model, it's just like the other imports and _save_new_and_reply is called, which blows up, because prepare_for_client is not called.

I think prepare_for_client is implemented incorrectly. First, template.srw is the only template that calls save_simulation_json, which means it is out of line with other templates. Second, the work of fixing up the models should be done in prepare_for_save, not prepare_for_client.

robnagler commented 1 year ago

prepare_for_save should get deleted. It is trying to what prepare_for_client is doing, but it does it incorrectly. prepare_for_client will be called at the end of the importFile API. Related #6526

robnagler commented 1 year ago

prepare_for_save can't be deleted at this stage. #6526 will do this. For now, just fixing prepare_for_save