4.2.1. thuner.option.attribute

Classes for object attribute options.

pydantic model thuner.option.attribute.Attribute[source]

Bases: BaseOptions

Base attribute description class. An “attribute” will become a column of a pandas dataframe, csv file, sql table, etc.

Fields:
Validators:
field data_type: type | str [Required]

Data type of the attribute.

field description: str | None = None

Description of the attribute.

field name: str [Required]

Name of the attribute.

field precision: int | None = None

Number of decimal places for a numerical attribute.

field retrieval: Retrieval | None = None

The function/kwargs used to retrieve the attribute.

field type: Literal['Attribute'] = 'Attribute'
field units: str | None = None

Units of the attribute.

validator check_data_type  »  all fields[source]

Check that the data type is valid.

pydantic model thuner.option.attribute.AttributeGroup[source]

Bases: BaseOptions

A group of related attributes retrieved by the same method, e.g. lat/lon or u/v.

Fields:
Validators:
field attributes: list[Attribute] [Required]

Attributes in the group.

field description: str | None = None

Description of the attribute group.

field name: str [Required]

Name of the attribute group.

field retrieval: Retrieval | None = None

The function/kwargs used to retrieve the attributes in the group.

field type: Literal['AttributeGroup'] = 'AttributeGroup'
validator check_retrieval  »  all fields[source]

Check that the retrieval method is the same for all attributes in the group. Also check that the shared retrieval method is the same as the group retrieval method if one has been provided.

pydantic model thuner.option.attribute.AttributeType[source]

Bases: BaseOptions

Attribute type options. Each “attribute type” contains attributes and attribute groups, and will form a single pandas dataframe, csv file, sql table, etc.

Fields:
Validators:
field attributes: list[Attribute | AttributeGroup] [Required]

Attributes and attribute groups comprising the attribute type.

field dataset: str | None = None

Dataset for tag attribute types (None if not applicable).

field description: str | None = None

Description of the attribute type.

field name: str [Required]

Name of the attribute type.

field type: Literal['AttributeType'] = 'AttributeType'
attribute_by_name(name: str) Attribute | AttributeGroup[source]

Get an attribute by name.

validator initialize_lookup  »  all fields[source]

Initialize the lookup dictionary for attributes. This is used to quickly access attributes by name.

pydantic model thuner.option.attribute.Attributes[source]

Bases: BaseOptions

Class for storing all the attribute options for a given object.

Fields:
Validators:
field attribute_types: list[AttributeType] [Required]

Attribute types of the object.

field member_attributes: dict[str, Attributes] | None = None

List of object attributes for the member objects.

field name: str [Required]

Name of the object.

field type: Literal['Attributes'] = 'Attributes'
attribute_type_by_name(name: str) AttributeType[source]

Get an attribute type by name.

validator initialize_lookup  »  all fields[source]

Initialize the lookup dictionary for attribute types. This is used to quickly access attribute types by name.

pydantic model thuner.option.attribute.Retrieval[source]

Bases: BaseOptions

Class for retrieval. Generally a function and a dictionary of kwargs.

Fields:
  • function (Callable | str | None)

  • keyword_arguments (dict)

  • type (Literal['Retrieval'])

Validators:
  • check_function » all fields

field function: Callable | str | None = None

The function used to retrieve the attribute.

field keyword_arguments: dict = {}

Keyword arguments for the retrieval function.

field type: Literal['Retrieval'] = 'Retrieval'
validator check_function  »  all fields[source]

Ensure that the function is callable, and available to thuner.