pudl.settings#

Module for validating pudl etl settings.

Module Contents#

Classes#

BaseModel

BaseModel with global configuration.

GenericDatasetSettings

An abstract pydantic model for generic datasets.

Ferc1Settings

An immutable pydantic model to validate Ferc1Settings.

Ferc714Settings

An immutable pydantic model to validate Ferc714Settings.

EpaCemsSettings

An immutable pydantic model to validate EPA CEMS settings.

Eia923Settings

An immutable pydantic model to validate EIA 923 settings.

Eia861Settings

An immutable pydantic model to validate EIA 861 settings.

Eia860Settings

An immutable pydantic model to validate EIA 860 settings.

GlueSettings

An immutable pydantic model to validate Glue settings.

EiaSettings

An immutable pydantic model to validate EIA datasets settings.

DatasetsSettings

An immutable pydantic model to validate PUDL Dataset settings.

Ferc1ToSqliteSettings

An immutable pydantic nodel to validate Ferc1 to SQLite settings.

EtlSettings

Main settings validation class.

class pudl.settings.BaseModel[source]#

Bases: pydantic.BaseModel

BaseModel with global configuration.

class Config[source]#

Pydantic config.

allow_mutation = False[source]#
extra = forbid[source]#
class pudl.settings.GenericDatasetSettings[source]#

Bases: BaseModel

An abstract pydantic model for generic datasets.

Each dataset must specify working tables and partitions. A dataset can have an arbitrary number of partitions.

tables :list[str][source]#
validate_partitions(partitions)[source]#

Validate the requested data partitions.

Check that all the partitions defined in the working_partitions of the associated data_source (e.g. years or states) have been assigned in the definition of the class, and that the requested values are a subset of the allowable values defined by the data_source.

validate_tables(tables)[source]#

Validate tables are available.

class pudl.settings.Ferc1Settings[source]#

Bases: GenericDatasetSettings

An immutable pydantic model to validate Ferc1Settings.

Parameters:
  • data_source – DataSource metadata object

  • years – List of years to validate.

  • tables – List of tables to validate.

data_source :ClassVar[pudl.metadata.classes.DataSource][source]#
years :list[int][source]#
tables :list[str][source]#
class pudl.settings.Ferc714Settings[source]#

Bases: GenericDatasetSettings

An immutable pydantic model to validate Ferc714Settings.

Parameters:
  • data_source – DataSource metadata object

  • tables – List of tables to validate.

data_source :ClassVar[pudl.metadata.classes.DataSource][source]#
tables :list[str][source]#
class pudl.settings.EpaCemsSettings[source]#

Bases: GenericDatasetSettings

An immutable pydantic model to validate EPA CEMS settings.

Parameters:
  • data_source – DataSource metadata object

  • years – List of years to validate.

  • states – List of states to validate.

  • tables – List of tables to validate.

  • partition – Whether to output year-state partitioned Parquet files. If True, all available threads / CPUs will be used in parallel.

data_source :ClassVar[pudl.metadata.classes.DataSource][source]#
years :list[int][source]#
states :list[str][source]#
tables :list[str][source]#
partition :bool = False[source]#
allow_all_keyword(states)[source]#

Allow users to specify [‘all’] to get all states.

class pudl.settings.Eia923Settings[source]#

Bases: GenericDatasetSettings

An immutable pydantic model to validate EIA 923 settings.

Parameters:
  • data_source – DataSource metadata object

  • years – List of years to validate.

  • tables – List of tables to validate.

data_source :ClassVar[pudl.metadata.classes.DataSource][source]#
years :list[int][source]#
tables :list[str][source]#
class pudl.settings.Eia861Settings[source]#

Bases: GenericDatasetSettings

An immutable pydantic model to validate EIA 861 settings.

Parameters:
  • data_source – DataSource metadata object

  • years – List of years to validate.

  • tables – List of tables to validate.

  • transform_functions – List of transform functions to be applied to eia861

data_source :ClassVar[pudl.metadata.classes.DataSource][source]#
years :list[int][source]#
tables :list[str][source]#
transform_functions :list[str][source]#
generate_transform_functions(values)[source]#

Map tables to transform functions.

Parameters:

values – eia861 settings.

Returns:

eia861 settings.

Return type:

values

class pudl.settings.Eia860Settings[source]#

Bases: GenericDatasetSettings

