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_supplemental_attribute! bug #1282

Open
claytonpbarrows opened this issue Feb 12, 2025 · 1 comment
Open

remove_supplemental_attribute! bug #1282

claytonpbarrows opened this issue Feb 12, 2025 · 1 comment
Assignees
Labels

Comments

@claytonpbarrows
Copy link
Member

help?> remove_supplemental_attribute!
search: remove_supplemental_attribute! remove_supplemental_attributes! iterate_supplemental_attributes get_supplemental_attributes

  remove_supplemental_attribute!(
      sys::System,
      component::Component,
      attribute::SupplementalAttribute
  )
  

  Remove the supplemental attribute from the component. The attribute will be removed from the system if it is not attached to any other
  component.

  ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  remove_supplemental_attribute!(
      sys::System,
      attribute::SupplementalAttribute
  )
  

  Remove the supplemental attribute from the system and all attached components.

julia> a = get_supplemental_attributes(x->x.geo_json["coordinates"] == [0.0,0.0], GeographicInfo, sys) |> first
GeographicInfo: 3add1158-d1d8-428d-ab2b-cd6096b6c0ee:
   geo_json: Dict{String, Any}("coordinates" => Any[0, 0], "type" => "Point")
   has_time_series: false

julia> remove_supplemental_attribute!(sys, a)
ERROR: MethodError: no method matching remove_supplemental_attribute!(::InfrastructureSystems.SystemData, ::GeographicInfo)
The function `remove_supplemental_attribute!` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  remove_supplemental_attribute!(::InfrastructureSystems.SystemData, ::InfrastructureSystems.InfrastructureSystemsComponent, ::SupplementalAttribute)
   @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/nVUI1/src/system_data.jl:1195
  remove_supplemental_attribute!(::InfrastructureSystems.SupplementalAttributeManager, ::SupplementalAttribute)
   @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/nVUI1/src/supplemental_attribute_manager.jl:157
  remove_supplemental_attribute!(::InfrastructureSystems.SupplementalAttributeManager, ::InfrastructureSystems.InfrastructureSystemsComponent, ::SupplementalAttribute)
   @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/nVUI1/src/supplemental_attribute_manager.jl:145

Stacktrace:
 [1] remove_supplemental_attribute!(sys::System, attribute::GeographicInfo)
   @ PowerSystems ~/.julia/packages/PowerSystems/azBUB/src/base.jl:1665
 [2] top-level scope
   @ REPL[49]:1
@daniel-thom
Copy link
Contributor

There is a disconnect between PSY and IS, and I don't recall why. IS quite explicitly does not allow removal of a single attribute. The SystemData struct does not implement the method, as shown in the stack trace. The SupplementalAttributesManager does implement the method. However, it will fail if the attribute is still attached to a component.

I don't recall if this is the intended behavior and if we/I just forgot to delete the PSY method.

If @jd-lara remembers the history, let me know. Otherwise, let's just focus on what we want. This hasn't worked in a long time, if ever.

  • A user cannot add a supplemental attribute by itself, so these methods are symmetric. Also, one could argue that, despite the docstring, implicit disconnection from components may not be obvious.
add_supplemental_attribute!(sys, component, attribute)
remove_supplemental_attribute!(sys, component, attribute)
  • We do offer this method to remove all attributes of a particular type. It detaches all components first.
function remove_supplemental_attributes!(
    ::Type{T},
    sys::System,
) where {T <: IS.SupplementalAttribute}

Solutions:

  1. Delete this method from PSY and require the user to pass the component.
  2. Implement a new method that implements the PSY docstring.

What do you guys want? @claytonpbarrows @jd-lara

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants