I think the code would be more readable and robust if we used enums instead of custom dictionaries where possible.
One use case that I think would be ready to switch is the ML model type. For example, this
class ModelType(Enum):
neural_network_single = "Neural Network (single)"
neural_network_ensemble = "Neural Network (ensemble)"
gaussian_process = "Gaussian Process"
would allow to stop relying on string checks like if model_type == "NN", where the correspondence between "NN" and "Neural Network (single)" is defined in a custom dictionary, currently
|
model_type_tag_dict = { |
|
"Gaussian Process": "GP", |
|
"Neural Network (single)": "NN", |
|
"Neural Network (ensemble)": "ensemble_NN", |
|
} |
and replace them with if model_type == ModelType.neural_network, while still leaving access to a user-friendly string representation to be exposed in the UI (e.g., "Neural Network (single)").
Something similar probably can be done for other variables related to selectors and other UI components.
I think the code would be more readable and robust if we used enums instead of custom dictionaries where possible.
One use case that I think would be ready to switch is the ML model type. For example, this
would allow to stop relying on string checks like
if model_type == "NN", where the correspondence between"NN"and"Neural Network (single)"is defined in a custom dictionary, currentlysynapse/dashboard/model_manager.py
Lines 19 to 23 in 6d135b2
and replace them with
if model_type == ModelType.neural_network, while still leaving access to a user-friendly string representation to be exposed in the UI (e.g.,"Neural Network (single)").Something similar probably can be done for other variables related to selectors and other UI components.