Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ssh_graph specification (not required) #185

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 4 deletions cimsparql/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
@dataclass
class ModelConfig:
system_state_repo: Optional[str] = None
ssh_graph: str = "?ssh_graph"
eq_repo: Optional[str] = None
value_mappers: Iterable[ValueMapper] = field(default_factory=list)

Expand Down Expand Up @@ -204,7 +203,7 @@ async def bus_data(self, region: Optional[str] = None) -> BusDataFrame:
return BusDataFrame(df)

def loads_query(self, region: Optional[str] = None) -> str:
substitutes = {"region": region or ".*", "ssh_graph": self.config.ssh_graph}
substitutes = {"region": region or ".*"}
return self.template_to_query(templates.LOADS_QUERY, substitutes)

async def loads(self, region: Optional[str] = None) -> LoadsDataFrame:
Expand Down Expand Up @@ -241,7 +240,7 @@ async def wind_generating_units(
return WindGeneratingUnitsDataFrame(df)

def synchronous_machines_query(self, region: Optional[str] = None) -> str:
substitutes = {"region": region or ".*", "ssh_graph": self.config.ssh_graph}
substitutes = {"region": region or ".*"}
return self.template_to_query(templates.SYNCHRONOUS_MACHINES_QUERY, substitutes)

async def synchronous_machines(
Expand Down Expand Up @@ -311,7 +310,7 @@ async def exchange(self, region: Optional[str] = None) -> ExchangeDataFrame:
return ExchangeDataFrame(df)

def converters_query(self, region: Optional[str] = None) -> str:
substitutes = {"region": region or ".*", "ssh_graph": self.config.ssh_graph}
substitutes = {"region": region or ".*"}
return self.template_to_query(templates.CONVERTERS_QUERY, substitutes)

async def converters(self, region: Optional[str] = None) -> ConvertersDataFrame:
Expand Down
10 changes: 4 additions & 6 deletions cimsparql/sparql/converters.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ PREFIX SN:<${SN}>
select ?mrid ?name ?alias ?p ?q ?station ?status ?node
where {
# Extract active and reactive power for the converter
graph ${ssh_graph} {
?converter cim:ACDCConverter.p ?p;
cim:ACDCConverter.q ?q .
}
?converter cim:ACDCConverter.p ?p;
cim:ACDCConverter.q ?q .

optional {?converter ^cim:SvStatus.ConductingEquipment/cim:SvStatus.inService ?in_service .}

# Extract connected and optionally the mrid for the topological node associated with the terminal
Expand All @@ -31,7 +30,6 @@ where {

# Extract properties for the terminals for the converter
?terminal cim:Terminal.ConductingEquipment ?converter;
cim:IdentifiedObject.mRID ?t_mrid;
cim:Terminal.ConnectivityNode ?con_node;
cim:Terminal.sequenceNumber|cim:ACDCTerminal.sequenceNumber 1 .
optional {?converter SN:Equipment.networkAnalysisEnable ?_analysis_enabled .}
Expand All @@ -44,6 +42,6 @@ where {
# 1) mRID of the topological node associated with the connectivity node
# 2) mRID of the topological node for the terminal
# 3) mRID of the terminal
bind(coalesce(?con_top_node_mrid, ?term_top_node_mrid, ?t_mrid) as ?node)
bind(coalesce(?con_top_node_mrid, ?term_top_node_mrid) as ?node)
bind(coalesce(?in_service, ?connected) as ?status)
}
3 changes: 1 addition & 2 deletions cimsparql/sparql/loads.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ where {

# Optionally extract in_service flag and active and reactive energy consumption for each load
optional {?load ^cim:SvStatus.ConductingEquipment/cim:SvStatus.inService ?in_service }.
graph ${ssh_graph} {?load cim:EnergyConsumer.p ?p; cim:EnergyConsumer.q ?q}
?load cim:EnergyConsumer.p ?p; cim:EnergyConsumer.q ?q .

service <${eq_repo}> {
# Declare which load types to consider
Expand Down Expand Up @@ -42,7 +42,6 @@ where {
cim:Terminal.ConnectivityNode ?con_node .
}


# Assign status flag for load. The status flag is set to the first existing of
# 1) in_service flag
# 2) connected flag the terminal
Expand Down
2 changes: 1 addition & 1 deletion cimsparql/sparql/synchronous_machines.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ where {
# Optinoally extract in_service flag for each macchine, as well as active and reactive power
service <${repo}> {
optional {?machine ^cim:SvStatus.ConductingEquipment/cim:SvStatus.inService ?in_service} .
graph ${ssh_graph} {optional {?machine cim:RotatingMachine.p ?p;cim:RotatingMachine.q ?q .}}
optional {?machine cim:RotatingMachine.p ?p;cim:RotatingMachine.q ?q .}
}
optional {?machine SN:Equipment.networkAnalysisEnable ?_network_analysis}
filter(?network_analysis)
Expand Down
15 changes: 2 additions & 13 deletions tests/t_utils/custom_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ def combined_graphdb_service() -> ServiceConfig:
return ServiceConfig(repo=repo)


default_ssh_graph = "<http://entsoe.eu/CIM/SteadyStateHypothesis/1/1>"


def ssh_graph():
return os.getenv("SSH_GRAPH", default_ssh_graph)


@functools.lru_cache
def combined_model() -> t_common.ModelTest:
if os.getenv("CI"):
Expand All @@ -32,9 +25,7 @@ def combined_model() -> t_common.ModelTest:
eq_repo = f"repository:{service.repo},infer=false"
model = None
try:
model = get_single_client_model(
service, ModelConfig(system_state_repo, ssh_graph(), eq_repo)
)
model = get_single_client_model(service, ModelConfig(system_state_repo, eq_repo))
except Exception as exc:
logger.error(f"{exc}")
return t_common.ModelTest(model, False, False)
Expand All @@ -52,9 +43,7 @@ def federated_model() -> t_common.ModelTest:
tpsvssh_client = GraphDBClient(tpsvssh_client_cfg)

m_cfg = ModelConfig(
f"repository:{system_state_repo},infer=false",
ssh_graph(),
f"repository:{eq_repo},infer=false",
f"repository:{system_state_repo},infer=false", f"repository:{eq_repo},infer=false"
)
model = None
try:
Expand Down
Loading