An immutable pydantic model to validate EIA 860 settings.

This model also check 860m settings.

Parameters:
  • data_source – DataSource metadata object

  • years – List of years to validate.

  • tables – List of tables to validate.

  • ClassVar[str] (eia860m_date) – The 860m year to date.

data_source :ClassVar[pudl.metadata.classes.DataSource][source]#
eia860m_data_source :ClassVar[pudl.metadata.classes.DataSource][source]#
eia860m_date :ClassVar[str][source]#
years :list[int][source]#
tables :list[str][source]#
eia860m :bool = True[source]#
check_eia860m_date(eia860m: bool) bool[source]#

Check 860m date year is exactly one year later than most recent working 860 year.

Parameters:

eia860m – True if 860m is requested.

Returns:

True if 860m is requested.

Return type:

eia860m

Raises:

ValueError – the 860m date is within 860 working years.

class pudl.settings.GlueSettings[source]#

Bases: BaseModel

An immutable pydantic model to validate Glue settings.

Parameters:
  • eia – Include eia in glue settings.

  • ferc1 – Include ferc1 in glue settings.

eia :bool = True[source]#
ferc1 :bool = True[source]#
class pudl.settings.EiaSettings[source]#

Bases: BaseModel

An immutable pydantic model to validate EIA datasets settings.

Parameters:
  • eia860 – Immutable pydantic model to validate eia860 settings.

  • eia923 – Immutable pydantic model to validate eia923 settings.

eia860 :Eia860Settings[source]#
eia923 :Eia923Settings[source]#
default_load_all(values)[source]#

If no datasets are specified default to all.

Parameters:

values (Dict[str, BaseModel]) – dataset settings.

Returns:

dataset settings.

Return type:

values (Dict[str, BaseModel])

check_eia_dependencies(values)[source]#

Make sure the dependencies between the eia datasets are satisfied.

Dependencies: * eia860 requires eia923.boiler_fuel_eia923 and eia923.generation_eia923. * eia923 requires eia860 for harvesting purposes.

Parameters:

values (Dict[str, BaseModel]) – dataset settings.

Returns:

dataset settings.

Return type:

values (Dict[str, BaseModel])

class pudl.settings.DatasetsSettings[source]#

Bases: BaseModel

An immutable pydantic model to validate PUDL Dataset settings.

Parameters:
  • ferc1 – Immutable pydantic model to validate ferc1 settings.

  • eia – Immutable pydantic model to validate eia(860, 923) settings.

  • glue – Immutable pydantic model to validate glue settings.

  • epacems – Immutable pydantic model to validate epacems settings.

ferc1 :Ferc1Settings[source]#
eia :EiaSettings[source]#
glue :GlueSettings[source]#
epacems :EpaCemsSettings[source]#
default_load_all(values)[source]#

If no datasets are specified default to all.

Parameters:

values (Dict[str, BaseModel]) – dataset settings.

Returns:

dataset settings.

Return type:

values (Dict[str, BaseModel])

add_glue_settings(values)[source]#

Add glue settings if ferc1 and eia data are both requested.

Parameters:

values (Dict[str, BaseModel]) – dataset settings.

Returns:

dataset settings.

Return type:

values (Dict[str, BaseModel])

get_datasets()[source]#

Gets dictionary of dataset settings.

class pudl.settings.Ferc1ToSqliteSettings[source]#

Bases: GenericDatasetSettings

An immutable pydantic nodel to validate Ferc1 to SQLite settings.

Parameters:
  • tables – List of tables to validate.

  • years – List of years to validate.

data_source :ClassVar[pudl.metadata.classes.DataSource][source]#
years :list[int][source]#
tables :list[str][source]#
refyear :ClassVar[int][source]#
bad_cols :tuple = [][source]#
validate_tables(tables)[source]#

Validate tables.

class pudl.settings.EtlSettings[source]#

Bases: pydantic.BaseSettings

Main settings validation class.

ferc1_to_sqlite_settings :Ferc1ToSqliteSettings[source]#
datasets :DatasetsSettings[source]#
name :str[source]#
title :str[source]#
description :str[source]#
version :str[source]#
pudl_in :str[source]#
pudl_out :str[source]#
classmethod from_yaml(path: str) EtlSettings[source]#

Create an EtlSettings instance from a yaml_file path.

Parameters:

path – path to a yaml file.

Returns:

An ETL settings object.