Prefer list
to dictionary
in configuration for multi-items.
#33
YooSunYoung
started this conversation in
Design Choices
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background Reason
name
in the configuration chunk of each item (workflow or target or application).At the beginning, when you have multiple items in the field, I tried to write them as dictionaries.
For example, workflow configuration was written like below.
But one day I made a mistake to use the same name twice for different
target
and then the second one just overwrites it andpyyaml
doesn't really tell you.Another annoying thing is when you want to map a function over all the items in the
workflows
ortargets
, you might want to use thename
, which used to be thekey
.You can also just map over
dict.items()
, for me it was more straightforward to have thename
as a field of each item-dictionary, not as a separate variable.So I made all configuration fields that has multiple items as
list
rather thandict
and each item hasname
field that represents the name.Now it looks like this:
Pros
By this way, we can also avoid checking if it is a
list
or adictionary
since it will always be lists.Cons
You can't directly access to the item you want by
name
.So in the
data-reduction
application module, it makes a dictionary out of the list first and then use thename
as the key.The overwriting error raise should be implemented.
Beta Was this translation helpful? Give feedback.
All reactions