Skip to content

Fixes #2829 Allow a user supplied list of probable parameter names fo…#2831

Merged
rwmcintosh merged 2 commits intoV13from
2829-allow-a-user-supplied-list-of-probable-parameter-names-for-createexpressionfrom-in-parametervaluescreator
Apr 16, 2026
Merged

Fixes #2829 Allow a user supplied list of probable parameter names fo…#2831
rwmcintosh merged 2 commits intoV13from
2829-allow-a-user-supplied-list-of-probable-parameter-names-for-createexpressionfrom-in-parametervaluescreator

Conversation

@rwmcintosh
Copy link
Copy Markdown
Member

@rwmcintosh rwmcintosh commented Apr 16, 2026

Fixes #2829 allow a user supplied list of probable parameter names for createexpressionfrom in parametervaluescreator

Description

We are using the expression profiles in the project to guess parameter names for a newly created parameter values based on an expression in MoBi.

In R, we want to provide this 'reference' expression from the command line, so this implements an override where it can be referenced in the ParameterValuesCreator

Type of change

Please mark relevant options with an x in the brackets.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires documentation changes (link at least one user or developer documentation issue):
  • Algorithm update - updates algorithm documentation/questions/answers etc.
  • Other (please describe):

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Integration tests
  • Unit tests
  • Manual tests
  • No tests required

Reviewer checklist

Mark everything that needs to be checked before merging the PR.

  • Check if the code is well documented
  • Check if the behavior is what is expected
  • Check if the code is well tested
  • Check if the code is readable and well formatted
  • Additional checks (document below if any)
  • Check if documentation update issue(s) are created if the option This change requires a documentation update above is selected

Screenshots (if appropriate):

Questions (if appropriate):

Summary by CodeRabbit

Release Notes

  • New Features

    • Extended parameter value creation to support molecule-specific expression parameters using reference expression profiles.
  • Tests

    • Added test coverage for expression profile-based parameter value creation, validating formula preservation and path targeting accuracy.

…r CreateExpressionFrom in ParameterValuesCreator
@rwmcintosh rwmcintosh self-assigned this Apr 16, 2026
@rwmcintosh rwmcintosh requested review from Yuri05 and msevestre April 16, 2026 18:01
@rwmcintosh rwmcintosh added this to v13 Apr 16, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 16, 2026

Warning

Rate limit exceeded

@rwmcintosh has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 37 minutes and 10 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 37 minutes and 10 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a5481a50-bc47-468e-a141-f14744d3d87b

📥 Commits

Reviewing files that changed from the base of the PR and between 198ff97 and 3acf719.

📒 Files selected for processing (1)
  • src/OSPSuite.Core/Domain/Services/ParameterValuesCreator.cs
📝 Walkthrough

Walkthrough

The PR extends IParameterValuesCreator with a new overload that creates expression-parameter values for a single molecule using a provided reference expression profile. The implementation refactors expression-creation logic into reusable helper methods while maintaining backward compatibility through additional method overloads.

Changes

Cohort / File(s) Summary
Parameter Values Creator Service
src/OSPSuite.Core/Domain/Services/ParameterValuesCreator.cs
Added new public overload CreateExpressionFrom(IContainer, MoleculeBuilder, ExpressionProfileBuildingBlock) to interface and implementation. Extracted expression-creation logic into private helper methods to enable filtering expression parameters from a provided reference profile and creating ParameterValues for a single molecule across physical containers.
Parameter Values Creator Tests
tests/OSPSuite.Core.Tests/Domain/ParameterValuesCreatorSpecs.cs
Added two new BDD test scenarios: one validating that expression parameter values are correctly created with matching formula/value correspondence and proper path targeting; another verifying empty results when molecule names in the reference profile do not match the input molecule.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A molecule finds its expression, so bright,
With profiles now guiding each parameter's flight,
New overloads blossom, the logic takes shape,
Filters and helpers help none will escape!
Hop-hop, the refactor brings clarity's might! 🌟

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title is truncated/incomplete ('...fo…') and doesn't clearly convey the main change, making it unclear what the pull request accomplishes. Complete and clarify the title to something like 'Add overload to CreateExpressionFrom accepting reference expression profile' to fully describe the implemented change.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The changes implement the requirement from #2829 by adding a new overload to CreateExpressionFrom that accepts an ExpressionProfileBuildingBlock parameter, allowing external expression profiles to guide parameter value creation.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue #2829: the new interface method, implementation overload, helper methods, and corresponding tests all support providing external expression profiles to CreateExpressionFrom.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2829-allow-a-user-supplied-list-of-probable-parameter-names-for-createexpressionfrom-in-parametervaluescreator

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/OSPSuite.Core/Domain/Services/ParameterValuesCreator.cs (1)

105-107: Avoid recomputing expression parameter lookup per container.

expressionParametersFor(molecule, referenceExpressionProfile) is invariant across the loop and currently re-evaluated for each physical container. Compute it once before SelectMany to reduce repeated filtering/allocation.

♻️ Suggested refactor
 public IReadOnlyList<ParameterValue> CreateExpressionFrom(IContainer physicalContainer, MoleculeBuilder molecule, ExpressionProfileBuildingBlock referenceExpressionProfile) =>
-   physicalContainer.GetAllContainersAndSelf<IContainer>(x => x.Mode.Is(ContainerMode.Physical))
-      .SelectMany(container => createExpressionFrom(container, molecule, expressionParametersFor(molecule, referenceExpressionProfile))).ToList();
+   createExpressionFromWithReferenceProfile(physicalContainer, molecule, referenceExpressionProfile);
+
+private IReadOnlyList<ParameterValue> createExpressionFromWithReferenceProfile(
+   IContainer physicalContainer,
+   MoleculeBuilder molecule,
+   ExpressionProfileBuildingBlock referenceExpressionProfile)
+{
+   var expressionParameters = expressionParametersFor(molecule, referenceExpressionProfile);
+   return physicalContainer.GetAllContainersAndSelf<IContainer>(x => x.Mode.Is(ContainerMode.Physical))
+      .SelectMany(container => createExpressionFrom(container, molecule, expressionParameters))
+      .ToList();
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/OSPSuite.Core/Domain/Services/ParameterValuesCreator.cs` around lines 105
- 107, CreateExpressionFrom currently calls expressionParametersFor(molecule,
referenceExpressionProfile) inside the SelectMany for each container causing
repeated work; compute var expressionParams = expressionParametersFor(molecule,
referenceExpressionProfile) once before calling
physicalContainer.GetAllContainersAndSelf<IContainer>(...) and pass that
expressionParams into createExpressionFrom in the SelectMany to reuse the same
lookup across all containers (adjust CreateExpressionFrom to reference
expressionParams instead of calling expressionParametersFor repeatedly).
tests/OSPSuite.Core.Tests/Domain/ParameterValuesCreatorSpecs.cs (1)

347-359: Prefer path/name-based assertions over positional indexing in tests.

These assertions assume deterministic ordering (_parameterValues[0], _parameterValues[1]). Matching by parameter path/name would make the test resilient to harmless ordering changes.

🧪 Optional test hardening
 [Observation]
 public void the_parameter_value_should_have_matching_formula()
 {
-   _parameterValues[0].Formula.IsExplicit().ShouldBeTrue();
-   _parameterValues[1].Formula.ShouldBeNull();
+   var relExp = _parameterValues.Single(x => x.Path.ToString().EndsWith($"|{Constants.Parameters.REL_EXP}"));
+   var someName = _parameterValues.Single(x => x.Path.ToString().EndsWith("|somename"));
+   relExp.Formula.IsExplicit().ShouldBeTrue();
+   someName.Formula.ShouldBeNull();
 }

 [Observation]
 public void the_parameter_value_should_have_matching_value()
 {
-   _parameterValues[0].Value.ShouldBeNull();
-   _parameterValues[1].Value.ShouldBeEqualTo(5.0);
+   var relExp = _parameterValues.Single(x => x.Path.ToString().EndsWith($"|{Constants.Parameters.REL_EXP}"));
+   var someName = _parameterValues.Single(x => x.Path.ToString().EndsWith("|somename"));
+   relExp.Value.ShouldBeNull();
+   someName.Value.ShouldBeEqualTo(5.0);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/OSPSuite.Core.Tests/Domain/ParameterValuesCreatorSpecs.cs` around lines
347 - 359, The tests the_parameter_value_should_have_matching_formula and
the_parameter_value_should_have_matching_value rely on positional indexing into
_parameterValues (e.g. _parameterValues[0], _parameterValues[1]); change them to
locate the correct ParameterValue by a stable identifier (path or name) instead:
query _parameterValues for the item whose Path or Name equals the expected
parameter path/name, then assert on that item's Formula and Value properties
(Formula.IsExplicit()/ShouldBeNull() and Value/ShouldBeEqualTo(5.0)) so ordering
changes won't break the tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/OSPSuite.Core/Domain/Services/ParameterValuesCreator.cs`:
- Around line 58-64: The call to expressionParametersFor(molecule,
referenceExpressionProfile) is being recomputed for each container inside the
SelectMany; compute it once before iterating and reuse it: call
expressionParametersFor(...) into a local variable (e.g., parameters) and then
pass that variable into the SelectMany's createExpressionFrom(...) invocation
over physicalContainer.GetAllContainersAndSelf<IContainer>(x =>
x.Mode.Is(ContainerMode.Physical)) so createExpressionFrom(container, molecule,
parameters) is used instead of re-calling expressionParametersFor for each
container.

---

Nitpick comments:
In `@src/OSPSuite.Core/Domain/Services/ParameterValuesCreator.cs`:
- Around line 105-107: CreateExpressionFrom currently calls
expressionParametersFor(molecule, referenceExpressionProfile) inside the
SelectMany for each container causing repeated work; compute var
expressionParams = expressionParametersFor(molecule, referenceExpressionProfile)
once before calling physicalContainer.GetAllContainersAndSelf<IContainer>(...)
and pass that expressionParams into createExpressionFrom in the SelectMany to
reuse the same lookup across all containers (adjust CreateExpressionFrom to
reference expressionParams instead of calling expressionParametersFor
repeatedly).

In `@tests/OSPSuite.Core.Tests/Domain/ParameterValuesCreatorSpecs.cs`:
- Around line 347-359: The tests
the_parameter_value_should_have_matching_formula and
the_parameter_value_should_have_matching_value rely on positional indexing into
_parameterValues (e.g. _parameterValues[0], _parameterValues[1]); change them to
locate the correct ParameterValue by a stable identifier (path or name) instead:
query _parameterValues for the item whose Path or Name equals the expected
parameter path/name, then assert on that item's Formula and Value properties
(Formula.IsExplicit()/ShouldBeNull() and Value/ShouldBeEqualTo(5.0)) so ordering
changes won't break the tests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f5ce0d38-7a6b-4a03-9f4f-f0d37a4a324f

📥 Commits

Reviewing files that changed from the base of the PR and between 34d1ede and 198ff97.

📒 Files selected for processing (2)
  • src/OSPSuite.Core/Domain/Services/ParameterValuesCreator.cs
  • tests/OSPSuite.Core.Tests/Domain/ParameterValuesCreatorSpecs.cs

Comment thread src/OSPSuite.Core/Domain/Services/ParameterValuesCreator.cs
@rwmcintosh rwmcintosh merged commit 5bc3cd0 into V13 Apr 16, 2026
2 checks passed
@rwmcintosh rwmcintosh deleted the 2829-allow-a-user-supplied-list-of-probable-parameter-names-for-createexpressionfrom-in-parametervaluescreator branch April 16, 2026 20:25
@github-project-automation github-project-automation bot moved this to Done in v13 Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants