Skip to content

Commit

Permalink
Merge branch 'main' into slb/MigrationScriptChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
slb-halfspace authored Dec 18, 2024
2 parents 8e364ea + 147ff64 commit 00b472e
Show file tree
Hide file tree
Showing 28 changed files with 104 additions and 38 deletions.
5 changes: 3 additions & 2 deletions .devcontainer/docker-compose-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ services:
# Forwards the local Docker socket to the container.
- /var/run/docker.sock:/var/run/docker-host.sock
# Update this to wherever you want VS Code to mount the folder of your project
- ..:/workspaces/opengeh-wholesale:cached
- ..:${HOME}/work/opengeh-wholesale:cached
# Map to Azure CLI token cache location (on Windows)
- "${USERPROFILE}/.azure:/home/joyvan/.azure"
- "${USERPROFILE}/.azure:/home/jovyan/.azure"
working_dir: ${HOME}/work/opengeh-wholesale
environment:
# Pass the environment variables from your shell straight through to your containers.
# No warning is issued if the variable in the shell environment is not set.
Expand Down
5 changes: 3 additions & 2 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ services:
# Forwards the local Docker socket to the container.
- /var/run/docker.sock:/var/run/docker-host.sock
# Update this to wherever you want VS Code to mount the folder of your project
- ..:/workspaces/opengeh-wholesale:cached
- ..:${HOME}/work/opengeh-wholesale:cached
# Map to Azure CLI token cache location (on Linux)
- "${HOME}/.azure:/home/joyvan/.azure"
- "${HOME}/.azure:/home/jovyan/.azure"
working_dir: ${HOME}/work/opengeh-wholesale
environment:
# Pass the environment variables from your shell straight through to your containers.
# No warning is issued if the variable in the shell environment is not set.
Expand Down
9 changes: 6 additions & 3 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ ENV PATH=$SPARK_HOME/bin:$HADOOP_HOME/bin:$PATH \
# Dynamically downloading spark dependencies from conf/spark-defaults.conf. This is done to save time in the build pipeline so that we don't need to download on every build.
RUN spark-shell

# Make $HOME owned by the root, which is the user used in the container
# This is needed for e.g. commands that create files or folders in $HOME
RUN sudo chown -R root:users $HOME
# Change the username from jovyan to nayvoj and update the user id to 1001, as that is the user id used in the GitHub Actions runner
RUN usermod -l nayvoj jovyan && \
usermod -u 1001 nayvoj && \
usermod -l jovyan nayvoj

RUN usermod -u 1001 jovyan
4 changes: 2 additions & 2 deletions .docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -l
#!/bin/bash

# Copyright 2020 Energinet DataHub A/S
#
Expand All @@ -21,7 +21,7 @@ echo "Tests folder path: '$1'"
echo "Filter (paths): '$2'"

# Configure Azure CLI to use token cache which must be mapped as volume from host machine
export AZURE_CONFIG_DIR=/home/joyvan/.azure
export AZURE_CONFIG_DIR=/home/jovyan/.azure

