Skip to content

Commit 324840c

Browse files
committed
Apply ruff formatting to Python source and test files
Run ruff format to normalize quote style to double quotes, wrap long lines, and fix spacing across goss.py, field_proxy_forwarder.py, and test_simulation.py.
1 parent f674228 commit 324840c

3 files changed

Lines changed: 68 additions & 62 deletions

File tree

gridappsd-field-bus-lib/gridappsd_field_bus/field_interface/field_proxy_forwarder.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
try:
88
from importlib.metadata import version as _pkg_version
9-
_STOMP_V8 = int(_pkg_version('stomp-py').split('.')[0]) >= 8
9+
10+
_STOMP_V8 = int(_pkg_version("stomp-py").split(".")[0]) >= 8
1011
except Exception:
1112
_STOMP_V8 = False
1213

gridappsd-python-lib/gridappsd/goss.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,15 @@
6767
_log: Logger = logging.getLogger(inspect.getmodulename(__file__))
6868

6969
# stomp.py 8.x changed listener callbacks from (headers, body) to (frame)
70-
_stomp_major = int(getattr(_stomp_module, '__version__', (0,))[0]) if isinstance(getattr(_stomp_module, '__version__', None), tuple) else 0
70+
_stomp_major = (
71+
int(getattr(_stomp_module, "__version__", (0,))[0])
72+
if isinstance(getattr(_stomp_module, "__version__", None), tuple)
73+
else 0
74+
)
7175
try:
7276
from importlib.metadata import version as _pkg_version
73-
_stomp_major = int(_pkg_version('stomp-py').split('.')[0])
77+
78+
_stomp_major = int(_pkg_version("stomp-py").split(".")[0])
7479
except Exception:
7580
pass
7681
_STOMP_V8 = _stomp_major >= 8
Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
1-
#import json
2-
#import logging
3-
#import os
4-
#import sys
5-
#import time
6-
#import pytest
7-
#from datetime import datetime, timezone
1+
import json
2+
import logging
3+
import os
4+
import sys
5+
import time
6+
import pytest
7+
from datetime import datetime, timezone
88

9-
#logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
9+
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
1010

11-
#from gridappsd import GridAPPSD, topics as t
12-
#from gridappsd.simulation import Simulation, PowerSystemConfig, SimulationArgs, SimulationConfig
11+
from gridappsd import GridAPPSD, topics as t
12+
from gridappsd.simulation import Simulation, PowerSystemConfig, SimulationArgs, SimulationConfig
1313

14-
#simulation_is_complete = False
15-
#measurements_received = 0
14+
simulation_is_complete = False
15+
measurements_received = 0
1616

17-
#@pytest.fixture
18-
#def createGadObject():
19-
# gad_user = os.environ.get('GRIDAPPSD_USER')
20-
# if gad_user is None:
21-
# os.environ['GRIDAPPSD_USER'] = 'system'
22-
# gad_password = os.environ.get('GRIDAPPSD_PASSWORD')
23-
# if gad_password is None:
24-
# os.environ['GRIDAPPSD_PASSWORD'] = 'manager'
25-
# return GridAPPSD()
17+
@pytest.fixture
18+
def createGadObject():
19+
gad_user = os.environ.get('GRIDAPPSD_USER')
20+
if gad_user is None:
21+
os.environ['GRIDAPPSD_USER'] = 'system'
22+
gad_password = os.environ.get('GRIDAPPSD_PASSWORD')
23+
if gad_password is None:
24+
os.environ['GRIDAPPSD_PASSWORD'] = 'manager'
25+
return GridAPPSD()
2626

27-
#def test_createSimulations(createGadObject):
28-
# gadObj = createGadObject
29-
# response = gadObj.query_model_info()
30-
# models = response.get("data", {}).get("models", {})
31-
# start_time = int(datetime(year=2025, month=1, day=1, hour=0, minute=0, second=0, microsecond=0, tzinfo=timezone.utc).timestamp())
32-
# simulationArgs = SimulationArgs(start_time=f"{start_time}",
33-
# duration="120",
34-
# run_realtime=False,
35-
# pause_after_measurements=False)
36-
# sim_config = SimulationConfig(simulation_config=simulationArgs)
37-
# modelsToRun = [
38-
# "49AD8E07-3BF9-A4E2-CB8F-C3722F837B62", # IEEE 13 Node Test Feeder
39-
# "C1C3E687-6FFD-C753-582B-632A27E28507" # IEEE 123 Node Test Feeder
40-
# ]
41-
# for m in models:
42-
# if m.get("modelId") not in modelsToRun:
43-
# continue
44-
# line_name = m.get("modelId")
45-
# subregion_name = m.get("subRegionId")
46-
# region_name = m.get("regionId")
47-
# psc = PowerSystemConfig(Line_name=line_name,
48-
# SubGeographicalRegion_name=subregion_name,
49-
# GeographicalRegion_name=region_name)
50-
# sim_config.power_system_configs.append(psc)
51-
# sim_obj = Simulation(gapps=gadObj, run_config=sim_config)
52-
# def on_measurement(sim, ts, m):
53-
# global measurements_received
54-
# measurements_received += 1
55-
# def on_simulation_complete(sim):
56-
# global simulation_is_complete
57-
# simulation_is_complete = True
58-
# sim_obj.add_onmeasurement_callback(on_measurement)
59-
# sim_obj.add_oncomplete_callback(on_simulation_complete)
60-
# sim_obj.start_simulation()
61-
# while not simulation_is_complete:
62-
# time.sleep(1)
63-
# assert measurements_received == 1
64-
# gadObj.disconnect()
27+
def test_createSimulations(createGadObject):
28+
gadObj = createGadObject
29+
response = gadObj.query_model_info()
30+
models = response.get("data", {}).get("models", {})
31+
start_time = int(datetime(year=2025, month=1, day=1, hour=0, minute=0, second=0, microsecond=0, tzinfo=timezone.utc).timestamp())
32+
simulationArgs = SimulationArgs(start_time=f"{start_time}",
33+
duration="120",
34+
run_realtime=False,
35+
pause_after_measurements=False)
36+
sim_config = SimulationConfig(simulation_config=simulationArgs)
37+
modelsToRun = [
38+
"49AD8E07-3BF9-A4E2-CB8F-C3722F837B62", # IEEE 13 Node Test Feeder
39+
"C1C3E687-6FFD-C753-582B-632A27E28507" # IEEE 123 Node Test Feeder
40+
]
41+
for m in models:
42+
if m.get("modelId") not in modelsToRun:
43+
continue
44+
line_name = m.get("modelId")
45+
subregion_name = m.get("subRegionId")
46+
region_name = m.get("regionId")
47+
psc = PowerSystemConfig(Line_name=line_name,
48+
SubGeographicalRegion_name=subregion_name,
49+
GeographicalRegion_name=region_name)
50+
sim_config.power_system_configs.append(psc)
51+
sim_obj = Simulation(gapps=gadObj, run_config=sim_config)
52+
def on_measurement(sim, ts, m):
53+
global measurements_received
54+
measurements_received += 1
55+
def on_simulation_complete(sim):
56+
global simulation_is_complete
57+
simulation_is_complete = True
58+
sim_obj.add_onmeasurement_callback(on_measurement)
59+
sim_obj.add_oncomplete_callback(on_simulation_complete)
60+
sim_obj.start_simulation()
61+
while not simulation_is_complete:
62+
time.sleep(1)
63+
assert measurements_received == 1
64+
gadObj.disconnect()

0 commit comments

Comments
 (0)