Adds a base Parameter class with subclasses for StringParameter, FileParameter, etc. These take default values, labels, and docstrings to characterize the parameter's role in the processing node.
Every concrete node must define OPTIONS, a dictionary with Parameter values
The descriptor classes Options and OptionTypes provide access to those options from both the Node class and instances.
Accessing .option_types from either the class or instance returns a dictionary representation of the defaults for use in the front end
Accessing .options from the instance returns copies of the default parameters, with values taken from the instance's option_values attribute. This attribute is what .options used to be. Accessing them through the Options descriptor allows us to use the power of the Paramter classes (e.g. validation)
Fixes some file access logic in pyworkflow (retrieve_node_data is no longer static, because it needs access to the workflow's root_dir to look up filenames)
This might seem a little overly complex at first glance, and I've been staring at it for so long that I'm no longer sure it's not. But it feels like all of the boilerplate I was able to remove from node.py means it's worthwhile. Concrete classes no longer need to implement their own __init__ to bubble things upward. Using descriptor-style access means the parameters must only be defined once (as Node.OPTIONS), and can be accessed flexibly depending on what the caller needs to know. Also means all the parameter metadata (type, docstring) no longer needs to be serialized in the networkx graph.
Parameter
class with subclasses forStringParameter
,FileParameter
, etc. These take default values, labels, and docstrings to characterize the parameter's role in the processing node.OPTIONS
, a dictionary withParameter
valuesOptions
andOptionTypes
provide access to those options from both the Node class and instances..option_types
from either the class or instance returns a dictionary representation of the defaults for use in the front end.options
from the instance returns copies of the default parameters, with values taken from the instance'soption_values
attribute. This attribute is what.options
used to be. Accessing them through theOptions
descriptor allows us to use the power of the Paramter classes (e.g. validation)retrieve_node_data
is no longer static, because it needs access to the workflow's root_dir to look up filenames)This might seem a little overly complex at first glance, and I've been staring at it for so long that I'm no longer sure it's not. But it feels like all of the boilerplate I was able to remove from
node.py
means it's worthwhile. Concrete classes no longer need to implement their own__init__
to bubble things upward. Using descriptor-style access means the parameters must only be defined once (asNode.OPTIONS
), and can be accessed flexibly depending on what the caller needs to know. Also means all the parameter metadata (type, docstring) no longer needs to be serialized in the networkx graph.