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

[OPIK-121] Allow multiline in dataset description #339

Merged

Conversation

thiagohora
Copy link
Contributor

Details

Allow multiline in the dataset description

Issues

OPIK-121

Testing

Add dataset with multiline description
Add project with multiline description

@thiagohora thiagohora self-assigned this Oct 3, 2024
@thiagohora thiagohora requested a review from a team as a code owner October 3, 2024 16:15
Copy link
Collaborator

@andrescrz andrescrz left a comment

Choose a reason for hiding this comment

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

This started as a quick validation at the beginning of the project, but I believe the regex is starting to get out of hand and this bug is a proof of it. Also, because this already has many references in the code, so we should make sure it's endurable.

I think it's time to create a validation annotation, like the other ones that you've already created in the service.

It's trivial to check if null or not black with a validator class.

You could also extend it to work on collections, but no need to do it now.

You only need to be careful with our related PODAM utils. Basically, you need to make sure that:

  1. Fields with the new annotation are properly randomly generated.
  2. You should consider cleaning up the current PODAM utils for the Pattern annotation.

@thiagohora
Copy link
Contributor Author

thiagohora commented Oct 4, 2024

This started as a quick validation at the beginning of the project, but I believe the regex is starting to get out of hand and this bug is a proof of it. Also, because this already has many references in the code, so we should make sure it's endurable.

I think it's time to create a validation annotation, like the other ones that you've already created in the service.

It's trivial to check if null or not black with a validator class.

You could also extend it to work on collections, but no need to do it now.

You only need to be careful with our related PODAM utils. Basically, you need to make sure that:

  1. Fields with the new annotation are properly randomly generated.
  2. You should consider cleaning up the current PODAM utils for the Pattern annotation.

I understand your concern, and it's valid. However, there is a downside to using custom annotations, and the issue is that custom annotations are not documented in OpenApi docs. I added tests to all scenarios, and hopefully, those should be enough to give us confidence. Regarding documenting it, I can do it. I also usually use some tools to explain it.

https://zzzcode.ai/regex/explain?id=94d92613-3632-48e6-b80a-60ddfa6469b3

https://regexper.com/#%5E%5Cs*%28%5CS.*%5CS%7C%5CS%29%5Cs*%24

@thiagohora thiagohora requested a review from andrescrz October 4, 2024 09:32
@andrescrz
Copy link
Collaborator

This started as a quick validation at the beginning of the project, but I believe the regex is starting to get out of hand and this bug is a proof of it. Also, because this already has many references in the code, so we should make sure it's endurable.
I think it's time to create a validation annotation, like the other ones that you've already created in the service.
It's trivial to check if null or not black with a validator class.
You could also extend it to work on collections, but no need to do it now.
You only need to be careful with our related PODAM utils. Basically, you need to make sure that:

  1. Fields with the new annotation are properly randomly generated.
  2. You should consider cleaning up the current PODAM utils for the Pattern annotation.

I understand your concern, and it's valid. However, there is a downside to using custom annotations, and the issue is that custom annotations are not documented in OpenApi docs. I added tests to all scenarios, and hopefully, those should be enough to give us confidence. Regarding documenting it, I can do it. I also usually use some tools to explain it.

https://zzzcode.ai/regex/explain?id=94d92613-3632-48e6-b80a-60ddfa6469b3

https://regexper.com/#%5E%5Cs*%28%5CS.*%5CS%7C%5CS%29%5Cs*%24

For pattern validation annotation, the OpenAPI docs aren't very descriptive either. They just show the raw regex string^(?!\s*$).+ which isn't very significative either.

If this is a concern, a quick solution is just to add a @Schema(description tag to the fields that apply, and that's not different for Pattern or the new annotation.

As longer term solution, maybe there's a way to integrate the custom annotation with swagger.

@thiagohora
Copy link
Contributor Author

This started as a quick validation at the beginning of the project, but I believe the regex is starting to get out of hand and this bug is a proof of it. Also, because this already has many references in the code, so we should make sure it's endurable.
I think it's time to create a validation annotation, like the other ones that you've already created in the service.
It's trivial to check if null or not black with a validator class.
You could also extend it to work on collections, but no need to do it now.
You only need to be careful with our related PODAM utils. Basically, you need to make sure that:

  1. Fields with the new annotation are properly randomly generated.
  2. You should consider cleaning up the current PODAM utils for the Pattern annotation.

I understand your concern, and it's valid. However, there is a downside to using custom annotations, and the issue is that custom annotations are not documented in OpenApi docs. I added tests to all scenarios, and hopefully, those should be enough to give us confidence. Regarding documenting it, I can do it. I also usually use some tools to explain it.
https://zzzcode.ai/regex/explain?id=94d92613-3632-48e6-b80a-60ddfa6469b3
https://regexper.com/#%5E%5Cs*%28%5CS.*%5CS%7C%5CS%29%5Cs*%24

For pattern validation annotation, the OpenAPI docs aren't very descriptive either. They just show the raw regex string^(?!\s*$).+ which isn't very significative either.

If this is a concern, a quick solution is just to add a @Schema(description tag to the fields that apply, and that's not different for Pattern or the new annotation.

As longer term solution, maybe there's a way to integrate the custom annotation with swagger.

To me, the issue is not just description but code generation. The OpenApi code generator supports patterns, which allow the code to be validated on the client side. It's not a must, but I believe it's a good property to have. I think this is a good reason to keep it, but if want I can remove it. I just think with the regex explainers, it's pretty easy to understand it

@andrescrz
Copy link
Collaborator

This started as a quick validation at the beginning of the project, but I believe the regex is starting to get out of hand and this bug is a proof of it. Also, because this already has many references in the code, so we should make sure it's endurable.
I think it's time to create a validation annotation, like the other ones that you've already created in the service.
It's trivial to check if null or not black with a validator class.
You could also extend it to work on collections, but no need to do it now.
You only need to be careful with our related PODAM utils. Basically, you need to make sure that:

  1. Fields with the new annotation are properly randomly generated.
  2. You should consider cleaning up the current PODAM utils for the Pattern annotation.

I understand your concern, and it's valid. However, there is a downside to using custom annotations, and the issue is that custom annotations are not documented in OpenApi docs. I added tests to all scenarios, and hopefully, those should be enough to give us confidence. Regarding documenting it, I can do it. I also usually use some tools to explain it.
https://zzzcode.ai/regex/explain?id=94d92613-3632-48e6-b80a-60ddfa6469b3
https://regexper.com/#%5E%5Cs*%28%5CS.*%5CS%7C%5CS%29%5Cs*%24

For pattern validation annotation, the OpenAPI docs aren't very descriptive either. They just show the raw regex string^(?!\s*$).+ which isn't very significative either.
If this is a concern, a quick solution is just to add a @Schema(description tag to the fields that apply, and that's not different for Pattern or the new annotation.
As longer term solution, maybe there's a way to integrate the custom annotation with swagger.

To me, the issue is not just description but code generation. The OpenApi code generator supports patterns, which allow the code to be validated on the client side. It's not a must, but I believe it's a good property to have. I think this is a good reason to keep it, but if want I can remove it. I just think with the regex explainers, it's pretty easy to understand it

It's a fair point, but I don't think those client side validations are crucial. At least not at the expense of other problems in the backend. I'd like to double check if the Fern generation of a Python client really considers this.

Anyway, I'm going to take a look at the second revision.

Copy link
Collaborator

@andrescrz andrescrz left a comment

Choose a reason for hiding this comment

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

As discussed, this can go through as you improved it in the next revision:

  1. Added javadoc.
  2. Added additional tests.

And also because it's the simpler solution at the moment.

If this causes any other issue in the future (bug or user misunderstanding), we'll explore the approach of generating a custom annotation.


import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertEquals;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor: better use assertJ assertions instead of the ones from JUnit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will address in following PR

assertEquals(expected, input.matches(ValidationUtils.NULL_OR_NOT_BLANK));
}

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor: new line at the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same

@thiagohora thiagohora merged commit dc1556c into main Oct 4, 2024
7 checks passed
@thiagohora thiagohora deleted the thiagohora/OPIK-121_allow_multiline_in_dataset_description branch October 4, 2024 12:08
dsblank pushed a commit that referenced this pull request Oct 4, 2024
* [OPIK-121] Allow multiline in dataset description

* Add docs
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