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

[CLN] Separate validation and transformation logic #2899

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

atroyn
Copy link
Contributor

@atroyn atroyn commented Oct 4, 2024

Description of changes

We perform validation, and transformations, on requests before we send them from the client to the server. Previously, these operations were not well modularized, leading to difficult to debug code, lots of exceptional paths, and overall not-niceness.

This PR separates validation, and makes it idemponent, from transformations, for all methods on Collection in the python client.

Along the way, this PR cleans up the possibility of sending empty lists or dicts as filters or lists of IDs, so that the tests are now consistent with our validators.

In a future PR, we will also repeat this same validation logic server-side for use with clients other than our first party, and update it in JavaScript.

Test plan

CI Passes

New validation to ensure empty filters trigger validators.

Documentation Changes

TODO

  • Technically this is a breaking API change, let's discuss

Copy link

github-actions bot commented Oct 4, 2024

Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas

Copy link

github-actions bot commented Oct 4, 2024

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link
Contributor Author

atroyn commented Oct 4, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @atroyn and the rest of your teammates on Graphite Graphite

@atroyn atroyn changed the title Record & Validators [CLN] Separate validation and transformation logic Oct 4, 2024
@atroyn atroyn force-pushed the anton/separate_validation_logic branch 12 times, most recently from 4f829fc to 9d25975 Compare October 11, 2024 21:43
@atroyn atroyn force-pushed the anton/separate_validation_logic branch 4 times, most recently from b948c07 to 440e3b2 Compare October 19, 2024 17:48
@atroyn atroyn force-pushed the anton/separate_validation_logic branch 2 times, most recently from b91c9e5 to 5d181a9 Compare October 20, 2024 00:58
@atroyn atroyn marked this pull request as ready for review October 21, 2024 15:23
@atroyn atroyn requested review from HammadB and itaismith October 21, 2024 15:23
Copy link
Contributor

@itaismith itaismith left a comment

Choose a reason for hiding this comment

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

At least on Github there is only 1 example of someone using where with an empty dict, but we can still communicate this change for clarity

@atroyn atroyn force-pushed the anton/separate_validation_logic branch 3 times, most recently from 0346548 to 4294588 Compare October 22, 2024 22:57
@atroyn atroyn force-pushed the anton/separate_validation_logic branch from 4294588 to 8cb96fe Compare October 22, 2024 23:58
Copy link
Collaborator

@HammadB HammadB left a comment

Choose a reason for hiding this comment

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

This makes sense, I have left some questions. Except for the partial input problem everything looks great to me.

@atroyn atroyn force-pushed the anton/separate_validation_logic branch from 8cb96fe to b3f10d6 Compare October 29, 2024 20:12
@atroyn atroyn requested a review from HammadB October 29, 2024 20:35
@atroyn atroyn merged commit 3065adb into main Oct 29, 2024
72 checks passed
@atroyn atroyn deleted the anton/separate_validation_logic branch October 29, 2024 23:21
codetheweb pushed a commit that referenced this pull request Nov 5, 2024
## Description of changes

We perform validation, and transformations, on requests before we send
them from the client to the server. Previously, these operations were
not well modularized, leading to difficult to debug code, lots of
exceptional paths, and overall not-niceness.

This PR separates validation, and makes it idemponent, from
transformations, for all methods on `Collection` in the python client.

Along the way, this PR cleans up the possibility of sending empty lists
or dicts as filters or lists of IDs, so that the tests are now
consistent with our validators.

In a future PR, we will also repeat this same validation logic
server-side for use with clients other than our first party, and update
it in JavaScript.

## Test plan

CI Passes

New validation to ensure empty filters trigger validators. 

## Documentation Changes

## TODO
 - [ ] Technically this is a breaking API change, let's discuss
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.

3 participants