Skip to content

Commit

Permalink
Add deleted_market_actors to data model #574
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianK13 committed Oct 9, 2024
1 parent 9b3c4ba commit 550ba37
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion open_mastr/mastr.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class Mastr:
"""

def __init__(self, engine="sqlite", connect_to_translated_db=False) -> None:

validate_parameter_format_for_mastr_init(engine)

self.output_dir = get_output_dir()
Expand Down Expand Up @@ -150,6 +149,7 @@ def download(
| "balancing_area" | Yes | No |
| "permit" | Yes | Yes |
| "deleted_units" | Yes | No |
| "deleted_market_actors"| Yes | No |
| "retrofit_units" | Yes | No |
date : None or `datetime.datetime` or str, optional
Expand Down
10 changes: 6 additions & 4 deletions open_mastr/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"balancing_area",
"permit",
"deleted_units",
"deleted_market_actors",
"retrofit_units",
"changed_dso_assignment",
"storage_units",
Expand Down Expand Up @@ -63,6 +64,7 @@
"market_roles",
"permit",
"deleted_units",
"deleted_market_actors",
"retrofit_units",
"changed_dso_assignment",
"storage_units",
Expand Down Expand Up @@ -106,6 +108,7 @@
"balancing_area": ["bilanzierungsgebiete"],
"permit": ["einheitengenehmigung"],
"deleted_units": ["geloeschteunddeaktivierteeinheiten"],
"deleted_market_actors": ["geloeschteunddeaktiviertemarktakteure"],
"retrofit_units": ["ertuechtigungen"],
"changed_dso_assignment": ["einheitenaenderungnetzbetreiberzuordnungen"],
}
Expand All @@ -125,6 +128,7 @@
"balancing_area": ["balancing_area"],
"permit": ["permit"],
"deleted_units": ["deleted_units"],
"deleted_market_actors": ["deleted_market_actors"],
"retrofit_units": ["retrofit_units"],
"changed_dso_assignment": ["changed_dso_assignment"],
}
Expand Down Expand Up @@ -163,10 +167,7 @@
"eeg_data": "HydroEeg",
"permit_data": "Permit",
},
"nuclear": {
"unit_data": "NuclearExtended",
"permit_data": "Permit"
},
"nuclear": {"unit_data": "NuclearExtended", "permit_data": "Permit"},
"storage": {
"unit_data": "StorageExtended",
"eeg_data": "StorageEeg",
Expand All @@ -185,6 +186,7 @@
"balancing_area": "BalancingArea",
"permit": "Permit",
"deleted_units": "DeletedUnits",
"deleted_market_actors": "DeletedMarketActors",
"retrofit_units": "RetrofitUnits",
"changed_dso_assignment": "ChangedDSOAssignment",
"storage_units": "StorageUnits",
Expand Down
13 changes: 13 additions & 0 deletions open_mastr/utils/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,14 @@ class DeletedUnits(ParentAllTables, Base):
EinheitBetriebsstatus = Column(String)


class DeletedMarketActors(ParentAllTables, Base):
__tablename__ = "deleted_market_actors"

DatumLetzteAktualisierung = Column(DateTime(timezone=True))
MastrNummer = Column(String, primary_key=True)
MarktakteurStatus = Column(String)


class RetrofitUnits(ParentAllTables, Base):
__tablename__ = "retrofit_units"

Expand Down Expand Up @@ -1006,6 +1014,11 @@ class ChangedDSOAssignment(ParentAllTables, Base):
"__class__": DeletedUnits,
"replace_column_names": None,
},
"geloeschteunddeaktiviertemarktakteure": {
"__name__": DeletedMarketActors.__tablename__,
"__class__": DeletedMarketActors,
"replace_column_names": None,
},
"marktrollen": {
"__name__": MarketRoles.__tablename__,
"__class__": MarketRoles,
Expand Down
2 changes: 2 additions & 0 deletions open_mastr/xml_download/colums_to_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"Pumpspeichertechnologie",
"Einsatzort",
# geloeschteunddeaktivierteEinheiten
# geloeschteunddeaktivierteMarktAkteure
"MarktakteurStatus",
# lokationen
# marktakteure
"Personenart",
Expand Down
9 changes: 7 additions & 2 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def parameter_dict_working_list():
"balancing_area",
"permit",
"deleted_units",
"deleted_market_actors",
"retrofit_units",
None,
["wind", "solar"],
Expand Down Expand Up @@ -250,7 +251,12 @@ def test_validate_parameter_format_for_mastr_init(db):


def test_transform_data_parameter():
(data, api_data_types, api_location_types, harm_log,) = transform_data_parameter(
(
data,
api_data_types,
api_location_types,
harm_log,
) = transform_data_parameter(
method="API",
data=["wind", "location"],
api_data_types=["eeg_data"],
Expand Down Expand Up @@ -369,7 +375,6 @@ def test_db_query_to_csv(tmpdir, engine):
os.remove(csv_path)

for addit_table in addit_tables:

csv_path = join(
get_data_version_dir(),
f"bnetza_mastr_{addit_table}_raw.csv",
Expand Down

0 comments on commit 550ba37

Please sign in to comment.