Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New TimedBelief table and functionality to turn its entries into a BeliefsDataFrame and vice versa. * Fix docstring * Added TimedBelief table with i/o functionality * Move some functionality to timely-beliefs * Rename class methods * Source db class now derived from instance * Fix mixin usage by initializing superclasses in a specific order with specific args and kwargs * Set dependency dev version * Register TimedBelief as a data table for db-obs * Set minimum tb dependency to released version * Changelog entry Co-authored-by: F.N. Claessen <felix@seita.nl>
- Loading branch information
Showing
7 changed files
with
230 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
flexmeasures/data/migrations/versions/e62ac5f519d7_create_table_for_timed_beliefs.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
"""create table for timed beliefs | ||
Revision ID: e62ac5f519d7 | ||
Revises: a528c3c81506 | ||
Create Date: 2021-03-28 16:26:45.025994 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "e62ac5f519d7" | ||
down_revision = "a528c3c81506" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
"timed_belief", | ||
sa.Column( | ||
"event_start", sa.DateTime(timezone=True), nullable=False, index=True | ||
), | ||
sa.Column("belief_horizon", sa.Interval(), nullable=False), | ||
sa.Column("cumulative_probability", sa.Float(), nullable=False, default=0.5), | ||
sa.Column("event_value", sa.Float(), nullable=False), | ||
sa.Column("sensor_id", sa.Integer(), nullable=False, index=True), | ||
sa.Column("source_id", sa.Integer(), nullable=False), | ||
sa.ForeignKeyConstraint( | ||
["sensor_id"], | ||
["sensor.id"], | ||
name=op.f("timed_belief_sensor_id_sensor_fkey"), | ||
ondelete="CASCADE", | ||
), | ||
sa.ForeignKeyConstraint( | ||
["source_id"], | ||
["data_source.id"], | ||
name=op.f("timed_belief_source_id_source_fkey"), | ||
ondelete="CASCADE", | ||
), | ||
sa.PrimaryKeyConstraint( | ||
"event_start", | ||
"belief_horizon", | ||
"cumulative_probability", | ||
"sensor_id", | ||
name=op.f("timed_belief_pkey"), | ||
), | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table("timed_belief") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters