Skip to content

Commit 87dc18b

Browse files
authored
[UPD] Basic ecosystem maintenance (#494)
* update version reqs and CI file * fix json dependency * pluto version in docs project file * fix json again * parse json into dicts instead of objects * parse json into dicts instead of objects * merge a test change from main * update json parser * fix test type errors * json parser: turn objects into dicts
1 parent 05e1f5e commit 87dc18b

5 files changed

Lines changed: 39 additions & 39 deletions

File tree

.github/workflows/ci.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
name: CI
22
on:
3-
- push
4-
- pull_request
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
# needed to allow julia-actions/cache to delete old caches that it has created
9+
permissions:
10+
actions: write
11+
contents: read
512
jobs:
613
test:
714
if: "!contains(github.event.head_commit.message, 'skip ci')"
@@ -11,7 +18,7 @@ jobs:
1118
fail-fast: false
1219
matrix:
1320
version:
14-
- '1.6'
21+
- '1.10'
1522
- '1'
1623
- 'nightly'
1724
os:
@@ -21,26 +28,18 @@ jobs:
2128
arch:
2229
- x64
2330
steps:
24-
- uses: actions/checkout@v3
25-
- uses: julia-actions/setup-julia@v1
31+
- uses: actions/checkout@v6
32+
- uses: julia-actions/setup-julia@v2
2633
with:
2734
version: ${{ matrix.version }}
2835
arch: ${{ matrix.arch }}
29-
- uses: actions/cache@v3
30-
env:
31-
cache-name: cache-artifacts
32-
with:
33-
path: ~/.julia/artifacts
34-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
35-
restore-keys: |
36-
${{ runner.os }}-test-${{ env.cache-name }}-
37-
${{ runner.os }}-test-
38-
${{ runner.os }}-
36+
- uses: julia-actions/cache@v3
3937
- uses: julia-actions/julia-buildpkg@latest
4038
continue-on-error: ${{ matrix.version == 'nightly' }}
4139
- uses: julia-actions/julia-runtest@latest
4240
continue-on-error: ${{ matrix.version == 'nightly' }}
4341
- uses: julia-actions/julia-processcoverage@v1
44-
- uses: codecov/codecov-action@v3
42+
- uses: codecov/codecov-action@v6
4543
with:
46-
file: lcov.info
44+
files: lcov.info
45+
token: ${{ secrets.CODECOV_TOKEN }}

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ CSV = "0.8.5, 0.9, 0.10"
2626
FilePaths = "0.8.3"
2727
Glob = "1.3"
2828
Graphs = "1"
29-
InfrastructureModels = "0.7.3, 0.7.5"
29+
InfrastructureModels = "~0.7"
3030
Ipopt = "1"
31-
JSON = "0.18, 0.19, 0.20, 0.21"
31+
JSON = "~0.18, ~0.19, ~0.20, ~0.21, ~1"
3232
JuMP = "1.23.2"
3333
LoggingExtras = "0.4.7, 1"
3434
PolyhedralRelaxations = "0.3.5"
3535
SCS = "0.9, 1.0, 1.1"
3636
SpecialFunctions = "2"
37-
julia = "1.6"
37+
julia = "^1.10"
3838

3939
[extras]
4040
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"

src/io/json/json.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ end
1616
parses json files that were dumped via JSON.print (or PMD.print_file)
1717
"""
1818
function parse_json(io::IO)
19-
data = JSON.parse(io)
19+
data = JSON.parse(io; dicttype=Dict{String, Any})
2020
correct_json_import!(data)
2121

2222
return data
@@ -28,21 +28,23 @@ end
2828
2929
helper function to correct data imported from json
3030
"""
31-
function correct_json_import!(data::Dict{String,<:Any})
31+
function correct_json_import!(data::AbstractDict{String,<:Any})
3232
_fix_dtypes!(data)
3333
end
3434

35-
36-
"recursive function to fix data types from data imported from json"
37-
function _fix_dtypes!(data::Dict)
35+
function _fix_dtypes!(data::AbstractDict)
3836
for (k, v) in data
39-
if isa(v, Dict)
37+
if v isa AbstractDict
4038
_fix_dtypes!(v)
41-
else
42-
_fix_enums!(data, k, data[k])
43-
_fix_arrays!(data, k, data[k])
44-
_fix_nulls!(data, k, data[k])
39+
elseif v isa Vector
40+
for item in v
41+
item isa AbstractDict && _fix_dtypes!(item)
42+
end
4543
end
44+
45+
_fix_enums!(data, k, data[k])
46+
_fix_arrays!(data, k, data[k])
47+
_fix_nulls!(data, k, data[k])
4648
end
4749
end
4850

test/en_pf_native_validation.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@info "running explicit neutral power flow tests with native julia power flow solver"
22

33

4-
function conductor_correction!(data_eng)
4+
function conductor_correction!(data_eng::AbstractDict)
55
nw = data_eng
66
if neutral_idx nw["conductor_ids"]
77
filter!(e -> e neutral_idx, nw["conductor_ids"])
@@ -45,7 +45,7 @@ end
4545

4646

4747

48-
function sourcebus_voltage_vector_correction!(data_math::Dict{String,Any}; explicit_neutral=true)
48+
function sourcebus_voltage_vector_correction!(data_math::AbstractDict; explicit_neutral=true)
4949
if haskey(data_math, "multinetwork")
5050
for (n, nw) in data_math["nw"]
5151
for (i, bus) in data_math["nw"]["bus"]
@@ -255,7 +255,7 @@ filter!(e -> e ≠ "case3_balanced_battery_3ph", cases)
255255

256256
# obtain solution from dss
257257
sol_dss = open("$solution_dir/$case.json", "r") do f
258-
JSON.parse(f)
258+
Dict{String, Any}(JSON.parse(f))
259259
end
260260

261261
sol_pmd = transform_solution(res["solution"], data_math, make_si=true)
@@ -285,7 +285,7 @@ filter!(e -> e ≠ "case3_balanced_battery_3ph", cases)
285285
res = compute_mc_pf(pfd)
286286

287287
sol_dss = open("$solution_dir/$case.json", "r") do f
288-
JSON.parse(f)
288+
Dict{String, Any}(JSON.parse(f))
289289
end
290290

291291
sol_pmd = transform_solution(res["solution"], data_math, make_si=true)
@@ -323,7 +323,7 @@ cases = ["test_trans_dy_3w", "test_trans_yy_3w", "ut_trans_3w_dyy_1", "ut_trans_
323323

324324
# obtain solution from dss
325325
sol_dss = open("$solution_dir/$case.json", "r") do f
326-
JSON.parse(f)
326+
Dict{String, Any}(JSON.parse(f))
327327
end
328328

329329
sol_pmd = transform_solution(res["solution"], data_math, make_si=true)
@@ -388,11 +388,10 @@ solution_dir = "data/opendss_solutions"
388388
@test res["termination_status"]["10"] == PF_CONVERGED
389389

390390
sol_dss = open("$solution_dir/$case.json", "r") do f
391-
JSON.parse(f)
391+
Dict{String, Any}(JSON.parse(f))
392392
end
393393

394394
sol_pmd = transform_solution(res["solution"], data_math, make_si=true)
395-
396395
v_maxerr_pu = compare_sol_dss_pmd(sol_dss, sol_pmd["nw"]["10"], eng_ts["nw"]["10"], data_math["nw"]["10"], verbose=false, compare_math=true)
397396
@test v_maxerr_pu <= 1E-1 # This tolerance is selected for the multinetwork to pass, must be tightened later. The problem may be with OpenDSS json result.
398397

@@ -419,7 +418,7 @@ filter!(e -> e ≠ "case3_unbalanced_delta_loads", cases)
419418

420419
# obtain solution from dss
421420
sol_dss = open("$solution_dir/$case.json", "r") do f
422-
JSON.parse(f)
421+
Dict{String, Any}(JSON.parse(f))
423422
end
424423

425424
sol_pmd = transform_solution(res["solution"], data_math, make_si=true)

test/en_pf_validation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ case_transformations = Dict(
4040

4141
# obtain solution from dss
4242
sol_dss = open("$solution_dir/$case.json", "r") do f
43-
JSON.parse(f)
43+
Dict{String, Any}(JSON.parse(f))
4444
end
4545

4646
# add lb on neutrals to prevent issues with ACR formulations

0 commit comments

Comments
 (0)