Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

bugfix: Table Data Parser can have undefined inputs #1186

Merged
merged 4 commits into from
Oct 1, 2024

Conversation

ymiftah
Copy link
Contributor

@ymiftah ymiftah commented Sep 9, 2024

Background

When defining my system through CSV, without any dc_branch.csv, the TableData parser failed to create the system.

Bug description

The CSV files are parsed iteratively, with the get_dataframe function reading the TableData as a dataframe
the get_dataframe function defaults to an empty dataframe if the InputCategory is not defined, not a nothing. The check should be aligned

Happy to provide more context in an issue linked to this

Copy link

codecov bot commented Sep 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.52%. Comparing base (4eb1bea) to head (e5cf0c9).
Report is 7 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1186      +/-   ##
==========================================
- Coverage   84.55%   84.52%   -0.03%     
==========================================
  Files         181      181              
  Lines        8389     8389              
==========================================
- Hits         7093     7091       -2     
- Misses       1296     1298       +2     
Flag Coverage Δ
unittests 84.52% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/parsers/power_system_table_data.jl 82.06% <100.00%> (-0.30%) ⬇️

@pesap
Copy link
Member

pesap commented Sep 9, 2024

@ymiftah , if you add an empty dc_branch.csv to the folder where you are parsing the CSV data, does it work?

@ymiftah
Copy link
Contributor Author

ymiftah commented Sep 10, 2024

With an empty dc_branch.csv file, the system is parsed with a warning (as expected)

julia> data
PowerSystems.PowerSystemTableData:
  directory:  ../notebooks/siiptest
  base_power:  100.0
  PowerSystems.InputCategoryModule.InputCategory.GENERATOR = 4:  0×0 DataFrame
  PowerSystems.InputCategoryModule.InputCategory.BUS = 2:  6×17 DataFrame
  PowerSystems.InputCategoryModule.InputCategory.DC_BRANCH = 3:  0×0 DataFrame
  PowerSystems.InputCategoryModule.InputCategory.LOAD = 5:  0×0 DataFrame
  PowerSystems.InputCategoryModule.InputCategory.BRANCH = 1:  16×13 DataFrame

Truncated output

sys = PSY.System(data)
...
┌ Warning: Missing PowerSystems.InputCategoryModule.InputCategory.DC_BRANCH = 3 data.
└ @ PowerSystems ~/.julia/dev/PowerSystems/src/parsers/power_system_table_data.jl:212

System
┌───────────────────┬─────────────┐
│ Property          │ Value       │
├───────────────────┼─────────────┤
│ Name              │             │
│ Description       │             │
│ System Units Base │ DEVICE_BASE │
│ Base Power        │ 100.0       │
│ Base Frequency    │ 60.0        │
│ Num Components    │ 46          │
└───────────────────┴─────────────┘

Static Components
┌──────────┬───────┐
│ Type     │ Count │
├──────────┼───────┤
│ ACBus    │ 6     │
│ Arc      │ 12    │
│ Area     │ 6     │
│ Line     │ 16    │
│ LoadZone │ 6     │
└──────────┴───────┘

PS: I do not have a fully/correctly defined set of csv yet (working around this issue #1185) , so i actually ran this with empty generators and loads csv files as well.

PPS: It would still throw an error without this bugfix

@jd-lara jd-lara requested review from pesap and removed request for jd-lara September 16, 2024 19:15
@pesap pesap force-pushed the bugfix/check_empty_not_nothing branch from b64e36c to 9ca67d5 Compare September 16, 2024 21:11
@jd-lara jd-lara merged commit d0d3519 into NREL-Sienna:main Oct 1, 2024
7 of 8 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants