NREL-Sienna / InfrastructureSystems.jl

Utility package for Sienna's simulation infrastructure
https://nrel-sienna.github.io/InfrastructureSystems.jl/
BSD 3-Clause "New" or "Revised" License
35 stars 20 forks source link

Fix handling of deepcopy for SQLite databases #364

Closed daniel-thom closed 2 months ago

daniel-thom commented 2 months ago

This PR fixes a bug introduced by #357. The code did not properly handle the shared references to the internal SQLite database during a deepcopy of the system. This fix does the following:

An alternate is solution is to implement management of the SQLite database at the SystemData level. I did not go that route because of the requirement that supplemental attributes be persisted to JSON, not SQLite, during serialization.

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 90.24390% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 76.53%. Comparing base (490236b) to head (2a13ee9).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/NREL-Sienna/InfrastructureSystems.jl/pull/364/graphs/tree.svg?width=650&height=150&src=pr&token=I73yjxYxgn&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-Sienna)](https://app.codecov.io/gh/NREL-Sienna/InfrastructureSystems.jl/pull/364?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-Sienna) ```diff @@ Coverage Diff @@ ## main #364 +/- ## ========================================== - Coverage 76.65% 76.53% -0.13% ========================================== Files 66 66 Lines 5004 5012 +8 ========================================== Hits 3836 3836 - Misses 1168 1176 +8 ``` | [Flag](https://app.codecov.io/gh/NREL-Sienna/InfrastructureSystems.jl/pull/364/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-Sienna) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/NREL-Sienna/InfrastructureSystems.jl/pull/364/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-Sienna) | `76.53% <90.24%> (-0.13%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-Sienna#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/NREL-Sienna/InfrastructureSystems.jl/pull/364?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-Sienna) | Coverage Δ | | |---|---|---| | [src/supplemental\_attribute\_associations.jl](https://app.codecov.io/gh/NREL-Sienna/InfrastructureSystems.jl/pull/364?src=pr&el=tree&filepath=src%2Fsupplemental_attribute_associations.jl&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-Sienna#diff-c3JjL3N1cHBsZW1lbnRhbF9hdHRyaWJ1dGVfYXNzb2NpYXRpb25zLmps) | `92.80% <100.00%> (-2.69%)` | :arrow_down: | | [src/supplemental\_attribute\_manager.jl](https://app.codecov.io/gh/NREL-Sienna/InfrastructureSystems.jl/pull/364?src=pr&el=tree&filepath=src%2Fsupplemental_attribute_manager.jl&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-Sienna#diff-c3JjL3N1cHBsZW1lbnRhbF9hdHRyaWJ1dGVfbWFuYWdlci5qbA==) | `93.68% <100.00%> (-0.07%)` | :arrow_down: | | [src/system\_data.jl](https://app.codecov.io/gh/NREL-Sienna/InfrastructureSystems.jl/pull/364?src=pr&el=tree&filepath=src%2Fsystem_data.jl&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-Sienna#diff-c3JjL3N5c3RlbV9kYXRhLmps) | `90.21% <100.00%> (+0.03%)` | :arrow_up: | | [src/time\_series\_manager.jl](https://app.codecov.io/gh/NREL-Sienna/InfrastructureSystems.jl/pull/364?src=pr&el=tree&filepath=src%2Ftime_series_manager.jl&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-Sienna#diff-c3JjL3RpbWVfc2VyaWVzX21hbmFnZXIuamw=) | `91.26% <ø> (-1.05%)` | :arrow_down: | | [src/hdf5\_time\_series\_storage.jl](https://app.codecov.io/gh/NREL-Sienna/InfrastructureSystems.jl/pull/364?src=pr&el=tree&filepath=src%2Fhdf5_time_series_storage.jl&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-Sienna#diff-c3JjL2hkZjVfdGltZV9zZXJpZXNfc3RvcmFnZS5qbA==) | `96.46% <88.88%> (-0.25%)` | :arrow_down: | | [src/time\_series\_metadata\_store.jl](https://app.codecov.io/gh/NREL-Sienna/InfrastructureSystems.jl/pull/364?src=pr&el=tree&filepath=src%2Ftime_series_metadata_store.jl&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-Sienna#diff-c3JjL3RpbWVfc2VyaWVzX21ldGFkYXRhX3N0b3JlLmps) | `96.98% <87.50%> (-0.27%)` | :arrow_down: | | [src/utils/sqlite.jl](https://app.codecov.io/gh/NREL-Sienna/InfrastructureSystems.jl/pull/364?src=pr&el=tree&filepath=src%2Futils%2Fsqlite.jl&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-Sienna#diff-c3JjL3V0aWxzL3NxbGl0ZS5qbA==) | `70.96% <50.00%> (-4.04%)` | :arrow_down: |