Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
3f7b2d5
added uv project dependency manager
m-karo Jun 4, 2025
3c35ffd
bugfix: OPDM api fix to comply with release 11 due to changed structu…
m-karo Jun 5, 2025
f3aaeff
Merge branch 'dev' of https://github.com/Baltic-RCC/EMF into dev
m-karo Jun 5, 2025
583e8b2
#312 Quality module initial implementation
gpoderys Jun 5, 2025
a804078
Merge pull request #334 from Baltic-RCC/gp-qa-module
gpoderys Jun 5, 2025
5b40385
ci: manual trigger posibility
m-karo Jun 5, 2025
c662003
Merge branch 'dev' of https://github.com/Baltic-RCC/EMF into dev
m-karo Jun 5, 2025
5f5ff28
Merged model OPDM object send to ELK
gpoderys Jun 8, 2025
8995fd4
refactor: task generator elk index configured in one place
m-karo Jun 9, 2025
3894de6
Merge branch 'dev' of https://github.com/Baltic-RCC/EMF into dev
m-karo Jun 9, 2025
b2ec123
bugfix: task generator improved with more logging and handling automa…
m-karo Jun 9, 2025
0946a95
Update process_conf.json
MK1295 Jun 9, 2025
26768e0
Update process_conf.json
MK1295 Jun 9, 2025
01e6f73
Update process_conf.json
MK1295 Jun 9, 2025
3d4a2a9
bugfix: update task status fixed as it works without loop
m-karo Jun 9, 2025
4c51033
Merge remote-tracking branch 'origin/dev' into dev
m-karo Jun 9, 2025
dfdcf5f
logging: from warning to error
m-karo Jun 9, 2025
3742109
logging: added logging message for schedule query
m-karo Jun 11, 2025
713838c
Update scaler.properties
MK1295 Jun 13, 2025
1d6ca3a
Model quality triplets refactoring
gpoderys Jun 13, 2025
6afd8c7
Merge pull request #340 from Baltic-RCC/gp-quality-module
gpoderys Jun 13, 2025
b2656a8
Update publish-workers.yml
snec-afk Jun 17, 2025
77b4ed5
Update Dockerfile
snec-afk Jun 17, 2025
04ad706
refactor: moving merge pre-process to model validation
m-karo Jun 17, 2025
3deb8bf
Merge remote-tracking branch 'origin/dev' into dev
m-karo Jun 17, 2025
543bb2b
aligned quality module index names
m-karo Jun 17, 2025
2b58afd
Update publish-workers.yml
snec-afk Jun 17, 2025
8368b78
refactoring ongoing to optimize post-processing
m-karo Jun 19, 2025
47411ff
logging: clarified object storage log message about source bucket
m-karo Jun 26, 2025
476e173
bugfix: model validator fix to sanitize minio URL for EQ profile
m-karo Jun 26, 2025
cd192e5
#337 scaling: implemented feature to keep power factor constant at DC…
m-karo Jun 26, 2025
5769916
bugfix: local replacement overwritten other additional received models
m-karo Jun 26, 2025
d371b34
moves preprocessing step for opening non-retained switches from merge…
mr0321 Jun 27, 2025
cf05c2c
fix for load files
mr0321 Jun 27, 2025
6a5d47f
various fixes to refactoring
mr0321 Jun 27, 2025
975a9eb
updates dependencies
mr0321 Jun 27, 2025
06e91f4
adds export parameter for pypowsybl 1.11.1
mr0321 Jun 27, 2025
7596e6e
removes duplicates
mr0321 Jun 27, 2025
5b0b0e5
Model quality IGM loading bugfix
gpoderys Jun 27, 2025
a1c3204
logging: added log message to report if LF diverged after island ACNP…
m-karo Jun 30, 2025
d9cb2e2
Merge pull request #342 from Baltic-RCC/mr-general_update
m-karo Jun 30, 2025
bb2ad61
Merge pull request #343 from Baltic-RCC/mr-validator_update
m-karo Jun 30, 2025
0614a36
remove temporary metrics collection as this has been moved to statist…
m-karo Jun 30, 2025
e1d9dda
remove pre validator regarding kirchoff law
m-karo Jun 30, 2025
6030af1
reafactor: moved function to helpers.utils
m-karo Jun 30, 2025
a70d70a
feature: tie lines consistency of connectivity function
m-karo Jun 30, 2025
c48f825
refactor: not used temporary functions moved to legacy.py file
m-karo Jun 30, 2025
6930b74
refactor: model validator separated non retained switchis to validati…
m-karo Jun 30, 2025
0d5c27a
bugfix: handle zero division on HVDC scaling
m-karo Jun 30, 2025
a1df786
bugfix: circular import
m-karo Jul 1, 2025
43aceb3
bugifx: merger return string instead python dict to be able to publis…
m-karo Jul 1, 2025
7f31cbc
bugfix: validator failure when BDS received, now ignore it
m-karo Jul 1, 2025
73eeb78
bugfix: removed pre temp fix parameter from task generator
m-karo Jul 1, 2025
bf9901e
bugfix: content reference generation from file name
m-karo Jul 1, 2025
a11e144
fixes ssh profile loading
mr0321 Jul 2, 2025
39dbd00
for Kirchhoff 1st law
mr0321 Jul 2, 2025
9a44deb
Merge pull request #347 from Baltic-RCC/mr-fixes_1
m-karo Jul 3, 2025
bc5088b
Merge pull request #349 from Baltic-RCC/mr-switches_vol_2
m-karo Jul 3, 2025
6f6649a
Model quality statistics key fix
gpoderys Jul 3, 2025
31b52c7
Model quality functions update
gpoderys Jul 3, 2025
fc938e0
bugfix: merger return statement when models not available
m-karo Jul 4, 2025
564049c
Merge branch 'dev' of https://github.com/Baltic-RCC/EMF into dev
m-karo Jul 4, 2025
5b20a8a
VA_Cornercase when RMM is ran with empty list on included
VeikoAunapuu Jul 7, 2025
8d38d2c
#320 dynamic validation settings relaxation
gpoderys Jul 7, 2025
1d98ce7
#320 merge settings auto relaxation
gpoderys Jul 7, 2025
24e2d9a
Merge pull request #353 from Baltic-RCC/gp-lf-settings
m-karo Jul 9, 2025
31d7b41
Merge pull request #351 from Baltic-RCC/VeikoAunapuu-patch-1
m-karo Jul 9, 2025
6c6feb5
minor fine tune of merged pull requests with bugfix to forward LF set…
m-karo Jul 9, 2025
9770b0d
Merge branch 'dev' into mr-pypowsybl_1_11_1
m-karo Jul 9, 2025
11fee00
Merge pull request #344 from Baltic-RCC/mr-pypowsybl_1_11_1
m-karo Jul 9, 2025
4d0c26d
bump to pypowsybl 1.11.2
m-karo Jul 9, 2025
4bbc92e
#324 removed local replacement from config
gpoderys Jul 9, 2025
0ee66f6
Merge pull request #354 from Baltic-RCC/gp-replacement-local
m-karo Jul 9, 2025
5d96a44
#326 Added dynamic replacement query length based on time horizon
gpoderys Jul 9, 2025
e226c94
Added opdm metadata to merger message properties header
gpoderys Jul 9, 2025
fcb94da
Merge pull request #355 from Baltic-RCC/gp-replacement-length
m-karo Jul 9, 2025
9b7eebc
quickfix: properties header update
gpoderys Jul 9, 2025
8354e79
dependencies: triplets to 0.0.10 and opdmapi to 0.1.3
m-karo Jul 9, 2025
a0fc87c
including supporting tools to base image
m-karo Jul 9, 2025
0c38b46
Quality module CGM updated metadata
gpoderys Jul 9, 2025
9be3577
bump to triplets 0.0.11
m-karo Jul 10, 2025
58cb1bf
bugfix: replacement QUERY_FILTER env variable removal
m-karo Jul 10, 2025
0a8583d
bugfix: task generator get task initiator does not work in kube
m-karo Jul 11, 2025
0a5b966
Update publish-workers.yml
snec-afk Jul 11, 2025
98d4a99
Update publish-workers.yml
snec-afk Jul 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/publish-workers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,10 @@ jobs:
if [[ "$BRANCH_NAME" == *-dev ]]; then
docker push "${IMAGE_NAME}:latest"
fi
# - name: Update helm values with new image tag
# run: |
# git config user.name "Github Actions"
# git config user.email "actions@github.com"
# git add helm-chart/test-rcc-cl2.values.yaml
# git commit -m "Update image tag to ${{ env.IMAGE_TAG }}
# git push
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name = "pypi"
[packages]
pandas = "2.2.2"
numpy = "2.0.0"
pypowsybl = "1.9.0"
pypowsybl = "*"
aniso8601 = "*"
lxml = "*"
edx = "*"
Expand Down
575 changes: 267 additions & 308 deletions Pipfile.lock

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions config/cgm_worker/merger.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[MAIN]
INPUT_RABBIT_QUE = emf-merge.tasks.rmm
OUTPUT_RMQ_EXCHANGE = emf-quality.test
INPUT_MINIO_BUCKET = opde-confidential-models
INPUT_MINIO_FOLDER = IGM
OUTPUT_MINIO_BUCKET = opde-confidential-models
OUTPUT_MINIO_FOLDER = EMFOS/RMM
MERGE_REPORT_ELK_INDEX = emfos-merge-reports
SMALL_ISLAND_SIZE = 10
MERGE_LOAD_FLOW_SETTINGS = CGM_RELAXED_3_CUSTOM
NET_INTERCHANGE_THRESHOLD = 200
OPEN_NON_RETAINED_SWITCHES_BETWEEN_TN = True
OPDE_MODELS_ELK_INDEX = emfos-opde-models
ENABLE_DYNAMIC_MERGE_SETTINGS = True
MERGE_LOAD_FLOW_SETTINGS = CGM_DEFAULT
MERGE_LOAD_FLOW_SETTINGS_PRIORITY = CGM_DEFAULT,CGM_RELAXED_1,CGM_RELAXED_2,CGM_RELAXED_3_CUSTOM
REMOVE_GENERATORS_FROM_SLACK_DISTRIBUTION = True
5 changes: 5 additions & 0 deletions config/cgm_worker/post_processing.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[MAIN]
NET_INTERCHANGE_THRESHOLD = 200
FIX_INJECTION_ERRORS = True
INJECTION_THRESHOLD = 0.1
SMALL_ISLAND_SIZE = 10
3 changes: 1 addition & 2 deletions config/cgm_worker/replacement.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[MAIN]
REPLACEMENT_CONFIG = config/cgm_worker/replacement_config.json
QUERY_FILTER = now-2w
REPLACEMENT_CONFIG = config/cgm_worker/replacement_config.json
9 changes: 6 additions & 3 deletions config/cgm_worker/replacement_conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
"configuration": {
"validity_start": "2024-02-22T00:00:00Z",
"validity_end": "2024-02-22T23:59:59Z",
"timeZone": "CET"
"time_zone": "CET"
},
"timeHorizon": {
"Request_list": ["ID", "1D", "2D", "WK", "1D", "MO", "YR"]
"time_horizon": {
"request_list": ["ID", "1D", "2D", "WK", "1D", "MO", "YR"]
},
"replacement_length": {
"request_list": ["2w", "2w", "2w", "2w", "2w", "1m", "4m"]
},
"month_ahead": {
"hours": ["07:30", "08:30", "09:30", "06:30", "05:30", "04:30"],
Expand Down
4 changes: 2 additions & 2 deletions config/cgm_worker/scaler.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[MAIN]
MAX_ITERATION = 10
MAX_ITERATION = 15
BALANCE_THRESHOLD = 2
DEBUG = True
DEBUG = True
1 change: 0 additions & 1 deletion config/integrations/object_storage.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[MAIN]
ELASTIC_TASKS_INDEX = emfos-tasks
ELASTIC_MODELS_INDEX = emfos-opde-models
ELASTIC_SCHEDULES_INDEX = emfos-schedules
4 changes: 4 additions & 0 deletions config/model_quality/model_quality.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[MAIN]
INPUT_RMQ_QUEUE = object-storage.models.quality
ELK_QUALITY_INDEX = emfos-model-quality
ELK_STATISTICS_INDEX = emfos-model-statistics
8 changes: 6 additions & 2 deletions config/model_validator/model_validator.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[MAIN]
INPUT_RMQ_QUEUE = object-storage.models.validation
OUTPUT_RMQ_EXCHANGE = emf-quality.test
VALIDATION_ELK_INDEX = emfos-igm-validation
METADATA_ELK_INDEX = emfos-opde-models
ELK_ID_FROM_METADATA_FIELDS = opde:Id,data-source
ELK_ID_HASHING = True
VALIDATION_LOAD_FLOW_SETTINGS = CGM_RELAXED_2
ENABLE_DYNAMIC_VALIDATION_SETTINGS = False
VALIDATION_LOAD_FLOW_SETTINGS = IGM_VALIDATION
VALIDATION_LOAD_FLOW_SETTINGS_PRIORITY = IGM_VALIDATION,CGM_DEFAULT,CGM_RELAXED_1,CGM_RELAXED_2,CGM_RELAXED_3_CUSTOM
CHECK_NON_RETAINED_SWITCHES = False
CHECK_KIRCHHOFF_FIRST_LAW = False
CHECK_KIRCHHOFF_FIRST_LAW = False
OPEN_NON_RETAINED_SWITCHES = True
2 changes: 0 additions & 2 deletions config/task_generator/manual_task_generator.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ TASK_REFERENCE_TIME =
TASK_VERSION =
TASK_MERGING_ENTITY =
RUN_REPLACEMENT =
RUN_REPLACEMENT_LOCAL =
RUN_SCALING =
UPLOAD_TO_OPDM =
UPLOAD_TO_MINIO =
SEND_MERGE_REPORT =
PRE_TEMP_FIXES =
POST_TEMP_FIXES =
FORCE_OUTAGE_FIX =
FIX_NET_INTERCHANGE2 =
40 changes: 40 additions & 0 deletions config/task_generator/process_conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,46 @@
"send_merge_report": "True"
}
},
{
"@context": "https://example.com/schemas/run.jsonld",
"@id": "https://example.com/runs/IntraDayRMM/EOD",
"@type": "Run",
"process_id": "https://example.com/processes/RMM_CREATION",
"valid_from": "",
"valid_to": "",
"gate_open": "PT1H",
"gate_close": "PT45M",
"run_at": "00 15 29 02 3",
"time_frame": "ID",
"data_timestamps": "30 * * * *",
"data_resolution": "PT1H",
"tags": [],
"properties": {
"merge_type": "BA",
"merging_entity": "BALTICRCC",
"included": [
"AST",
"PSE",
"ELERING",
"LITGRID"
],
"excluded": [],
"local_import": [],
"time_horizon": "ID",
"version": "001",
"mas": "http://www.baltic-rsc.eu/OperationalPlanning/RMM",
"replacement": "True",
"replacement_local":"False",
"pre_temp_fixes":"True",
"post_temp_fixes":"True",
"fix_net_interchange2": "False",
"force_outage_fix":"False",
"scaling": "False",
"upload_to_opdm": "False",
"upload_to_minio": "True",
"send_merge_report": "True"
}
},
{
"@context": "https://example.com/schemas/run.jsonld",
"@id": "https://example.com/runs/DayAheadRMM",
Expand Down
2 changes: 1 addition & 1 deletion config/task_generator/task_generator.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[MAIN]
RMQ_EXCHANGE = emf-tasks
TASK_ELK_INDEX =
TASK_ELK_INDEX = emfos-tasks
TASK_WINDOW_DURATION = PT1M
TASK_WINDOW_REFERENCE = currentMinuteStart
TIMESTAMP =
Expand Down
19 changes: 15 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Define base container image (platform has to be defined if using with ARM64 architecture)
FROM python:3.11 as emfos-base
#FROM --platform=linux/amd64 python:3.11 as emfos-base
FROM python:3.11-slim as emfos-base
#FROM --platform=linux/amd64 python:3.11-slim as emfos-base

# Set working directory
WORKDIR /src

# Install tools to set up python environment
RUN apt-get update && apt-get install -y --no-install-recommends procps && rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade setuptools pip uv pipenv

# Install needed modules
COPY Pipfile .
COPY Pipfile.lock .
#COPY requirements.txt .
#RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
#RUN pipenv install --system --deploy
RUN pipenv requirements > requirements.txt
Expand Down Expand Up @@ -73,7 +73,6 @@ WORKDIR /src
# Copy files to container
COPY emf/model_merger/ ./emf/model_merger/
COPY emf/common/ ./emf/common/
COPY emf/task_generator/ ./emf/task_generator/
COPY config/ ./config/

# Start process
Expand All @@ -95,3 +94,15 @@ COPY config/ ./config/
ENV PYTHONPATH="${PYTHONPATH}:/src"
ENTRYPOINT ["python", "emf/task_generator/worker.py"]
#ENTRYPOINT ["/bin/bash"]

# Model Quality image
FROM balticrcc/emfos-base:latest as emfos-model-quality

WORKDIR /src

COPY emf/model_quality/ ./emf/model_quality/
COPY emf/common/ ./emf/common/
COPY config/ ./config/

ENV PYTHONPATH="${PYTHONPATH}:/src"
ENTRYPOINT ["python", "emf/model_quality/worker.py"]
3 changes: 2 additions & 1 deletion emf/common/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Start logger
logger = logging.getLogger(__name__)


def performance_counter(units='seconds'):
"""Counts performance of the function"""
def decorator_performance_counter(func):
Expand All @@ -15,7 +16,7 @@ def wrapper_performance_counter(*args, **kwargs):
duration = round(time.perf_counter() - start_time, 2)
if units == 'minutes':
duration = round(duration / 60, 2) # counting by minutes
logger.info(f"Process {func.__name__!r} finished with duration: {duration} {units}", extra={'numeric_value': duration})
logger.info(f"Process {func.__name__!r} finished with duration: {duration} {units}")
return response
return wrapper_performance_counter
return decorator_performance_counter
53 changes: 53 additions & 0 deletions emf/common/helpers/cgmes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import logging
import json
import pandas as pd
import config
from lxml import etree

logger = logging.getLogger(__name__)


def export_to_cgmes_zip(triplets: list):
namespace_map = {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"cim": "http://iec.ch/TC57/2013/CIM-schema-cim16#",
"md": "http://iec.ch/TC57/61970-552/ModelDescription/1#",
"entsoe": "http://entsoe.eu/CIM/SchemaExtension/3/1#",
}

rdf_map = json.load(config.paths.cgm_worker.CGMES_v2_4_15_2014_08_07)

return pd.concat(triplets, ignore_index=True).export_to_cimxml(rdf_map=rdf_map,
namespace_map=namespace_map,
export_undefined=False,
export_type="xml_per_instance_zip_per_xml",
debug=False,
export_to_memory=True)


def get_metadata_from_rdfxml(parsed_xml: etree._ElementTree):
"""Parse model metadata form xml, returns a dictionary with metadata"""

assert isinstance(parsed_xml, etree._ElementTree)

rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"

header = parsed_xml.find("{*}FullModel") # Version update proof, as long as element name remains the same
meta_elements = header.getchildren()

# Add model ID from FullModel@about
metadata = {"Model.mRID": header.attrib.get(f'{{{rdf}}}about').split(":")[-1]}

# Add all other metadata
for element in meta_elements:
key = element.tag.split("}")[1]
value = element.text if element.text else element.attrib.get(f"{{{rdf}}}resource")
if existing_value := metadata.get(key):
value = existing_value + [value] if isinstance(existing_value, list) else [existing_value, value]
metadata[key] = value

return metadata


if __name__ == "__main__":
pass
Loading
Loading