for entity in child_entities:
last_saved_params = entity.last_saved_params
last_saved_params["new_param"] = "new_value"
This works great, no problem at all.
- Summary is not updated
- Param is not part of last saved params in case o a new API call to all child entities. So all view/methods containing these child entities will not use the “set_params” values as last saved values.
The same goes for entities (files) that have been uploaded, but never opened/saved. They will have all values present if you open them, but if you were just to use them in a batch method, the params are not present.
How to convert the set_params result to usable last_saved_params without having to manually open them?
Solved, it was my own problem.
Using the method:
def process_file(self, file: File, **kwargs) -> dict:
the dict didn’t contain all keys from the parametrization (as we did some updates along the way).
So the last saved params of new entities, didn’t contain those keys either. When updating it with the set_params method, those keys still weren’t present.
Solution was adding the “default values” defined in the parametrization within the process_file method. As the default values of the Parametrization class are only called upon if you first open the editor of the entity and are only saved into last_saved_params once you save the new entity.
Maybe it is an idea for Viktor to check the default values of all keys in the Parametrization Class after the process_file if they didn’t get a key when uploading.