-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat(collection): add concat #748
Conversation
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 added some suggestions for the documentation. Also some nitpicky comments, some things to consider (and perhaps address in a separate PR).
@@ -0,0 +1,64 @@ | |||
|
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.
As mentioned in another PR, instead of adding newlines we should put that in the compogen
template. This is a workaround and contributors (myself included) don't need to know about this.
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 remove -
in compogen when there is extra content
|
||
## Example Recipes | ||
|
||
In this example, we are combining two arrays of strings using the `union` and `concat` components. |
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.
nit
In this example, we are combining two arrays of strings using the `union` and `concat` components. | |
### Combine 2 arrays using `TASK_UNION` and `TASK_CONCAT` | |
``` | ||
|
||
|
||
In this example, we are creating an object with keys `type` and `text` from a string. |
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.
nit
In this example, we are creating an object with keys `type` and `text` from a string. | |
### Use `TASK_ASSIGN` to create an object with `type` and `text` keys | |
|
||
In this example, we are combining two arrays of strings using the `union` and `concat` components. | ||
```yaml | ||
variable: |
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.
How about documenting and providing examples with a comment here? E.g.
# This pipeline combines 2 arrays of strings
# Examples:
# ["foo", "bar"], ["zot", "bat"] -> ["foo", "bar", "zot", "bat"], []
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 added these 2 in corresponding components.
# This component concatenates two arrays of strings.
# Examples:
# ["foo", "bar"], ["zot", "bat"] -> ["foo", "bar", "zot", "bat"]
# This component combines two arrays of strings in a union, ensuring that no duplicates are included.
# Examples:
# ["foo", "bar"], ["foo", "bat"] -> ["foo", "bar", "bat"]
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 meant documented the input/output of the pipelines, not the individual components. But it's fine.
@@ -316,5 +316,62 @@ | |||
"title": "Output", | |||
"type": "object" | |||
} | |||
}, | |||
"TASK_CONCAT": { | |||
"instillShortDescription": "Concat the arrays. i.e. `[1, 2] + [3, 4] = [1, 2, 3, 4]`", |
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.
"instillShortDescription": "Concat the arrays. i.e. `[1, 2] + [3, 4] = [1, 2, 3, 4]`", | |
"instillShortDescription": "Concatenate the arrays. i.e. `[1, 2] + [3, 4] = [1, 2, 3, 4]`", |
"instillUIOrder": 0, | ||
"properties": { | ||
"arrays": { | ||
"description": "Specify the arrays you want to concat.", |
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.
nit: this should be a description, not an order
"description": "Specify the arrays you want to concat.", | |
"description": "The arrays to be concatenated.", |
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.
🗣️ not crucial for this PR, just opening a discussion
We need to decide about the periods for the task tables. 2 options:
- Always finish with a period
- Don't finish with a period by default, only do so when we have > 1 sentence in the description (separated by a period).
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.
Always finish with a period
Now, I follow this, which @GeorgeWilliamStrong mentioned it somewhere.
"instillUIOrder": 0, | ||
"properties": { | ||
"array": { | ||
"description": "The union set.", |
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 is a typo, right?
"description": "The union set.", | |
"description": "The concatenated arrays.", |
@@ -82,6 +85,19 @@ func (c *component) CreateExecution(x base.ComponentExecution) (base.IExecution, | |||
return e, nil | |||
} | |||
|
|||
func (e *execution) concat(in *structpb.Struct) (*structpb.Struct, error) { |
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.
nit: unit-testing this component would be great 🙏
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.
It’s odd that compongen
generates empty lines at the end of MDX files, but the pre-commit action removes them. I’ve adjusted the pre-commit hook to fix this behavior so the end-of-line characters in MDX files are no longer automatically removed. We can decide whether we should keep empty lines at the end of MDX files later.
It's a compromise between the readability of the template and the auto-generated file. Since the template ends with an optional section, this will produce a blank line by default (empty section). My opinion is that, while we should aim to make README.mdx as pretty as possible, the shape of autogenerated files isn't important as long as their rendered version (or e.g. the API of the package for auto-generated code) is neat. When in conflict we should prioritise rendered document > template > raw MDX. |
I can think of 2 simpler ways to define the test data:
|
Because - we need to concat 2 arrays This commit - add concat task in collection - add recipe samples --------- Co-authored-by: Chang, Hui-Tang <[email protected]>
🤖 I have created a release *beep* *boop* --- ## [0.44.0-beta](v0.43.2-beta...v0.44.0-beta) (2024-10-22) ### Features * **collection:** add concat ([#748](#748)) ([04d1467](04d1467)) * **compogen:** improve Title Case capitalization ([#757](#757)) ([f956ead](f956ead)) * **component:** update documentation URL to component ID ([#749](#749)) ([d4083c2](d4083c2)) * **instillmodel:** implement instill model embedding ([#727](#727)) ([17d88bc](17d88bc)) * **run:** run logging data list by requester API ([#730](#730)) ([e1e844b](e1e844b)) * **slack:** enable OAuth 2.0 integration ([#758](#758)) ([8043dc5](8043dc5)) * standardize the tag naming convention ([#767](#767)) ([fd0500f](fd0500f)) * **web:** refactor web operator ([#753](#753)) ([700805f](700805f)) ### Bug Fixes * **groq:** use credential-supported model in example ([#752](#752)) ([fc90435](fc90435)) * **run:** not return minio error in list pipeline run ([#744](#744)) ([4d0afa1](4d0afa1)) * **whatsapp:** fix dir name ([#763](#763)) ([029aef9](029aef9)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
🤖 I have created a release *beep* *boop* --- ## [0.44.0-beta](v0.43.2-beta...v0.44.0-beta) (2024-10-22) ### Features * **collection:** add concat ([#748](#748)) ([04d1467](04d1467)) * **compogen:** improve Title Case capitalization ([#757](#757)) ([f956ead](f956ead)) * **component:** update documentation URL to component ID ([#749](#749)) ([d4083c2](d4083c2)) * **instillmodel:** implement instill model embedding ([#727](#727)) ([17d88bc](17d88bc)) * **run:** run logging data list by requester API ([#730](#730)) ([e1e844b](e1e844b)) * **slack:** enable OAuth 2.0 integration ([#758](#758)) ([8043dc5](8043dc5)) * standardize the tag naming convention ([#767](#767)) ([fd0500f](fd0500f)) * **web:** refactor web operator ([#753](#753)) ([700805f](700805f)) ### Bug Fixes * **groq:** use credential-supported model in example ([#752](#752)) ([fc90435](fc90435)) * **run:** not return minio error in list pipeline run ([#744](#744)) ([4d0afa1](4d0afa1)) * **whatsapp:** fix dir name ([#763](#763)) ([029aef9](029aef9)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Because
This commit