Dear Developers,
I find the dict mod syntax a very powerful tool for chaining fireworks / firetasks. However it seems the current implementation does not correctly handle the nested array and dict situations, while the same syntax is supported by Mongo standard (If I’m not mistaken).
What I want to achieve:
Firework 1 → FWAction(mod_spec={"_set": {"_tasks->0->param1": value}}) → Firework 2
when firework 1 changes some parameters in one specific task of firework 2 (in addition to fw_spec).
The key _tasks->0->param1
is supposed to be equivalent to _tasks.0.param1
in mongo standard. However the current Fireworks implementation will raise error
TypeError: list indices must be integers or slices, not str
because the expression is translated to fw_spec["_tasks"]["0"]["param1"]
instead of fw_spec["_tasks"][0]["param1"]
(in fireworks/utilities/dict_mods.py
)
I think in most cases the integer inside the string should be interpreted as index instead of key. Is it ok to change the behavior of get_nested_dict
in dict_mods.py
?