# There env vars are important to ensure that the driver and worker nodes in spark are alligned
export PYSPARK_PYTHON=/opt/conda/bin/python
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/ci-databricks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ jobs:
shell: bash
id: test_count
run: |
# Small hack to get the repository name
repository=${{ github.repository }}
repository_owner=${{ github.repository_owner }}
repository_name=${repository/$repository_owner\//}
# IMPORTANT: When adding a new folder here, one must also add the folder
# to one of the test jobs above! This is because this filter contains the sum of all folders
# from test jobs.
Expand All @@ -255,7 +250,7 @@ jobs:
optimize_job/
datamigration/unity_catalog"
IMAGE_TAG=${{ inputs.image_tag }} docker compose -f .devcontainer/docker-compose.yml run --rm -u root -w //workspaces/${repository_name} python-unit-test ./.devcontainer/check_test_count.sh $filter
IMAGE_TAG=${{ inputs.image_tag }} docker compose -f .devcontainer/docker-compose.yml run --rm -u root python-unit-test ./.devcontainer/check_test_count.sh $filter
calculator_job_mypy_check:
if: ${{ inputs.has_calculator_job_changes }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# 've_production' | 'net_production' | 'supply_to_grid' |
# 'consumption_from_grid' | 'wholesale_services_information' |
# 'own_production' | 'net_from_grid' 'net_to_grid' | 'total_consumption' |
# 'electrical_heating' | 'net_consumption' | 'effect_settlement'
# 'electrical_heating' | 'net_consumption' | 'capacity_settlement'
t.StructField("metering_point_type", t.StringType(), not nullable),
#
# 'non_profiled' | 'flex'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# When wholesale calculations types also:
# 've_production' | 'net_production' | 'supply_to_grid' 'consumption_from_grid' |
# 'wholesale_services_information' | 'own_production' | 'net_from_grid' 'net_to_grid' |
# 'total_consumption' | 'electrical_heating' | 'net_consumption' | 'effect_settlement'
# 'total_consumption' | 'electrical_heating' | 'net_consumption' | 'capacity_settlement'
t.StructField("metering_point_type", t.StringType(), not nullable),
#
# 'PT15M' | 'PT1H'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# 'production' | 'consumption' | 've_production' | 'net_production' |
# 'supply_to_grid' | 'consumption_from_grid' | 'wholesale_services_information' |
# 'own_production' | 'net_from_grid' 'net_to_grid' | 'total_consumption' |
# 'electrical_heating' | 'net_consumption' | 'effect_settlement'
# 'electrical_heating' | 'net_consumption' | 'capacity_settlement'
t.StructField("metering_point_type", t.StringType(), not nullable),
#
# 'flex' | 'non_profiled'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# 'production' | 'consumption' | 've_production' | 'net_production' |
# 'supply_to_grid' | 'consumption_from_grid' | 'wholesale_services_information' |
# 'own_production' | 'net_from_grid' 'net_to_grid' | 'total_consumption' |
# 'electrical_heating' | 'net_consumption' | 'effect_settlement'
# 'electrical_heating' | 'net_consumption' | 'capacity_settlement'
t.StructField("metering_point_type", t.StringType(), not nullable),
#
# 'flex' | 'non_profiled'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# 'net_production' | 'supply_to_grid' 'consumption_from_grid' |
# 'wholesale_services_information' | 'own_production' | 'net_from_grid' |
# 'net_to_grid' | 'total_consumption' | 'electrical_heating' |
# 'net_consumption' | 'effect_settlement'
# 'net_consumption' | 'capacity_settlement'
t.StructField("metering_point_type", t.StringType(), not nullable),
#
# 'flex' | 'non_profiled'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# 'net_production' | 'supply_to_grid' 'consumption_from_grid' |
# 'wholesale_services_information' | 'own_production' | 'net_from_grid' |
# 'net_to_grid' | 'total_consumption' | 'electrical_heating' |
# 'net_consumption' | 'effect_settlement'
# 'net_consumption' | 'capacity_settlement'
t.StructField("metering_point_type", t.StringType(), not nullable),
#
# 'subscription' | 'fee' | 'tariff'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# 've_production' | 'net_production' | 'supply_to_grid' |
# 'consumption_from_grid' | 'wholesale_services_information' |
# 'own_production' | 'net_from_grid' 'net_to_grid' | 'total_consumption' |
# 'electrical_heating' | 'net_consumption' | 'effect_settlement'
# 'electrical_heating' | 'net_consumption' | 'capacity_settlement'
t.StructField("metering_point_type", t.StringType(), not nullable),
#
# 'non_profiled' | 'flex'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# When wholesale calculations types also:
# 've_production' | 'net_production' | 'supply_to_grid' 'consumption_from_grid' |
# 'wholesale_services_information' | 'own_production' | 'net_from_grid' 'net_to_grid' |
# 'total_consumption' | 'electrical_heating' | 'net_consumption' | 'effect_settlement'
# 'total_consumption' | 'electrical_heating' | 'net_consumption' | 'capacity_settlement'
t.StructField("metering_point_type", t.StringType(), not nullable),
#
# 'PT15M' | 'PT1H'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ def _fix_metering_point_type(df: DataFrame) -> DataFrame:
)
.when(
col(Colname.metering_point_type)
== InputMeteringPointType.EFFECT_SETTLEMENT.value,
lit(MeteringPointType.EFFECT_SETTLEMENT.value),
== InputMeteringPointType.CAPACITY_SETTLEMENT.value,
lit(MeteringPointType.CAPACITY_SETTLEMENT.value),
)
.otherwise(lit("Unknown type")),
# The otherwise is to avoid changing the nullability of the column.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ class InputMeteringPointType(Enum):
TOTAL_CONSUMPTION = "D12"
ELECTRICAL_HEATING = "D14"
NET_CONSUMPTION = "D15"
EFFECT_SETTLEMENT = "D19"
CAPACITY_SETTLEMENT = "D19"
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ class MeteringPointType(Enum):
TOTAL_CONSUMPTION = "total_consumption"
ELECTRICAL_HEATING = "electrical_heating"
NET_CONSUMPTION = "net_consumption"
EFFECT_SETTLEMENT = "effect_settlement"
CAPACITY_SETTLEMENT = "capacity_settlement"
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ALTER TABLE {CATALOG_NAME}.{WHOLESALE_BASIS_DATA_INTERNAL_DATABASE_NAME}.time_series_points
DROP CONSTRAINT IF EXISTS metering_point_type_chk
GO

ALTER TABLE {CATALOG_NAME}.{WHOLESALE_BASIS_DATA_INTERNAL_DATABASE_NAME}.time_series_points
ADD CONSTRAINT metering_point_type_chk
CHECK (metering_point_type IN ( 'production' , 'consumption' , 'exchange' , 've_production' , 'net_production' , 'supply_to_grid' , 'consumption_from_grid' , 'wholesale_services_information' , 'own_production' , 'net_from_grid' , 'net_to_grid' , 'total_consumption' , 'electrical_heating' , 'net_consumption' , 'effect_settlement', 'capacity_settlement' ))
GO

ALTER TABLE {CATALOG_NAME}.{WHOLESALE_RESULTS_INTERNAL_DATABASE_NAME}.amounts_per_charge
DROP CONSTRAINT IF EXISTS metering_point_type_chk
GO

ALTER TABLE {CATALOG_NAME}.{WHOLESALE_RESULTS_INTERNAL_DATABASE_NAME}.amounts_per_charge
ADD CONSTRAINT metering_point_type_chk
CHECK (metering_point_type IN ( 'production' , 'consumption' , 'exchange' , 've_production' , 'net_production' , 'supply_to_grid' , 'consumption_from_grid' , 'wholesale_services_information' , 'own_production' , 'net_from_grid' , 'net_to_grid' , 'total_consumption' , 'electrical_heating' , 'net_consumption' , 'effect_settlement', 'capacity_settlement' ))
GO

ALTER TABLE {CATALOG_NAME}.{WHOLESALE_BASIS_DATA_INTERNAL_DATABASE_NAME}.metering_point_periods
DROP CONSTRAINT IF EXISTS metering_point_type_chk
GO

ALTER TABLE {CATALOG_NAME}.{WHOLESALE_BASIS_DATA_INTERNAL_DATABASE_NAME}.metering_point_periods
ADD CONSTRAINT metering_point_type_chk
CHECK (metering_point_type IN ( 'production' , 'consumption' , 'exchange' , 've_production' , 'net_production' , 'supply_to_grid' , 'consumption_from_grid' , 'wholesale_services_information' , 'own_production' , 'net_from_grid' , 'net_to_grid' , 'total_consumption' , 'electrical_heating' , 'net_consumption' , 'effect_settlement', 'capacity_settlement' ))
GO
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
UPDATE {CATALOG_NAME}.{WHOLESALE_BASIS_DATA_INTERNAL_DATABASE_NAME}.time_series_points
SET metering_point_type = 'capacity_settlement'
WHERE metering_point_type = 'effect_settlement';
GO

UPDATE {CATALOG_NAME}.{WHOLESALE_RESULTS_INTERNAL_DATABASE_NAME}.amounts_per_charge
SET metering_point_type = 'capacity_settlement'
WHERE metering_point_type = 'effect_settlement';
GO

UPDATE {CATALOG_NAME}.{WHOLESALE_BASIS_DATA_INTERNAL_DATABASE_NAME}.metering_point_periods
SET metering_point_type = 'capacity_settlement'
WHERE metering_point_type = 'effect_settlement';
GO
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ALTER TABLE {CATALOG_NAME}.{WHOLESALE_BASIS_DATA_INTERNAL_DATABASE_NAME}.time_series_points
DROP CONSTRAINT IF EXISTS metering_point_type_chk
GO

ALTER TABLE {CATALOG_NAME}.{WHOLESALE_BASIS_DATA_INTERNAL_DATABASE_NAME}.time_series_points
ADD CONSTRAINT metering_point_type_chk
CHECK (metering_point_type IN ( 'production' , 'consumption' , 'exchange' , 've_production' , 'net_production' , 'supply_to_grid' , 'consumption_from_grid' , 'wholesale_services_information' , 'own_production' , 'net_from_grid' , 'net_to_grid' , 'total_consumption' , 'electrical_heating' , 'net_consumption' , 'capacity_settlement' ))
GO

ALTER TABLE {CATALOG_NAME}.{WHOLESALE_RESULTS_INTERNAL_DATABASE_NAME}.amounts_per_charge
DROP CONSTRAINT IF EXISTS metering_point_type_chk
GO

ALTER TABLE {CATALOG_NAME}.{WHOLESALE_RESULTS_INTERNAL_DATABASE_NAME}.amounts_per_charge
ADD CONSTRAINT metering_point_type_chk
CHECK (metering_point_type IN ( 'production' , 'consumption' , 'exchange' , 've_production' , 'net_production' , 'supply_to_grid' , 'consumption_from_grid' , 'wholesale_services_information' , 'own_production' , 'net_from_grid' , 'net_to_grid' , 'total_consumption' , 'electrical_heating' , 'net_consumption' , 'capacity_settlement' ))
GO

ALTER TABLE {CATALOG_NAME}.{WHOLESALE_BASIS_DATA_INTERNAL_DATABASE_NAME}.metering_point_periods
DROP CONSTRAINT IF EXISTS metering_point_type_chk
GO

ALTER TABLE {CATALOG_NAME}.{WHOLESALE_BASIS_DATA_INTERNAL_DATABASE_NAME}.metering_point_periods
ADD CONSTRAINT metering_point_type_chk
CHECK (metering_point_type IN ( 'production' , 'consumption' , 'exchange' , 've_production' , 'net_production' , 'supply_to_grid' , 'consumption_from_grid' , 'wholesale_services_information' , 'own_production' , 'net_from_grid' , 'net_to_grid' , 'total_consumption' , 'electrical_heating' , 'net_consumption' , 'capacity_settlement' ))
GO
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class TestWhenValidInput:
],
[InputMeteringPointType.NET_CONSUMPTION, MeteringPointType.NET_CONSUMPTION],
[
InputMeteringPointType.EFFECT_SETTLEMENT,
MeteringPointType.EFFECT_SETTLEMENT,
InputMeteringPointType.CAPACITY_SETTLEMENT,
MeteringPointType.CAPACITY_SETTLEMENT,
],
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
MeteringPointTypeDataProductValue.TOTAL_CONSUMPTION.value: "D12",
MeteringPointTypeDataProductValue.ELECTRICAL_HEATING.value: "D14",
MeteringPointTypeDataProductValue.NET_CONSUMPTION.value: "D15",
MeteringPointTypeDataProductValue.EFFECT_SETTLEMENT.value: "D19",
MeteringPointTypeDataProductValue.CAPACITY_SETTLEMENT.value: "D19",
MeteringPointTypeDataProductValue.CONSUMPTION.value: "E17",
MeteringPointTypeDataProductValue.PRODUCTION.value: "E18",
MeteringPointTypeDataProductValue.EXCHANGE.value: "E20",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ class MeteringPointTypeDataProductValue(Enum):
TOTAL_CONSUMPTION = "total_consumption"
ELECTRICAL_HEATING = "electrical_heating"
NET_CONSUMPTION = "net_consumption"
EFFECT_SETTLEMENT = "effect_settlement"
CAPACITY_SETTLEMENT = "capacity_settlement"
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# 've_production' | 'net_production' | 'supply_to_grid' |
# 'consumption_from_grid' | 'wholesale_services_information' |
# 'own_production' | 'net_from_grid' 'net_to_grid' | 'total_consumption' |
# 'electrical_heating' | 'net_consumption' | 'effect_settlement'
# 'electrical_heating' | 'net_consumption' | 'capacity_settlement'
t.StructField("metering_point_type", t.StringType(), not nullable),
#
# 'non_profiled' | 'flex'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# When wholesale calculations types also:
# 've_production' | 'net_production' | 'supply_to_grid' 'consumption_from_grid' |
# 'wholesale_services_information' | 'own_production' | 'net_from_grid' 'net_to_grid' |
# 'total_consumption' | 'electrical_heating' | 'net_consumption' | 'effect_settlement'
# 'total_consumption' | 'electrical_heating' | 'net_consumption' | 'capacity_settlement'
t.StructField("metering_point_type", t.StringType(), not nullable),
#
# 'PT15M' | 'PT1H'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ def test_mapping_of_energy_business_process(
id="when metering point type is net_consumption, then type of mp is D15",
),
pytest.param(
MeteringPointTypeDataProductValue.EFFECT_SETTLEMENT,
MeteringPointTypeDataProductValue.CAPACITY_SETTLEMENT,
"D19",
id="when metering point type is effect_settlement, then type of mp is D19",
id="when metering point type is capacity_settlement, then type of mp is D19",
),
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ public enum MeteringPointType
TotalConsumption = 11,
ElectricalHeating = 12,
NetConsumption = 13,
EffectSettlement = 14,
CapacitySettlement = 14,
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void Map_WhenValidMeteringPointType_ReturnsExpectedString()
(MeteringPointType.TotalConsumption, WholesaleServicesRequestSeries.Types.MeteringPointType.TotalConsumption),
(MeteringPointType.ElectricalHeating, WholesaleServicesRequestSeries.Types.MeteringPointType.ElectricalHeating),
(MeteringPointType.NetConsumption, WholesaleServicesRequestSeries.Types.MeteringPointType.NetConsumption),
(MeteringPointType.EffectSettlement, WholesaleServicesRequestSeries.Types.MeteringPointType.EffectSettlement),
(MeteringPointType.CapacitySettlement, WholesaleServicesRequestSeries.Types.MeteringPointType.EffectSettlement),
};

// Act
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static WholesaleServicesRequestSeries.Types.MeteringPointType Map(Meterin
MeteringPointType.TotalConsumption => WholesaleServicesRequestSeries.Types.MeteringPointType.TotalConsumption,
MeteringPointType.ElectricalHeating => WholesaleServicesRequestSeries.Types.MeteringPointType.ElectricalHeating,
MeteringPointType.NetConsumption => WholesaleServicesRequestSeries.Types.MeteringPointType.NetConsumption,
MeteringPointType.EffectSettlement => WholesaleServicesRequestSeries.Types.MeteringPointType.EffectSettlement,
MeteringPointType.CapacitySettlement => WholesaleServicesRequestSeries.Types.MeteringPointType.EffectSettlement,
_ => throw new ArgumentOutOfRangeException(
nameof(seriesMeteringPointType),
actualValue: seriesMeteringPointType,
Expand Down

0 comments on commit 00b472e

Please sign in to comment.