Skip to content

Commit

Permalink
Merge branch 'rename-valid-till-date' into improve-build-script
Browse files Browse the repository at this point in the history
  • Loading branch information
zaneselvans committed Feb 23, 2024
2 parents 92e9b27 + bd6d912 commit 5ce6a2e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Rename valid_till_date to valid_until_date
Revision ID: c76866dcc23c
Revises: 98836fb06355
Create Date: 2024-02-22 14:52:07.204044
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'c76866dcc23c'
down_revision = '98836fb06355'
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('core_eia860m__changelog_generators', schema=None) as batch_op:
batch_op.add_column(sa.Column('valid_until_date', sa.Date(), nullable=True, comment='The record in the changelog is valid until this date. The record is valid from the report_date up until but not including the valid_until_date.'))
batch_op.drop_column('valid_till_date')

# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('core_eia860m__changelog_generators', schema=None) as batch_op:
batch_op.add_column(sa.Column('valid_till_date', sa.DATE(), nullable=True))
batch_op.drop_column('valid_until_date')

# ### end Alembic commands ###
4 changes: 2 additions & 2 deletions src/pudl/metadata/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3525,9 +3525,9 @@
"type": "string",
"description": "Freeform description of type of utility reported in one of the other three other utility_type sections in the core_ferc1__yearly_utility_plant_summary_sched200 table. This field is reported only in the DBF reporting years (1994-2020).",
},
"valid_till_date": {
"valid_until_date": {
"type": "date",
"description": "The record in the changelog is valid until this date. The record is valid from the report_date up until but not including the valid_till_date.",
"description": "The record in the changelog is valid until this date. The record is valid from the report_date up until but not including the valid_until_date.",
},
"variable_peak_pricing": {
"type": "boolean",
Expand Down
4 changes: 2 additions & 2 deletions src/pudl/metadata/resources/eia860m.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"nothing changes month-to-month. This table is a changelog of that monthly "
"reported generator data. There is a record cooresponding to the first instance "
"of a generator and associated characteristics with a report_date column and a "
"valid_till_date column. Whenever any of the reported EIA-860m data was changed "
"valid_until_date column. Whenever any of the reported EIA-860m data was changed "
"for a record, there will be a new changelog record with a new report_date."
),
"schema": {
"fields": [
"report_date",
"valid_till_date",
"valid_until_date",
"plant_id_eia",
"plant_name_eia",
"utility_id_eia",
Expand Down
6 changes: 3 additions & 3 deletions src/pudl/transform/eia860m.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def core_eia860m__changelog_generators(
for field in pudl.metadata.classes.Resource.from_id(
"core_eia860m__changelog_generators"
).schema.fields
if field.name != "valid_till_date"
if field.name != "valid_until_date"
]
]
# there is one plant/gen that has duplicate values
Expand Down Expand Up @@ -91,7 +91,7 @@ def core_eia860m__changelog_generators(
fill_through_freq="month",
)

# assign a max report_date column for use in the valid_till_date column
# assign a max report_date column for use in the valid_until_date column
eia860m_all["report_date_max"] = eia860m_all.groupby(gen_idx_no_date)[
"report_date"
].transform("max")
Expand All @@ -103,7 +103,7 @@ def core_eia860m__changelog_generators(
keep="first",
)

eia860m_changelog["valid_till_date"] = (
eia860m_changelog["valid_until_date"] = (
eia860m_changelog.sort_values(gens_idx, ascending=False)
.groupby(gen_idx_no_date)["report_date"]
.transform("shift")
Expand Down

0 comments on commit 5ce6a2e

Please sign in to comment.