Skip to content
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

Merged
merged 8 commits into from
Oct 18, 2024
Merged

feat(collection): add concat #748

merged 8 commits into from
Oct 18, 2024

Conversation

chuang8511
Copy link
Member

Because

  • we need to concat 2 arrays

This commit

  • add concat task in collection
  • add recipe samples

Copy link

linear bot commented Oct 16, 2024

Copy link
Collaborator

@jvallesm jvallesm left a 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 @@

Copy link
Collaborator

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.

Copy link
Member Author

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
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:
Copy link
Collaborator

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"], []

Copy link
Member Author

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"]

Copy link
Collaborator

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]`",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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.",
Copy link
Collaborator

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

Suggested change
"description": "Specify the arrays you want to concat.",
"description": "The arrays to be concatenated.",

Copy link
Collaborator

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

cc @GeorgeWilliamStrong

Copy link
Member Author

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.",
Copy link
Collaborator

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?

Suggested change
"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) {
Copy link
Collaborator

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 🙏

@chuang8511
Copy link
Member Author

@jvallesm
Thanks for reviewing. I fixed all and made a few adjustments.
Please take a look.

And, I am curious about if there is a more elegant way to init the test data in your experience.

I felt it is not so easy to create the test data.

Copy link
Member

@donch1989 donch1989 left a 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.

@donch1989 donch1989 merged commit 04d1467 into main Oct 18, 2024
12 checks passed
@donch1989 donch1989 deleted the chunhao/ins-6334-concat branch October 18, 2024 04:14
@jvallesm
Copy link
Collaborator

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.

@jvallesm
Copy link
Collaborator

And, I am curious about if there is a more elegant way to init the test data in your experience.

I felt it is not so easy to create the test data.

I can think of 2 simpler ways to define the test data:

  • As Go types ([]string{"c", "d"}, map[string]any{"array": want}). NewValue takes any type and will do the conversion for you.
  • You can also define the test data in JSON and use protojson to unmarshal it.

joremysh pushed a commit that referenced this pull request Oct 18, 2024
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]>
donch1989 pushed a commit that referenced this pull request Oct 22, 2024
🤖 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).
jvallesm pushed a commit that referenced this pull request Oct 29, 2024
🤖 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants