sleap.gui.learning.scopedkeydict¶
Conversion between flat (form data) and hierarchical (config object) dicts.
-
class
sleap.gui.learning.scopedkeydict.
ScopedKeyDict
(key_val_dict: Dict[str, Any])[source]¶ Class to support conversion between flat and hierarchical dictionaries.
Flat dictionaries have scoped keys, e.g., “foo.bar”. These typically come from user-editable forms.
Hierarchical dictionaries have dictionaries as values of other dictionaries, e.g., {“foo”: {“bar”: … } }. These are typically used when serializing and deserializing objects.
-
key_val_dict
¶ Data stores in a flat dictionary with scoped keys.
-
classmethod
from_hierarchical_dict
(hierarch_dict: dict)[source]¶ Constructs object (with flat dict) from hierarchical dictionary.
-
-
sleap.gui.learning.scopedkeydict.
apply_cfg_transforms_to_key_val_dict
(key_val_dict: dict)[source]¶ Transforms data from form to correct data types before converting to object.
- Parameters
key_val_dict – Flat dictionary from
TrainingEditorWidget
.- Returns
None, modifies dict in place.
-
sleap.gui.learning.scopedkeydict.
find_backbone_name_from_key_val_dict
(key_val_dict: dict)[source]¶ Find the backbone model name from the config dictionary.
-
sleap.gui.learning.scopedkeydict.
make_model_config_from_key_val_dict
(key_val_dict: dict) → sleap.nn.config.model.ModelConfig[source]¶ Make
ModelConfig
object from flat dictionary.- Parameters
key_val_dict – Flat dictionary from
TrainingEditorWidget
.- Returns
The
ModelConfig
object.
-
sleap.gui.learning.scopedkeydict.
make_training_config_from_key_val_dict
(key_val_dict: dict) → sleap.nn.config.training_job.TrainingJobConfig[source]¶ Make
TrainingJobConfig
object from flat dictionary.- Parameters
key_val_dict – Flat dictionary from
TrainingEditorWidget
.- Returns
The
TrainingJobConfig
object.