Skip to content

small bug fixes for PSI integration #585

Merged
jd-lara merged 23 commits into
IS4from
claude/youthful-bell-xxgcvp
Jun 11, 2026
Merged

small bug fixes for PSI integration #585
jd-lara merged 23 commits into
IS4from
claude/youthful-bell-xxgcvp

Conversation

@jd-lara

@jd-lara jd-lara commented Jun 10, 2026

Copy link
Copy Markdown
Member

No description provided.

claude and others added 9 commits June 10, 2026 04:23
Deep review of the IS4 branch vs main (correctness, hygiene, performance)
with a focused analysis of the units management layer. Findings are
prioritized task cards (P1-P3) with verified evidence, acceptance criteria,
decision points, and guardrails for an implementation session.

https://claude.ai/code/session_01HkFivicrR478NZxtSueMSj
@jd-lara jd-lara requested review from Copilot and luke-kiernan June 10, 2026 17:57
@jd-lara jd-lara changed the base branch from main to IS4 June 10, 2026 17:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens several IS4 behaviors that affect PSI/PSY integration by replacing cryptic MethodError/promotion failures with actionable ArgumentErrors, clarifying units/scaling-factor contracts, and adding regression tests around time-series-backed cost curves and relative-units arithmetic.

Changes:

  • Enforce/document the 2-argument scaling_factor_multiplier(owner, units) contract (typed units::AbstractUnitSystem) and surface a clear ArgumentError for legacy 1-arg multipliers.
  • Improve relative-units safety and UX: reject double-tagging, throw clear errors on cross-unit and tagged-vs-untagged operations, add hash consistent with ==, and add an unsupported-unit conversion fallback.
  • Fix/clarify cost-curve time-series key resolution + serialization robustness, and add tests covering round-trips and legacy unit-system decoding.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/test_time_series.jl Adds regression tests for 2-arg scaling-factor multiplier contract + typed units kwarg behavior
test/test_supplemental_attributes.jl Adds test for get_attr_value(::TestSupplemental)
test/test_relative_units.jl Adds broader regression coverage for new relative-units error behaviors, hashing, and unsupported unit conversions
test/test_generate_structs.jl Adds synthetic-descriptor test to exercise needs_conversion codegen/export behavior
test/test_cost_functions.jl Adds tests for get_time_series_key behavior matrix, fallback errors, serialization round-trips, legacy unit decoding, and zero unit preservation
test/test_convexity_checks.jl Adds tests ensuring is_valid_data rejects time-series-backed function data/curves with ArgumentError
test/InfrastructureSystemsTests.jl Removes unused DataFramesMeta import from test runner
src/utils/test.jl Fixes TestSupplemental accessor (introduces get_attr_value)
src/utils/generate_structs.jl Updates needs-conversion getter docstring; clarifies _unitful export gate rationale
src/time_series_value_curve.jl Refactors repeated TS function-data key resolution into _resolve_function_data_key + adds perf note to docstrings
src/time_series_interface.jl Documents/annotates units::AbstractUnitSystem kwarg across accessors; rethrows legacy multiplier arity mismatch as ArgumentError
src/relative_units.jl Adds double-tagging guards, clearer cross-unit/tagged-vs-untagged errors, hash, _cost_coeff_ratio fallback, and doc tweaks
src/production_variable_cost_curve.jl Adds get_time_series_key fallback + FuelCurve key disambiguation; preserves unit system in zero; normalizes/validates fuel_cost deserialize
src/outputs.jl Fixes stub error message to reference write_outputs
src/InfrastructureSystems.jl Clarifies export policy exception for get_value/set_value generics
src/function_data/convexity_checks.jl Makes is_valid_data on TS-backed data throw ArgumentError instead of MethodError
.claude/IS4_REVIEW.md Adds an implementation handoff/review task file
.claude/claude.md Updates repo architectural notes and documents the IS4 units/time-series contracts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/InfrastructureSystemsTests.jl
Comment thread test/test_time_series.jl Outdated
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.70588% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.85%. Comparing base (7558864) to head (04aa9fc).
⚠️ Report is 1 commits behind head on IS4.

Files with missing lines Patch % Lines
src/relative_units.jl 80.64% 6 Missing ⚠️
src/utils/print_pt.jl 78.26% 5 Missing ⚠️
src/outputs.jl 0.00% 1 Missing ⚠️
src/serialization.jl 87.50% 1 Missing ⚠️
src/utils/generate_structs.jl 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              IS4     #585      +/-   ##
==========================================
+ Coverage   83.51%   83.85%   +0.34%     
==========================================
  Files          74       73       -1     
  Lines        6266     6301      +35     
==========================================
+ Hits         5233     5284      +51     
+ Misses       1033     1017      -16     
Flag Coverage Δ
unittests 83.85% <89.70%> (+0.34%) ⬆️

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

Files with missing lines Coverage Δ
src/InfrastructureSystems.jl 44.44% <ø> (ø)
src/Optimization/enums.jl 100.00% <100.00%> (+100.00%) ⬆️
src/Optimization/optimization_container_types.jl 28.57% <100.00%> (+14.28%) ⬆️
src/Simulation/enums.jl 100.00% <100.00%> (+100.00%) ⬆️
src/components.jl 85.71% <100.00%> (-0.10%) ⬇️
src/function_data/convexity_checks.jl 82.64% <100.00%> (+0.59%) ⬆️
src/function_data/time_series_function_data.jl 81.81% <100.00%> (ø)
src/production_variable_cost_curve.jl 85.88% <100.00%> (+8.79%) ⬆️
src/time_series_interface.jl 96.38% <100.00%> (+0.13%) ⬆️
src/time_series_structs.jl 93.10% <ø> (ø)
... and 9 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@luke-kiernan luke-kiernan left a comment

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.

Lots going on and rather confusing. Would be helpful to see the bugs or issues that each of the changes was made in response to.

Comment thread src/utils/generate_structs.jl Outdated
Comment thread src/utils/print_pt.jl

comps = get_components(component_type, components)
data = Array{Any, 2}(undef, length(comps), length(column_labels))

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.

I had to read this like 3 times to grasp the intention here. 2 problems: first, the abundance of edge cases (are these actually exercised?). Second, readability: soooo many layers of unresolved function calls and variable assignments.

Comment thread src/production_variable_cost_curve.jl Outdated
# goes through the kwarg constructor with every data key splatted, so a field
# added to the struct cannot be silently dropped: an unknown key fails loudly
# here (no `_deserialize_pvcc_field` method) or at the constructor.
_deserialize_pvcc_field(::Val{:value_curve}, raw::AbstractDict) =

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.

pvcc...oh, Point Value Cost Curve. Probably worth specifying that in a comment.

),
)

function deserialize(::Type{FuelCurve}, data::Dict)

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.

What's the problem with the previous implementation here?

Comment thread src/serialization.jl
# This has several limitations and is only a workaround for PSY.Reserve subtypes.
# - each parameter must be in _module
# - does not support nested parametrics.
# Reserves should be fixed and then we can remove this hack.

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.

Explain please.

@jd-lara jd-lara merged commit ba0c194 into IS4 Jun 11, 2026
8 of 10 checks passed
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