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

Jd/add infos #316

Merged
merged 47 commits into from
Dec 22, 2023
Merged

Jd/add infos #316

merged 47 commits into from
Dec 22, 2023

Conversation

jd-lara
Copy link
Member

@jd-lara jd-lara commented Nov 29, 2023

No description provided.

@jd-lara jd-lara requested a review from daniel-thom November 29, 2023 22:01
@jd-lara jd-lara mentioned this pull request Nov 29, 2023
src/infos.jl Outdated Show resolved Hide resolved
src/InfrastructureSystems.jl Outdated Show resolved Hide resolved
src/component.jl Outdated Show resolved Hide resolved
src/component.jl Outdated Show resolved Hide resolved
src/component.jl Outdated Show resolved Hide resolved
src/component.jl Outdated Show resolved Hide resolved
src/system_data.jl Outdated Show resolved Hide resolved
src/system_data.jl Outdated Show resolved Hide resolved
src/system_data.jl Show resolved Hide resolved
src/system_data.jl Outdated Show resolved Hide resolved
src/system_data.jl Outdated Show resolved Hide resolved
jd-lara and others added 3 commits December 11, 2023 21:26
Co-authored-by: Daniel Thom <daniel.thom@nrel.gov>
Co-authored-by: Daniel Thom <daniel.thom@nrel.gov>
jd-lara and others added 3 commits December 11, 2023 23:05
Co-authored-by: Daniel Thom <daniel.thom@nrel.gov>
@jd-lara
Copy link
Member Author

jd-lara commented Dec 12, 2023

@daniel-thom I addressed most of the comments. There are a few failing tests related to the time series and the serialization

@jd-lara jd-lara self-assigned this Dec 12, 2023
@jd-lara jd-lara added the enhancement New feature or request label Dec 12, 2023
@jd-lara jd-lara requested a review from daniel-thom December 18, 2023 23:45
@jd-lara jd-lara marked this pull request as ready for review December 18, 2023 23:45
@jd-lara
Copy link
Member Author

jd-lara commented Dec 18, 2023

Tests are expected to fail on serialization/deserialization

end

function TestSupplemental(;
value::Float64 = 0.0,
Copy link
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
value::Float64 = 0.0,
value::Float64=0.0,

value::Float64 = 0.0,
component_uuids::Set{UUIDs.UUID}=Set{UUIDs.UUID}(),
)
return TestSupplemental(value, component_uuids, InfrastructureSystemsInternal(), TimeSeriesContainer())
Copy link
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 TestSupplemental(value, component_uuids, InfrastructureSystemsInternal(), TimeSeriesContainer())
return TestSupplemental(
value,
component_uuids,
InfrastructureSystemsInternal(),
TimeSeriesContainer(),
)

Comment on lines 102 to 103


Copy link
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

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

data::ComponentsByType
time_series_storage::TimeSeriesStorage
validation_descriptors::Vector
end

get_display_string(::Components) = "components"

function Components(time_series_storage::TimeSeriesStorage, validation_descriptors=nothing)
Copy link
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 Components(time_series_storage::TimeSeriesStorage, validation_descriptors=nothing)
function Components(
time_series_storage::TimeSeriesStorage,
validation_descriptors = nothing,
)

