-
Notifications
You must be signed in to change notification settings - Fork 9
Feature/inheritance #85
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
base: develop
Are you sure you want to change the base?
Conversation
… + expected result
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #85 +/- ##
===========================================
+ Coverage 65.90% 66.95% +1.04%
===========================================
Files 122 123 +1
Lines 6983 7244 +261
Branches 667 707 +40
===========================================
+ Hits 4602 4850 +248
- Misses 2381 2394 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/metkit/mars/ContextRule.h
Outdated
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
ContextRule::ContextRule(const std::string& k) : key_(k) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its confusing that ContextRule is defined in Type.h
and the ContextRule CTor in ContextRule.h
src/metkit/mars/ContextRule.h
Outdated
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
class Include : public ContextRule { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add one sentence explaining what this class represents.
src/metkit/mars/ContextRule.h
Outdated
std::set<std::string> vals_; | ||
}; | ||
|
||
class Exclude : public ContextRule { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add one sentence explaining what this class represents.
src/metkit/mars/ContextRule.h
Outdated
std::set<std::string> vals_; | ||
}; | ||
|
||
class Undef : public ContextRule { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add one sentence explaining what this class represents.
src/metkit/mars/ContextRule.h
Outdated
void print(std::ostream& out) const override { out << "Undef[key=" << key_ << "]"; } | ||
}; | ||
|
||
class Def : public ContextRule { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add one sentence explaining what this class represents.
src/metkit/mars/MarsExpansion.cc
Outdated
for (const auto& request : requests) { | ||
auto& lang = language(request, request.verb()); | ||
result.emplace_back(lang.expand(request, request, inherit_, strict_)); | ||
for (size_t i = 0; i < requests.size(); i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I am not mistaken this could still be a range based for loop
@@ -183,7 +193,8 @@ std::string MarsLanguage::bestMatch(const MarsExpandContext& ctx, const std::str | |||
size_t score = (fullMatch ? name.length() : 1); | |||
std::vector<std::string> best; | |||
|
|||
static bool strict = eckit::Resource<bool>("$METKIT_LANGUAGE_STRICT_MODE", false); | |||
|
|||
static bool strict = eckit::Resource<bool>("$METKIT_LANGUAGE_STRICT_MODE", true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this have downstream impact? If not, why not remove the whole option and always be strict?
tests/test_expand.cc
Outdated
// { | ||
// const char* text = "retrieve,class=d1,dataset=extreme-dt,date=-1"; | ||
// ExpectedVals expected{{"class", {"d1"}}, {"dataset", {"extremes-dt"}}, | ||
// {"expver", {"0001"}}, {"levelist", {"1000", "850", "700", "500", "400", "300"}}, | ||
// {"levtype", {"pl"}}, {"param", {"129"}}, | ||
// {"step", {"0"}}, {"stream", {"oper"}}, | ||
// {"time", {"1200"}}, {"type", {"an"}}}; | ||
// expand(text, "retrieve", expected, {-1}); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix or remove
tests/CMakeLists.txt
Outdated
@@ -34,6 +34,8 @@ ecbuild_get_test_multidata( TARGET metkit_get_odb_data | |||
# TEST_DEPENDS grib_get_data | |||
# ) | |||
|
|||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/expand" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be a softlink instead. Use
add_custom_command(soft_link_expand_test_data ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/expand")
src/metkit/mars/MarsLanguage.cc
Outdated
// for (std::vector<std::string>::const_iterator k = params.begin(); k != params.end(); ++k) { | ||
// type(*k)->finalise(ctx, result, strict); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commented out code
src/metkit/mars/ContextRule.h
Outdated
@@ -0,0 +1,105 @@ | |||
/* | |||
* (C) Copyright 1996- ECMWF. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be (C) Copyright 2025- ECMWF.
tests/test_context.cc
Outdated
@@ -0,0 +1,57 @@ | |||
/* | |||
* (C) Copyright 1996- ECMWF. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be 2025
EXPECT_EQUAL(e.second.size(), vv.size()); | ||
ExpectedRequest() = default; | ||
|
||
ExpectedRequest(std::string vrb, ExpectedVals vv, std::vector<std::string> dd) : verb(vrb), vals(vv), dates(dd) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it is just test code but all 3 arguments should be moved
- [kwbc] | ||
- [none] | ||
- [hrm] | ||
- [ifs, IFS with no ocean model] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason 'IFS' and the other all capital letter aliases has been removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We aim to handle all requests on a case-insensitive basis, so the code is already handling the enum values disregarding their case.
share/metkit/language.yaml
Outdated
|
||
# verify | ||
# refdate | ||
|
||
hdate: | ||
category: data | ||
multiple: true | ||
type: integer | ||
# type: integer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be removed
@@ -13,3 +13,4 @@ wind: | |||
# list of tables used by ParamID normalisation to limit the param-table expansion to wind, ocean and reanalysis | |||
drop-tables: [140,150,151,160,162,170,180,190] | |||
full-table-dropping: true | |||
ml-params-single-level: [22, 127, 128, 129, 152] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if I understand the purpose but from MarsRequest::count I transcribed that this list of parameters can be used in the presence of a levelist
keyword but still result in only a single field. Isn't that a violation of our mars tree design?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, you are right. This violates the assumption that the hypercube is a dense set.
There are a few parameters that are only encoded at levelist=1 for levtype=ml (which is even more odd, since levelist=1 is in the stratosphere).
We suggested encoding those parameters as levtype=sfc or sol, but we have been told that users need to retrieve those parameters together with the 3D of the atmosphere... and we cannot mix different levtypes in a single request.
src/metkit/mars/MarsRequest.cc
Outdated
size_t levels = 1; | ||
size_t params = 0; | ||
size_t paramsSingleLevel = 0; | ||
|
||
for (std::list<Parameter>::const_iterator i = params_.begin(); i != params_.end(); ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you rework this anyway you can turn this into a range base do loop as well
src/metkit/mars/MarsRequest.cc
Outdated
@@ -326,8 +327,47 @@ void MarsRequest::getParams(std::vector<std::string>& p) const { | |||
|
|||
size_t MarsRequest::count() const { | |||
size_t result = 1; | |||
|
|||
std::set<std::string> paramidsSingleLevel = ParamID::getMlParamsSingleLevel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be const and a reference.
src/metkit/mars/MarsRequest.cc
Outdated
if (paramidsSingleLevel.find(v) != paramidsSingleLevel.end()) { | ||
paramsSingleLevel++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use paramsSingleLevel += parmaIdsSingleLevel.count(v);
src/metkit/mars/MarsRequest.cc
Outdated
} | ||
else { | ||
if (i->name() == "param") { | ||
for (auto v : i->values()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const auto&
This PR introduces: