-
Notifications
You must be signed in to change notification settings - Fork 61
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
Support combining multiple output variables. #737
Conversation
Changes AnalysisCommit SHA: 43dc5f2 API ChangesSummaryNO CHANGES ReportThe full API changes report is available at: https://github.com/opensearch-project/opensearch-api-specification/actions/runs/12397608942/artifacts/2338846969 API Coverage
|
2990ceb
to
3b06ff0
Compare
Spec Test Coverage Analysis
|
@nhtruong care to take a look pls? |
tools/src/tester/types/eval.types.ts
Outdated
@@ -87,16 +87,42 @@ export enum Result { | |||
export class OutputReference { |
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 missed this when this was first added but this file is meant to hold type definitions only. This class should be in its own file.
tools/src/tester/types/eval.types.ts
Outdated
static replace(str: string, callback: (chapter_id: any, variable: any) => string): any { | ||
// preserve type if 1 value is returned | ||
let full_match = str.match(/^\$\{([^}]+)\}$/) | ||
if (full_match) { | ||
const spl = this.#split(full_match[1], '.', 2) | ||
return callback(spl[0], spl[1]) | ||
} else return str.replace(/\$\{([^}]+)\}/g, (_, k) => { | ||
const spl = this.#split(k, '.', 2) | ||
return callback(spl[0], spl[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.
Should add a comment explaining what this function does because it's not clear what it's trying to achieve.
tools/src/tester/types/eval.types.ts
Outdated
static #split(str: any, delim: string, count: number): string[] { | ||
if (str === undefined) return [str] | ||
if (count <= 0) return [str] | ||
const parts = str.split(delim) | ||
if (parts.length <= count) return parts | ||
const result = parts.slice(0, count - 1) | ||
result.push(parts.slice(count - 1).join(delim)) | ||
return result |
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 needs an explanation as well.
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.
Moved to helpers.
} else { | ||
return str | ||
} | ||
return OutputReference.replace(str, (chapter_id, output_name) => { |
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 this is the only place the replace
function is used, then having a generic replace function that can handle any callback is a bit over-engineered, IMO.
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 it's best we keep the parsing regex values/logic in one place so it doesn't leak into the usage of it.
tools/tests/types/eval.types.test.ts
Outdated
expect(OutputReference.replace('string', f)).toEqual('string') | ||
expect(OutputReference.replace('${k.v}', f)).toEqual('[k:v]') | ||
expect(OutputReference.replace('${k.value}', f)).toEqual('[k:value]') | ||
expect(OutputReference.replace('${k.v.m}', f)).toEqual('[k:v.m]') |
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 was on board until the last example. It's not clearly why k
is treated differently from v
and m
and how the callback f
caused such an output.
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.
Our output variables are split with namespace.xyz where namespace=payload and is meaningful, but the rest of it is not and can be anything, including something that contains periods. That's basically what this is testing.
|
f632b2a
to
c546f0e
Compare
Ready to be reviewed again, thanks @nhtruong! |
Signed-off-by: dblock <[email protected]>
Signed-off-by: dblock <[email protected]>
Signed-off-by: dblock <[email protected]>
* Support combining multiple output variables. Signed-off-by: dblock <[email protected]>
* Support combining multiple output variables. Signed-off-by: dblock <[email protected]> Signed-off-by: Tokesh <[email protected]>
* adding missing tests Signed-off-by: Tokesh <[email protected]> * fixing validate ci, links, added node failure in specs Signed-off-by: Tokesh <[email protected]> * adding node failures to changelog, fixing path in specs of update by query and small fix in response of query group tests Signed-off-by: Tokesh <[email protected]> * Support combining multiple output variables. (#737) * Support combining multiple output variables. Signed-off-by: dblock <[email protected]> Signed-off-by: Tokesh <[email protected]> * hotfix of method in snapshots Signed-off-by: Tokesh <[email protected]> * hotfix with snapshot tests Signed-off-by: Tokesh <[email protected]> * hotfix race condition Signed-off-by: Tokesh <[email protected]> * adding chapter in snapshot tests Signed-off-by: Tokesh <[email protected]> * correcting path to repository in snapshot tests Signed-off-by: Tokesh <[email protected]> * adding verbose to check ci Signed-off-by: Tokesh <[email protected]> * deleting verbose Signed-off-by: Tokesh <[email protected]> * added retry to status in snapshots Signed-off-by: Tokesh <[email protected]> * added retry to correct place Signed-off-by: Tokesh <[email protected]> * adding verbose to check Signed-off-by: Tokesh <[email protected]> * renaming to avoid race condition Signed-off-by: Tokesh <[email protected]> * refactoring folder organization, adding retries, fixing naming Signed-off-by: Tokesh <[email protected]> --------- Signed-off-by: Tokesh <[email protected]> Signed-off-by: dblock <[email protected]> Signed-off-by: Niyazbek Torekeldi <[email protected]> Co-authored-by: Daniel (dB.) Doubrovkine <[email protected]>
Description
task_id: ${task.node}:${task.id}
. I ended up not using this and getting the task ID fromdelete_by_query
, but it's a useful feature IMO.Issues Resolved
Part of #663.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.