@@ -388,6 +362,7 @@ function set_name!(
set_name_internal!(component, name)
components.data[T][name] = component
@debug "Changed the name of component $(summary(component))" _group = LOG_GROUP_SYSTEM
return
end

function compare_values(x::Components, y::Components; compare_uuids=false)
Copy link
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 compare_values(x::Components, y::Components; compare_uuids=false)
function compare_values(x::Components, y::Components; compare_uuids = false)

Comment on lines 19 to 20
geo_json::Dict{String, Any}=Dict{String, Any}(),
component_uuids::Set{UUIDs.UUID}=Set{UUIDs.UUID}(),
Copy link
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
geo_json::Dict{String, Any}=Dict{String, Any}(),
component_uuids::Set{UUIDs.UUID}=Set{UUIDs.UUID}(),
geo_json::Dict{String, Any} = Dict{String, Any}(),
component_uuids::Set{UUIDs.UUID} = Set{UUIDs.UUID}(),

function _add_supplemental_attribute!(
supplemental_attributes::SupplementalAttributes,
supplemental_attribute::T;
allow_existing_time_series=false,
Copy link
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
allow_existing_time_series=false,
allow_existing_time_series = false,

function get_supplemental_attributes(
::Type{T},
supplemental_attributes::SupplementalAttributes,
filter_func::Union{Nothing, Function}=nothing,
Copy link
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
filter_func::Union{Nothing, Function}=nothing,
filter_func::Union{Nothing, Function} = nothing,

Comment on lines 348 to 349
len=len,
ignore_scaling_factors=ignore_scaling_factors,
Copy link
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
len=len,
ignore_scaling_factors=ignore_scaling_factors,
len = len,
ignore_scaling_factors = ignore_scaling_factors,

Comment on lines 361 to 363
start_time::Union{Nothing, Dates.DateTime}=nothing;
len::Union{Nothing, Int}=nothing,
ignore_scaling_factors=false,
Copy link
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
start_time::Union{Nothing, Dates.DateTime}=nothing;
len::Union{Nothing, Int}=nothing,
ignore_scaling_factors=false,
start_time::Union{Nothing, Dates.DateTime} = nothing;
len::Union{Nothing, Int} = nothing,
ignore_scaling_factors = false,

Comment on lines 370 to 371
len=len,
ignore_scaling_factors=ignore_scaling_factors,
Copy link
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
len=len,
ignore_scaling_factors=ignore_scaling_factors,
len = len,
ignore_scaling_factors = ignore_scaling_factors,

end

function _make_time_array(component, time_series, start_time, len, ignore_scaling_factors)
ta = make_time_array(time_series, start_time; len=len)
Copy link
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
ta = make_time_array(time_series, start_time; len=len)
ta = make_time_array(time_series, start_time; len = len)

Comment on lines 454 to 455
name_mapping::Union{Nothing, Dict{Tuple{String, String}, String}}=nothing,
scaling_factor_multiplier_mapping::Union{Nothing, Dict{String, String}}=nothing,
Copy link
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
name_mapping::Union{Nothing, Dict{Tuple{String, String}, String}}=nothing,
scaling_factor_multiplier_mapping::Union{Nothing, Dict{String, String}}=nothing,
name_mapping::Union{Nothing, Dict{Tuple{String, String}, String}} = nothing,
scaling_factor_multiplier_mapping::Union{Nothing, Dict{String, String}} = nothing,

src/component.jl Outdated
attribute_container[T] = Set{T}()
end
push!(attribute_container[T], attribute)
@debug "SupplementalAttribute type $T with UUID $(get_uuid(attribute)) stored in component $(get_name(component))"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a LOG_GROUP for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

These are already implemented.

src/component.jl Outdated
container = get_supplemental_attributes_container(component)
for attribute_set in values(container)
for i in attribute_set
delete!(get_components_uuids(i), get_uuid(component))
Copy link
Contributor

Choose a reason for hiding this comment

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

One plural should be sufficient: get_component_uuids.

Copy link
Member Author

Choose a reason for hiding this comment

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

These are fixed already

src/component.jl Outdated
if !haskey(container, T)
throw(
ArgumentError(
"supplemental attribute type $T is not stored in component $(get_name(component))",
Copy link
Contributor

Choose a reason for hiding this comment

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

Related to comments in the last round, I think you should use $(summary(component)) so that the component type shows up in the message.

Copy link
Member Author

Choose a reason for hiding this comment

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

These are fixed already

src/geographic_supplemental_attribute.jl Outdated Show resolved Hide resolved
src/geographic_supplemental_attribute.jl Outdated Show resolved Hide resolved
attribute::T,
) where {T <: InfrastructureSystemsSupplementalAttribute}
attach_component!(attribute, component)
attribute_container = get_supplemental_attributes_container(component)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this call attach_component!? The code here and there is different. It seems not great to modify the attribute inside the component code.

src/system_data.jl Outdated Show resolved Hide resolved
for info in attributes
for c_uuid in get_component_uuids(info)
comp = get_component(data, c_uuid)
delete!(get_supplemental_attributes_container(comp), info)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same above, I think this could call a component method.

@@ -0,0 +1,606 @@
const SUPPORTED_TIME_SERIES_TYPES =
Copy link
Contributor

Choose a reason for hiding this comment

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

For type aliases don’t we normally use pascal case? SupportedTimeSeriesTypes?

return remove_supplemental_attribute!(data.attributes, info)
end

function remove_supplemental_attributes!(
Copy link
Contributor

Choose a reason for hiding this comment

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

I have concerns about this function because of the implicit disconnection from components. Since the user can only add attributes through a component, shouldn’t they only be able to remove attributes through a component?

Copy link
Member Author

Choose a reason for hiding this comment

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

This contradicts previous requests to have a method to do this

Copy link
Member Author

Choose a reason for hiding this comment

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

This method will clear all attributed of a particular type

Copy link
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
in_memory = time_series_in_memory,
directory = time_series_directory,
compression = compression,

component::SUPPORTED_TIME_SERIES_TYPES,
ts_metadata::T,
ts::TimeSeriesData;
skip_if_present=false,
Copy link
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
skip_if_present=false,
skip_if_present = false,

get_name(ts_metadata),
ts,
)
add_time_series!(component, ts_metadata, skip_if_present=skip_if_present)
Copy link
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
add_time_series!(component, ts_metadata, skip_if_present=skip_if_present)
add_time_series!(component, ts_metadata; skip_if_present = skip_if_present)

println(io, "==========")
println(io, "Num components: $num_components")
if num_components > 0
println(io)
show_components_table(io, components, backend=Val(:auto))
show_components_table(io, container, backend=Val(:auto))
Copy link
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
show_components_table(io, container, backend=Val(:auto))
show_components_table(io, container; backend = Val(:auto))


function TestSupplemental(;
value::Float64 = 0.0,
component_uuids::Set{UUIDs.UUID}=Set{UUIDs.UUID}(),
Copy link
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
component_uuids::Set{UUIDs.UUID}=Set{UUIDs.UUID}(),
component_uuids::Set{UUIDs.UUID} = Set{UUIDs.UUID}(),

Comment on lines 85 to 86
ta = TimeSeries.TimeArray(range(initial_time; length=24, step=resolution), ones(24))
ts = IS.SingleTimeSeries(data=ta, name="test")
Copy link
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
ta = TimeSeries.TimeArray(range(initial_time; length=24, step=resolution), ones(24))
ts = IS.SingleTimeSeries(data=ta, name="test")
ta = TimeSeries.TimeArray(range(initial_time; length = 24, step = resolution), ones(24))
ts = IS.SingleTimeSeries(; data = ta, name = "test")

Comment on lines 255 to 256
ta = TimeSeries.TimeArray(range(initial_time; length=24, step=resolution), ones(24))
ts = IS.SingleTimeSeries(data=ta, name="test")
Copy link
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
ta = TimeSeries.TimeArray(range(initial_time; length=24, step=resolution), ones(24))
ts = IS.SingleTimeSeries(data=ta, name="test")
ta = TimeSeries.TimeArray(range(initial_time; length = 24, step = resolution), ones(24))
ts = IS.SingleTimeSeries(; data = ta, name = "test")

Copy link

codecov bot commented Dec 22, 2023

Codecov Report

Attention: 99 lines in your changes are missing coverage. Please review.

Comparison is base (43d40cc) 78.08% compared to head (deebdbc) 78.35%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #316      +/-   ##
==========================================
+ Coverage   78.08%   78.35%   +0.27%     
==========================================
  Files          44       49       +5     
  Lines        3737     3964     +227     
==========================================
+ Hits         2918     3106     +188     
- Misses        819      858      +39     
Flag Coverage Δ
unittests 78.35% <83.13%> (+0.27%) ⬆️

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

Files Coverage Δ
src/components.jl 90.78% <100.00%> (-1.68%) ⬇️
src/containers.jl 100.00% <100.00%> (ø)
src/deterministic.jl 82.08% <100.00%> (-0.27%) ⬇️
src/deterministic_single_time_series.jl 76.27% <ø> (ø)
src/hdf5_time_series_storage.jl 91.10% <100.00%> (ø)
src/in_memory_time_series_storage.jl 73.22% <100.00%> (ø)
src/internal.jl 80.70% <100.00%> (+1.75%) ⬆️
src/scenarios.jl 84.31% <100.00%> (ø)
src/time_series_cache.jl 92.56% <100.00%> (ø)
src/time_series_container.jl 76.78% <ø> (ø)
... and 24 more

@jd-lara jd-lara merged commit 2f8a2dc into main Dec 22, 2023
10 checks passed
@jd-lara jd-lara deleted the jd/add_infos branch December 22, 2023 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants