Skip to content

Removing parsers: PowerSystemTableData, PowerModelsData, PowerFlowDataNetwork#1648

Open
hannahchubin wants to merge 7 commits intopsy6from
hc/remove_powerflow_parser
Open

Removing parsers: PowerSystemTableData, PowerModelsData, PowerFlowDataNetwork#1648
hannahchubin wants to merge 7 commits intopsy6from
hc/remove_powerflow_parser

Conversation

@hannahchubin
Copy link
Copy Markdown
Contributor

I've removed the parsing functions PowerSystemTableData(), PowerModelsData(), and PowerFlowDataNetwork() from all of PSY, meaning I've commented out (can fully delete once my changes are approved) and edited the following:

  • added PowerFlowFileParser.jl and PowerTableDataParser.jl repos as dependencies of PowerSystems.jl instead of exporting the parsing functions from PSY directly
  • removed the three parsing functions mentioned above, but kept their System methods, that use the parsed data created by said functions, in this repo
  • prefixed any calls of the three parsing functions in PSY with the name of the new repo they live in
  • moved all functions and constants in src/parsers/ that are only used to create/support the parsing functions to their new respective repos
  • the function get_generator_type defined in src/parsers/common.jl is called on the output of get_generator_mapping (defined in the same file), but the latter function is copied to PowerTableDataParser.jl with a different method. Therefore, the former function needed to be modified here to accommodate for both possible output types from the latter.
  • consequently, some of the getters in src/parsers/power_system_table_data.jl were also modified to accommodate this change
  • New function _category_key defined in src/parsers/power_system_table_data.jl to handle the fact that PowerTableDataParser.jl has data that does not use InputCategory in an effort to remove any PSY deps from the parsing repos. Previously, PowerSystemTableData in PSY could use InputCategory, so this new function is to handle this discrepancy
  • generally annotated the files in src/parsers/ with comments describing where certain functions are used in the parsing workflow
  • removed all the tests that were testing the parsing functions, as they now live in their new respective repos

@hannahchubin hannahchubin requested a review from jd-lara April 1, 2026 20:27
@jd-lara jd-lara changed the base branch from main to psy6 April 2, 2026 18:01
@jd-lara jd-lara requested a review from daniel-thom April 2, 2026 18:01
pm_kwargs = Dict(k => v for (k, v) in kwargs if !in(k, SYSTEM_KWARGS))
sys_kwargs = Dict(k => v for (k, v) in kwargs if in(k, SYSTEM_KWARGS))
return System(PowerModelsData(file_path; pm_kwargs...); sys_kwargs...)
return System(PowerFlowFileParser.PowerModelsData(file_path; pm_kwargs...); sys_kwargs...)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
return System(PowerFlowFileParser.PowerModelsData(file_path; pm_kwargs...); sys_kwargs...)
return System(
PowerFlowFileParser.PowerModelsData(file_path; pm_kwargs...);
sys_kwargs...,
)


"""Return the PowerSystems generator type for this fuel and unit_type."""
function get_generator_type(fuel, unit_type, mappings::Dict{NamedTuple, DataType})
function get_generator_type(fuel, unit_type, mappings::Union{Dict{NamedTuple, String}, Dict{NamedTuple, DataType}})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
function get_generator_type(fuel, unit_type, mappings::Union{Dict{NamedTuple, String}, Dict{NamedTuple, DataType}})
function get_generator_type(
fuel,
unit_type,
mappings::Union{Dict{NamedTuple, String}, Dict{NamedTuple, DataType}},
)

"""Return a vector of user-defined fields for the category."""
function get_user_fields(data::PowerSystemTableData, category::InputCategory)
if !haskey(data.user_descriptors, category)
function get_user_fields(data::PowerTableDataParser.PowerSystemTableData, category::InputCategory)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
function get_user_fields(data::PowerTableDataParser.PowerSystemTableData, category::InputCategory)
function get_user_fields(
data::PowerTableDataParser.PowerSystemTableData,
category::InputCategory,
)

"""Return the dataframe for the category."""
function get_dataframe(data::PowerSystemTableData, category::InputCategory)
df = get(data.category_to_df, category, DataFrames.DataFrame())
function get_dataframe(data::PowerTableDataParser.PowerSystemTableData, category::InputCategory)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
function get_dataframe(data::PowerTableDataParser.PowerSystemTableData, category::InputCategory)
function get_dataframe(
data::PowerTableDataParser.PowerSystemTableData,
category::InputCategory,
)

Refer to the PowerSystems descriptor file for field names that will be created.
"""
function iterate_rows(data::PowerSystemTableData, category; na_to_nothing = true)
function iterate_rows(data::PowerTableDataParser.PowerSystemTableData, category; na_to_nothing = true)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
function iterate_rows(data::PowerTableDataParser.PowerSystemTableData, category; na_to_nothing = true)
function iterate_rows(
data::PowerTableDataParser.PowerSystemTableData,
category;
na_to_nothing = true,
)


function _get_field_infos(data::PowerSystemTableData, category::InputCategory, df_names)
if !haskey(data.user_descriptors, category)
function _get_field_infos(data::PowerTableDataParser.PowerSystemTableData, category::InputCategory, df_names)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
function _get_field_infos(data::PowerTableDataParser.PowerSystemTableData, category::InputCategory, df_names)
function _get_field_infos(
data::PowerTableDataParser.PowerSystemTableData,
category::InputCategory,
df_names,
)


"""Reads values from dataframe row and performs necessary conversions."""
function _read_data_row(data::PowerSystemTableData, row, field_infos; na_to_nothing = true)
function _read_data_row(data::PowerTableDataParser.PowerSystemTableData, row, field_infos; na_to_nothing = true)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
function _read_data_row(data::PowerTableDataParser.PowerSystemTableData, row, field_infos; na_to_nothing = true)
function _read_data_row(
data::PowerTableDataParser.PowerSystemTableData,
row,
field_infos;
na_to_nothing = true,
)

end

function Base.show(io::IO, ::MIME"text/plain", data::PowerSystemTableData)
function Base.show(io::IO, ::MIME"text/plain", data::PowerTableDataParser.PowerSystemTableData)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
function Base.show(io::IO, ::MIME"text/plain", data::PowerTableDataParser.PowerSystemTableData)
function Base.show(
io::IO,
::MIME"text/plain",
data::PowerTableDataParser.PowerSystemTableData,
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants