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

Add dependencies/references support #560

Merged
merged 19 commits into from Apr 13, 2023
Merged

Conversation

libretto
Copy link
Contributor

Protobuf references support:
Add references to Protobuf schemas,
Support compare protobuf schemas with references,
Support serialization/deserialization of protobuf schemas with dependencies.

@libretto libretto requested review from a team as code owners March 14, 2023 11:22
@libretto
Copy link
Contributor Author

There is some "copyright" lint check which is not passed on github but locally it is passed. Question is what this check means?

@RyanSkraba
Copy link
Contributor

The copyright check is now in the pre-commit hooks: 1fd5ff7

I run this using pre-commit run --all-files.

It looks like the 3.11 failures are just enum types in error message and can be fixed (for all python versions): 's/{schema_type}/{schema_type.value}/g'

@RyanSkraba RyanSkraba self-requested a review March 14, 2023 16:47
@libretto
Copy link
Contributor Author

I run this using pre-commit run --all-files.
in my case pylint ignore copyright rules by some reason because locally I see
(py311) serge@dell:~/workspace/instaclustr/novage_office/karapace_mainstream$ pre-commit run --all-files
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
debug statements (python)................................................Passed
copyright................................................................Passed

@libretto
Copy link
Contributor Author

Debian 11 pre-commit rule not works probably because of this error:
(py311) serge@dell:~/workspace/instaclustr/novage_office/karapace_mainstream$ git grep -ELm1 'Copyright (c) 20[0-9]{2} Aiven' -- '.py' ':!init.py'
error: unknown switch `m'

Copy link
Contributor

@RyanSkraba RyanSkraba left a comment

Choose a reason for hiding this comment

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

Just some quick notes, so you know that we are looking at this!

I'm not asking for any changes yet -- I like to think a review is a collaboration and I still have quite a bit to get through. Don't hesitate to let me know if I've read or misunderstoon, and I'll keep on going through!

karapace/errors.py Outdated Show resolved Hide resolved
karapace/utils.py Outdated Show resolved Hide resolved
karapace/in_memory_database.py Outdated Show resolved Hide resolved
karapace/in_memory_database.py Outdated Show resolved Hide resolved
karapace/schema_models.py Outdated Show resolved Hide resolved
karapace/schema_reader.py Outdated Show resolved Hide resolved
karapace/schema_reader.py Show resolved Hide resolved
karapace/schema_references.py Outdated Show resolved Hide resolved
karapace/schema_models.py Outdated Show resolved Hide resolved
karapace/schema_reader.py Show resolved Hide resolved
@libretto
Copy link
Contributor Author

libretto commented Mar 16, 2023

@RyanSkraba all issues above are fixed

karapace/schema_models.py Outdated Show resolved Hide resolved
@aiven-anton
Copy link
Contributor

@libretto I logged a separate issue for the false positive in the copyright pre-commit hook: #563

@RyanSkraba
Copy link
Contributor

Thanks for the merge with master -- I did this locally and it wasn't too difficult, but I appreciate that it's constant effort. I should have another round of review for you in the protobuf area very soon!

Copy link
Contributor

@RyanSkraba RyanSkraba left a comment

Choose a reason for hiding this comment

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

Hey,

I've finally gotten all of this code pretty thoroughly reviewed, and again, thanks for your patience! For me, this is a pretty good feature to ramp up on my Karapace and get some more modern python experience, so I appreciate it.

I really tried to limit myself to noting things that might be breaking changes, since the priority must be to avoid any regressions with customers not using this feature.

There's a couple of things introduced in this PR that could be improved, but I think it's wise to create issues and fix them incrementally! I'm willing to take on some of this work and I hope you'll stick around to help review future changes in this area :D

Just for discussion: some of the things that I would like to see applied on top of this PR:

  • Restricting the scope as tight as possible helps reviews because we can tell the scope where a method applies.

  • Some field, file and class names aren't very helpful. While this often applies to Karapace as a whole, we specifically end up with dependency.schema.schema constructions which is hard on the eyes.

  • and of course, more extensive unit testing to catch regressions earlier.

To be clear, I'm not looking for the magic PR that makes everybody perfectly happy today! If we can do a round-trip on these comments, that might be enough to allow the above things to be gradually fixed while providing the references feature to those looking forward to it immediately.

all, What do you think?

karapace/protobuf/compare_type_storage.py Show resolved Hide resolved
karapace/protobuf/schema.py Outdated Show resolved Hide resolved
karapace/protobuf/schema.py Outdated Show resolved Hide resolved
karapace/protobuf/known_dependency.py Show resolved Hide resolved
karapace/protobuf/proto_file_element.py Outdated Show resolved Hide resolved
karapace/protobuf/schema.py Outdated Show resolved Hide resolved
karapace/protobuf/io.py Outdated Show resolved Hide resolved
karapace/protobuf/io.py Outdated Show resolved Hide resolved
@libretto libretto requested review from RyanSkraba and jjaakola-aiven and removed request for jjaakola-aiven and RyanSkraba March 29, 2023 21:57
@libretto
Copy link
Contributor Author

libretto commented Apr 3, 2023

@RyanSkraba I fixed all issues from Your comments. Most tests I ported from Wire (a java protobuf parser) or inspired by the code of Schema Registry. Of course, they do not cover all issues. You show an issue with an empty package name where one letter name will raise an exception. I will add there a simple test for one-letter names.

@RyanSkraba
Copy link
Contributor

Hello! Thanks again for doing yet another merge with master -- it looks like there were a couple of hiccups with the merge with formatting and whitespace (which is now a lint error).

The good news is that I think that once the lint is fixed, this LGTM sufficiently to merge it and make any other requested fixes iteratively!

Copy link
Contributor

@RyanSkraba RyanSkraba left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your continued work!

Copy link
Contributor Author

@libretto libretto left a comment

Choose a reason for hiding this comment

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

all changes was implemented

@libretto
Copy link
Contributor Author

@RyanSkraba I suppose we waiting for @jjaakola-aiven approval now...

@libretto
Copy link
Contributor Author

libretto commented Apr 13, 2023

@jjaakola-aiven I see "changes requested" in this thread. But all changes are done and all code comments are outdated. Could You take a look at Your change request and approve it?

Copy link
Contributor Author

@libretto libretto left a comment

Choose a reason for hiding this comment

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

All requested changes were fixed.

@RyanSkraba
Copy link
Contributor

Thanks so much, all is well, I was doing some follow-up in the meantime -- let's merge this before main moves again! If we have any code style preferences, extra clean-up or fixes we can make those changes incrementally!

@RyanSkraba RyanSkraba dismissed jjaakola-aiven’s stale review April 13, 2023 11:51

Some necessary changes can be made in future PRs

@RyanSkraba RyanSkraba merged commit 7e1de2a into Aiven-Open:main Apr 13, 2023
7 checks passed
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.

None yet

4 participants