pliers
pliers copied to clipboard
graph to_json doesn't save enough arguments to reload Transformer with required arguments
Here's a simple example of a Pliers Graph
nodes = [
(FrameSamplingFilter(every=10),
['BrightnessExtractor']),
(STFTAudioExtractor(freq_bins=[(100, 300)]))
]
and it outputs this JSON:
g.to_json()
>{'roots': [{'transformer': 'FrameSamplingFilter',
'children': [{'transformer': 'BrightnessExtractor'}]},
{'transformer': 'STFTAudioExtractor'}]}
However, this same JSON cannot initialize a Graph object:
Graph(nodes=j)
>ValueError: When initializing the FrameSamplingFilter, one of the 'every', 'hertz', or 'top_n' must be specified.
This is because the JSON does not specify the arguments that were originally passed into FrameSamplingFilter.
The reason I'm asking is I'm trying to implement the ability to extract Graphs in Neuroscout (current we only do one extractor at a time, and I have my own JSON notation for specifying arguments to Extractors).
I think it would make more sense to exploit the fact that pliers already has a JSON format for specifying sequences of extractors, and simply load the graph from JSON and transform the stimuli.
Is this a bug or am I missing something?
I spoke too soon as usually, obviously you can pass arguments in the JSON
j ={'roots': [{'transformer': 'FrameSamplingFilter', 'parameters': {'every': 10},
'children': [{'transformer': 'BrightnessExtractor'}]},
{'transformer': 'STFTAudioExtractor'}]}
I think the issue then is more than to_json doesn't save arguments, which possibly it doesn't because it might be too explicit, but then it leads to this weird asymetry