Skip to content

[BUG] String keys handed off to IMs code that expects ints #495

Description

@skylerreid

The InfrastructureModels function _populate_ref_it! operates on dictionaries that have string keys that can be parsed to integers. At some point, data is handed off to this function that has the string keys source, primary, and regleg. This causes the parse call in IMs to fail when it tries to convert these strings to integers.

See failing tests in ref_ravens_schema.

3-bus balanced multinetwork instantiate_mc_model - autodetect multinetwork: Error During Test at U:\dev\PowerModelsDistribution.jl\test\multinetwork.jl:11
  Got exception outside of a @test
  ArgumentError: invalid base 10 digit 's' in "source"
  Stacktrace:
    [1] tryparse_internal(::Type{Int64}, s::String, startpos::Int64, endpos::Int64, base_::Int64, raise::Bool)
      @ Base .\parse.jl:143
    [2] #parse#621
      @ .\parse.jl:254 [inlined]
    [3] parse
      @ .\parse.jl:253 [inlined]
    [4] #5
      @ .\none:0 [inlined]
    [5] iterate
      @ .\generator.jl:48 [inlined]
    [6] collect(itr::Base.Generator{Dict{String, Any}, InfrastructureModels.var"#5#6"})
      @ Base .\array.jl:791
    [7] _populate_ref_it!(refs::Dict{Symbol, Any}, data_it::Dict{String, Any}, global_keys::Set{String}, it::String)
      @ InfrastructureModels C:\Users\409610\.julia\packages\InfrastructureModels\3h9nD\src\core\base.jl:213
    [8] ref_initialize(data::Dict{String, Any}, it::String, global_keys::Set{String})
      @ InfrastructureModels C:\Users\409610\.julia\packages\InfrastructureModels\3h9nD\src\core\base.jl:148
    [9] InitializeInfrastructureModel(InfrastructureModel::Type{ACPUPowerModel}, data::Dict{String, Any}, global_keys::Set{String}, it::Symbol; ext::Dict{Symbol, Any}, setting::Dict{String, Any}, jump_model::JuMP.Model)
      @ InfrastructureModels C:\Users\409610\.julia\packages\InfrastructureModels\3h9nD\src\core\base.jl:83
   [10] InitializeInfrastructureModel(InfrastructureModel::Type, data::Dict{String, Any}, global_keys::Set{String}, it::Symbol)
      @ InfrastructureModels C:\Users\409610\.julia\packages\InfrastructureModels\3h9nD\src\core\base.jl:77
   [11] instantiate_model(data::Dict{String, Any}, model_type::Type, build_method::typeof(build_mn_mc_opf), ref_add_core!::typeof(ref_add_core!), global_keys::Set{String}, it::Symbol; ref_extensions::Vector{Function}, kwargs::@Kwargs{})
      @ InfrastructureModels C:\Users\409610\.julia\packages\InfrastructureModels\3h9nD\src\core\base.jl:356
   [12] #instantiate_mc_model#3761
      @ U:\dev\PowerModelsDistribution.jl\src\prob\common.jl:119 [inlined]
   [13] instantiate_mc_model(data::EngineeringModel{MultinetworkModel}, model_type::Type, build_method::Function)
      @ PowerModelsDistribution U:\dev\PowerModelsDistribution.jl\src\prob\common.jl:94
   [14] macro expansion
      @ U:\dev\PowerModelsDistribution.jl\test\multinetwork.jl:13 [inlined]
   [15] macro expansion
      @ C:\Users\409610\AppData\Local\Programs\Julia-1.11.6\share\julia\stdlib\v1.11\Test\src\Test.jl:1709 [inlined]
   [16] macro expansion
      @ U:\dev\PowerModelsDistribution.jl\test\multinetwork.jl:12 [inlined]
   [17] macro expansion
      @ C:\Users\409610\AppData\Local\Programs\Julia-1.11.6\share\julia\stdlib\v1.11\Test\src\Test.jl:1709 [inlined]
   [18] top-level scope
      @ U:\dev\PowerModelsDistribution.jl\test\multinetwork.jl:4
   [19] include(fname::String)
      @ Main .\sysimg.jl:38
   [20] macro expansion
      @ U:\dev\PowerModelsDistribution.jl\test\runtests.jl:46 [inlined]
   [21] macro expansion
      @ C:\Users\409610\AppData\Local\Programs\Julia-1.11.6\share\julia\stdlib\v1.11\Test\src\Test.jl:1709 [inlined]
   [22] top-level scope
      @ U:\dev\PowerModelsDistribution.jl\test\runtests.jl:28
   [23] include(fname::String)
      @ Main .\sysimg.jl:38
   [24] top-level scope
      @ none:6

System Information:

  • OS: Windows 11
  • Julia: 1.11.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions