Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Shared mutable caching is thread-unsafe, and inheritance context handling introduces cross-verb and sequential-expansion regressions.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Introduces cached MarsLanguage instances and moves inheritance state into request contexts.
Changes:
- Adds process-wide language caching and const interfaces.
- Refactors inheritance handling into
MarsRequestcontexts. - Updates ODB integration and tests for the new API.
mars2grib documentation: ✅ in sync — no impacted files under src/metkit/mars2grib or tests/mars2grib.
File summaries
| File | Description |
|---|---|
src/metkit/mars/MarsLanguage.cc |
Implements caching and context-based expansion. |
src/metkit/mars/MarsLanguage.h |
Exposes cached language API. |
src/metkit/mars/MarsExpansion.cc |
Manages expansion contexts. |
src/metkit/mars/MarsExpansion.h |
Removes owned languages and reset API. |
src/metkit/mars/Type.cc |
Removes inheritance state. |
src/metkit/mars/Type.h |
Updates type state interface. |
src/metkit/mars/TypeEnum.cc |
Removes redundant reset. |
src/metkit/mars/TypeEnum.h |
Removes reset declaration. |
src/metkit/mars/TypeParam.cc |
Removes redundant reset. |
src/metkit/mars/TypeParam.h |
Removes reset declaration. |
src/metkit/odb/OdbDecoder.cc |
Uses cached language. |
src/metkit/odb/OdbMetadataDecoder.cc |
Accepts const language. |
src/metkit/odb/OdbMetadataDecoder.h |
Stores const language reference. |
src/metkit/odb/OdbToRequest.cc |
Uses cached language. |
tests/test_date.cc |
Updates language access. |
tests/test_expand.cc |
Updates language access. |
tests/test_language.cc |
Updates language access. |
tests/test_mars_language.cc |
Updates language access. |
tests/test_mars_language_strict.cc |
Updates language access. |
tests/test_obstype.cc |
Updates language access. |
tests/test_param_axis.cc |
Supplies expansion context. |
tests/test_step.cc |
Updates language access. |
tests/test_time.cc |
Updates language access. |
tests/test_type_levelist.cc |
Updates language access. |
Review details
Suppressed comments (2)
src/metkit/mars/MarsExpansion.cc:42
- This overload also shares one inheritance context across all verbs, changing the prior per-language behavior. Mixed-verb
MarsRequestbatches can inherit parameters from an unrelated verb; select a separate context keyed bylang.verb()for each item.
MarsRequest ctx;
src/metkit/mars/MarsExpansion.cc:56
- This local context is discarded after every call. Previously a
MarsExpansionretained inheritance in its per-verbMarsLanguageuntilreset(), so sequentialexpand(request)calls on the same object inherited from one another. Store per-verb contexts onMarsExpansion(and preserve an explicit way to clear them) so this public overload does not silently lose that behavior.
MarsRequest ctx;
return language(request.verb()).expand(request, ctx, inherit_, strict_);
- Files reviewed: 24/24 changed files
- Comments generated: 4
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #270 +/- ##
===========================================
- Coverage 46.70% 46.63% -0.07%
===========================================
Files 471 471
Lines 21868 21859 -9
Branches 1531 1530 -1
===========================================
- Hits 10214 10195 -19
- Misses 11654 11664 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
The Rust bridge attempts to copy a non-copyable MarsLanguage returned by const reference.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 31/31 changed files
- Comments generated: 0 new
- Review effort level: Balanced
851ca16 to
66cd7d2
Compare
66cd7d2 to
ab14f35
Compare
simondsmart
left a comment
There was a problem hiding this comment.
This looks good. The only thing I would really consider is if the context should have its own type (i.e. there might be something other than the mars request that we want to carry along. And it means that there is no ambiguity as to the order of the arguments)
| std::unique_ptr<MarsRequestWrapper> MarsRequestWrapper::expand(bool inherit, bool strict) const { | ||
| metkit::mars::MarsLanguage lang(request_.verb()); | ||
| auto expanded = lang.expand(request_, inherit, strict); | ||
| metkit::mars::MarsRequest ctx; |
There was a problem hiding this comment.
Should we wrap the context in its own type? Such that the signature becomes self-explanatory (currently it accepts two MarsRequest objects).
Description
MarsLanguage is now immutable and values for inheritance are stored in a separate context (a MarsRequest)
Given its immutability, it can now be cached
Contributor Declaration
By opening this pull request, I affirm the following:
📋 Metkit Documentation 📋
https://sites.ecmwf.int/docs/metkit/pull-requests/PR-270