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

Add ComponentSelector feature: IS portion #342

Merged
merged 54 commits into from
Jan 18, 2025
Merged

Conversation

GabrielKS
Copy link
Contributor

@GabrielKS GabrielKS commented Mar 18, 2024

This draft PR will get filled in as @tengis-nrl and I move the ComponentSelector features from PowerAnalytics to InfrastructureSystems. Ready for review! Adds an immutable, lazy, system-independent representation of a grouped set of components. For more details and a demonstration, see https://github.nrel.gov/gkonars/PowerAnalytics-demos/blob/main/component_selector_pr_demo.ipynb.

Copy link

codecov bot commented Mar 24, 2024

Codecov Report

Attention: Patch coverage is 89.84375% with 13 lines in your changes missing coverage. Please review.

Project coverage is 78.47%. Comparing base (e443a83) to head (5bfccd4).
Report is 60 commits behind head on main.

Files with missing lines Patch % Lines
src/results.jl 0.00% 9 Missing ⚠️
src/time_series_storage.jl 0.00% 2 Missing ⚠️
src/component_container.jl 92.85% 1 Missing ⚠️
src/component_selector.jl 98.96% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #342      +/-   ##
==========================================
+ Coverage   77.94%   78.47%   +0.53%     
==========================================
  Files          69       71       +2     
  Lines        5622     5743     +121     
==========================================
+ Hits         4382     4507     +125     
+ Misses       1240     1236       -4     
Flag Coverage Δ
unittests 78.47% <89.84%> (+0.53%) ⬆️

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

Files with missing lines Coverage Δ
src/InfrastructureSystems.jl 55.55% <ø> (ø)
src/Optimization/optimization_container_keys.jl 95.58% <100.00%> (ø)
src/common.jl 66.66% <ø> (ø)
src/components.jl 86.39% <ø> (ø)
src/system_data.jl 92.01% <100.00%> (+0.01%) ⬆️
src/component_container.jl 92.85% <92.85%> (ø)
src/component_selector.jl 98.96% <98.96%> (ø)
src/time_series_storage.jl 61.53% <0.00%> (ø)
src/results.jl 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes

@tengis-nrl tengis-nrl marked this pull request as ready for review March 25, 2024 16:22
@tengis-nrl
Copy link
Contributor

image

@GabrielKS
Copy link
Contributor Author

We need working implementations of get_components and get_subselectors here, not just in PowerSystems, because the ComponentSelector feature is meant to be usable without PowerSystems. You'll note a TODO here about making get_available optional; if you don't think we have time to do that now, I think the IS version of get_components should just not check availability and the PSY version should.

@jd-lara jd-lara assigned jd-lara and unassigned tengis-nrl Apr 22, 2024
@GabrielKS GabrielKS changed the base branch from gks/td/component_selector_feature to main June 4, 2024 17:53
@GabrielKS GabrielKS force-pushed the gks/td/component_selector_port branch from 1732638 to 83ea408 Compare June 10, 2024 18:44
@GabrielKS
Copy link
Contributor Author

Rebased onto main and tests pass.

@GabrielKS GabrielKS assigned GabrielKS and unassigned jd-lara Jun 10, 2024
@GabrielKS GabrielKS requested a review from daniel-thom June 10, 2024 23:50
@GabrielKS GabrielKS force-pushed the gks/td/component_selector_port branch from f4e395d to d4c3aff Compare June 26, 2024 21:43
@GabrielKS GabrielKS force-pushed the gks/td/component_selector_port branch 2 times, most recently from 0344a74 to 915d247 Compare July 17, 2024 21:08
@GabrielKS GabrielKS force-pushed the gks/td/component_selector_port branch from 915d247 to b11ccf6 Compare September 18, 2024 20:49
@GabrielKS GabrielKS force-pushed the gks/td/component_selector_port branch from c5de532 to 78acc9d Compare September 25, 2024 22:35
@GabrielKS GabrielKS changed the title Move ComponentSelector from PowerAnalytics to InfrastructureSystems: IS portion Add ComponentSelector feature: IS portion Sep 26, 2024
@GabrielKS
Copy link
Contributor Author

This is now ready for in-depth code review! For a demonstration, see https://github.nrel.gov/gkonars/PowerAnalytics-demos/blob/main/component_selector_pr_demo.ipynb.

@GabrielKS GabrielKS requested a review from jd-lara September 26, 2024 00:30
Copy link
Contributor

@daniel-thom daniel-thom left a comment

Choose a reason for hiding this comment

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

This is a first pass to get some pedantic stuff out of the way.

function get_components(e::FilterComponentSelector, sys::SYSTEM_LIKE; filterby = nothing)
components = get_components(e.filter_fn, e.component_subtype, sys)
isnothing(filterby) && (return components)
return Iterators.filter(filterby, components)
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes the function type unstable. We created FlattenIteratorWrapper so that we know the length. We shouldn't return different types based on a kwarg.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any performance concerns with adding the second filter + iterator? Basically, how much slower is this implementation vs combining the two filter functions into one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Agreed, I'll make these type stable.
  2. Looks like not really, not after compilation anyway:
Screenshot 2024-09-30 at 3 20 06 PM (this is on the massive EI system)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get_components now always returns FlattenIteratorWrapper. I also ended up combining the two filter functions into one as an implementation detail (not for performance, it just ended up being more convenient with FlattenIteratorWrapper).

@GabrielKS GabrielKS force-pushed the gks/td/component_selector_port branch from edaf6b1 to 701591e Compare January 17, 2025 20:16
@GabrielKS GabrielKS requested a review from daniel-thom January 17, 2025 22:09
Copy link
Contributor

@daniel-thom daniel-thom left a comment

Choose a reason for hiding this comment

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

LGTM

@jd-lara jd-lara merged commit 4807dca into main Jan 18, 2025
10 checks passed
@jd-lara jd-lara deleted the gks/td/component_selector_port branch January 19, 2025 06:55
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.

4 participants