variableselector module¶
- class SelectedTimeUnit(timeunit, dt)¶
Bases:
objectA class for use inside callbacks where the period is parsed and with some utility methods for iterations
- Parameters:
timeunit (TimeUnit)
dt (DateTime)
- add(num_periods)¶
- Return type:
- Parameters:
num_periods (int)
- dt: DateTime¶
- subtract(num_periods)¶
- Return type:
- Parameters:
num_periods (int)
- to_str()¶
- Return type:
str
- class TimeUnit(**data)¶
Bases:
BaseModel- Parameters:
name (str)
frequency (TimeUnitType)
- frequency: TimeUnitType¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str¶
- static parse(timeunit, period)¶
Utility method for turning callback information into a SelectedTimeUnit for easier handling.
- Parameters:
timeunit (TimeUnit)
period (str)
- classmethod parse_frequency(value)¶
- Return type:
- Parameters:
value (str | TimeUnitType)
- class TimeUnitType(*values)¶
Bases:
Enum- DAY = 6¶
- HALF_YEAR = 2¶
- MONTH = 4¶
- QUARTER = 3¶
- WEEK = 5¶
- YEAR = 1¶
- to_fmt()¶
- Return type:
str
- class VariableSelector(selected_inputs, selected_states, default_values=None)¶
Bases:
objectClass containing options for shared states between modules in the framework.
Notes
Each module should have its own instance of the VariableSelector in its __init__ function.
- Parameters:
selected_inputs (list[str])
selected_states (list[str])
default_values (dict[str, str | int | float] | None)
- classmethod get_all_states()¶
- Return type:
list[State]
- classmethod get_grouping_vars(_type)¶
- Return type:
list[TypeVar(T,Input,State,Output)]- Parameters:
_type (type[Input | State | Output])
- classmethod get_ident(_type)¶
- Return type:
TypeVar(T,Input,State,Output)- Parameters:
_type (type[Input | State | Output])
- classmethod get_input(requested, search_target='title')¶
Retrieves a Input object for the selected variable.
- Return type:
list[Input]- Parameters:
requested (str | list[str])
search_target (str)
- classmethod get_option(search_term, search_target='title')¶
Retrieves a VariableSelectorOption by variable name.
- Parameters:
search_term (
str) – Word to search for, needs to be an exact match.search_target (
str) – Element of VariableSelectorOption to search.
- Return type:
- Returns:
VariableSelectorOption object matching description.
- Raises:
ValueError – If ‘search_target’ is not a searchable property.
Exception – If something goes wrong in a weird way.
- classmethod get_output_object(variable)¶
Creates a Dash Output object for a given variable.
Use this if you need to have a module output back to the shared VariableSelector in the main layout.
- Parameters:
variable (
str) – The variable name.- Returns:
The corresponding Dash Output object.
- Return type:
Output- Raises:
ValueError – If the name (title) does not exist in any of the options available to the VariableSelector
- classmethod get_refnr(_type)¶
- Return type:
TypeVar(T,Input,State,Output)- Parameters:
_type (type[Input | State | Output])
- classmethod get_secondary_ident(_type)¶
- Return type:
list[TypeVar(T,Input,State,Output)]- Parameters:
_type (type[Input | State | Output])
- classmethod get_state(requested, search_target='title')¶
Retrieves a State object for the selected variable.
- Return type:
list[State]- Parameters:
requested (str | list[str])
search_target (str)
- classmethod get_timevar(_type)¶
- Return type:
TypeVar(T,Input,State,Output)- Parameters:
_type (type[Input | State | Output])
- layout()¶
Generate a list of Dash Bootstrap cards based on selected variable keys.
- Return type:
list[Row]
- class VariableSelectorConfig(**data)¶
Bases:
BaseModelConfiguration for the variable selector.
- Parameters:
refnr (str | None)
ident (str | None)
secondary_idents (list[str] | None)
time_units (TimeUnit | None)
grouping_variables (list[str] | None)
- classmethod from_dict(config)¶
- Return type:
- classmethod from_yaml(yaml_path)¶
- Return type:
- Parameters:
yaml_path (str)
- grouping_variables: list[str] | None¶
- ident: str | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(_VariableSelectorConfig__context)¶
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- Return type:
None- Parameters:
_VariableSelectorConfig__context (Any)
- refnr: str | None¶
- secondary_idents: list[str] | None¶
- class VariableSelectorOption(variable_title, variable_id=None)¶
Bases:
objectRepresents an individual variable selection option.
- Parameters:
variable_title (str)
variable_id (str | None)