Skip to content

Support combining multiple output variables.#737

Merged
nhtruong merged 3 commits intoopensearch-project:mainfrom
dblock:tasks-vars
Dec 18, 2024
Merged

Support combining multiple output variables.#737
nhtruong merged 3 commits intoopensearch-project:mainfrom
dblock:tasks-vars

Conversation

@dblock
Copy link
Copy Markdown
Member

@dblock dblock commented Dec 16, 2024

Description

  • Support combining multiple output variables, e.g. task_id: ${task.node}:${task.id}. I ended up not using this and getting the task ID from delete_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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 16, 2024

Changes Analysis

Commit SHA: 43dc5f2
Comparing To SHA: 1b6935f

API Changes

Summary

NO CHANGES

Report

The full API changes report is available at: https://github.com/opensearch-project/opensearch-api-specification/actions/runs/12397608942/artifacts/2338846969

API Coverage

Before After Δ
Covered (%) 606 (59.35 %) 606 (59.35 %) 0 (0 %)
Uncovered (%) 415 (40.65 %) 415 (40.65 %) 0 (0 %)
Unknown 43 43 0

@dblock dblock force-pushed the tasks-vars branch 5 times, most recently from 2990ceb to 3b06ff0 Compare December 16, 2024 18:32
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 16, 2024

Spec Test Coverage Analysis

Total Tested
536 536 (100 %)

@dblock dblock changed the title Support combining multiple output variables. Support combining multiple output variables, added tests for tasks. Dec 16, 2024
@dblock dblock marked this pull request as ready for review December 16, 2024 22:24
@dblock
Copy link
Copy Markdown
Member Author

dblock commented Dec 17, 2024

@nhtruong care to take a look pls?

Comment thread tools/src/tester/types/eval.types.ts Outdated
@@ -87,16 +87,42 @@ export enum Result {
export class OutputReference {
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 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.

Comment thread tools/src/tester/types/eval.types.ts Outdated
Comment on lines +107 to +117
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])
});
}
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.

Should add a comment explaining what this function does because it's not clear what it's trying to achieve.

Comment thread tools/src/tester/types/eval.types.ts Outdated
Comment on lines +119 to +126
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
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.

This needs an explanation as well.

Copy link
Copy Markdown
Member Author

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) => {
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.

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.

Copy link
Copy Markdown
Member Author

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.

Comment thread 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]')
Copy link
Copy Markdown
Contributor

@nhtruong nhtruong Dec 17, 2024

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.

Copy link
Copy Markdown
Member Author

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.

@dblock dblock mentioned this pull request Dec 17, 2024
@dblock dblock marked this pull request as draft December 17, 2024 20:14
@dblock
Copy link
Copy Markdown
Member Author

dblock commented Dec 17, 2024

Converted this to draft, will iterate. Extracted unrelated tests to #746.

@dblock dblock force-pushed the tasks-vars branch 2 times, most recently from f632b2a to c546f0e Compare December 18, 2024 15:06
@dblock dblock marked this pull request as ready for review December 18, 2024 15:07
@dblock dblock requested a review from nhtruong December 18, 2024 15:07
@dblock dblock changed the title Support combining multiple output variables, added tests for tasks. Support combining multiple output variables. Dec 18, 2024
@dblock
Copy link
Copy Markdown
Member Author

dblock commented Dec 18, 2024

Ready to be reviewed again, thanks @nhtruong!

Signed-off-by: dblock <dblock@amazon.com>
Signed-off-by: dblock <dblock@amazon.com>
Signed-off-by: dblock <dblock@amazon.com>
@nhtruong nhtruong merged commit 4231dad into opensearch-project:main Dec 18, 2024
Tokesh pushed a commit to Tokesh/opensearch-api-specification that referenced this pull request Dec 18, 2024
* Support combining multiple output variables.

Signed-off-by: dblock <dblock@amazon.com>
Tokesh pushed a commit to Tokesh/opensearch-api-specification that referenced this pull request Dec 18, 2024
* Support combining multiple output variables.

Signed-off-by: dblock <dblock@amazon.com>
Signed-off-by: Tokesh <tokesh789@gmail.com>
@dblock dblock deleted the tasks-vars branch December 18, 2024 20:16
dblock added a commit that referenced this pull request Dec 19, 2024
* adding missing tests

Signed-off-by: Tokesh <tokesh789@gmail.com>

* fixing validate ci, links, added node failure in specs

Signed-off-by: Tokesh <tokesh789@gmail.com>

* 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 <tokesh789@gmail.com>

* Support combining multiple output variables. (#737)

* Support combining multiple output variables.

Signed-off-by: dblock <dblock@amazon.com>
Signed-off-by: Tokesh <tokesh789@gmail.com>

* hotfix of method in snapshots

Signed-off-by: Tokesh <tokesh789@gmail.com>

* hotfix with snapshot tests

Signed-off-by: Tokesh <tokesh789@gmail.com>

* hotfix race condition

Signed-off-by: Tokesh <tokesh789@gmail.com>

* adding chapter in snapshot tests

Signed-off-by: Tokesh <tokesh789@gmail.com>

* correcting path to repository in snapshot tests

Signed-off-by: Tokesh <tokesh789@gmail.com>

* adding verbose to check ci

Signed-off-by: Tokesh <tokesh789@gmail.com>

* deleting verbose

Signed-off-by: Tokesh <tokesh789@gmail.com>

* added retry to status in snapshots

Signed-off-by: Tokesh <tokesh789@gmail.com>

* added retry to correct place

Signed-off-by: Tokesh <tokesh789@gmail.com>

* adding verbose to check

Signed-off-by: Tokesh <tokesh789@gmail.com>

* renaming to avoid race condition

Signed-off-by: Tokesh <tokesh789@gmail.com>

* refactoring folder organization, adding retries, fixing naming

Signed-off-by: Tokesh <tokesh789@gmail.com>

---------

Signed-off-by: Tokesh <tokesh789@gmail.com>
Signed-off-by: dblock <dblock@amazon.com>
Signed-off-by: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com>
Co-authored-by: Daniel (dB.) Doubrovkine <dblock@amazon.com>
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.

2 participants