-
-
Notifications
You must be signed in to change notification settings - Fork 338
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
Type logic refactor #1222
Type logic refactor #1222
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.
Overall, I think this is going to be a massive improvement. We'll need to go through the code base and make sure no function deals with bare SA type classes, ever, except to convert them to the appropriate Enum
member, or at the last point when creating a column. I'm not sure how to guarantee that long-term. Maybe a ban on imports of SA type classes outside the types.base
module?
|
||
def get_sa_class(self, engine): | ||
""" | ||
Returns the SA class corresponding to this type or None if this type is not supported by |
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 will more precisely return a SA class corresponding to this type. In particular, we will return the SQL Standard or Vendor-Specific SA class for the type, with the exceptions of name
and "char"
, which will return (for now) the String
generic SA class.
See https://docs.sqlalchemy.org/en/14/core/type_basics.html#sql-standard-and-multiple-vendor-types
Latest revision adds
|
Note, I added |
I see that some e2e tests have failed in the Github runner, while they pass fine on my machine. I'm not sure if this is a fluke or if there's an actual problem. Rerunning the test suite. |
I'm guessing that the problem is that e2e test runner is choking, because I've enabled test parallelization (this runner is using 2 parallel threads). I'll disable automatic parallelization for e2e tests, when I get online. |
I disabled test parallelization on GitHub's e2e test workflow and now it seems to be passing. I presume the problem was that parallelization slowed down the test runner too much. That's not a concern in a regular development environment, as far as I can tell. I also removed |
Many changes made, including the requested changes.
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.
Overall, a massive improvement, good work.
I have some qualms with approving, since I admittedly wasn't able to completely verify everything, but:
- I looked through tests to asses whether they're still valid; I think they are.
- I looked through code to see if I noticed any obvious bugs or problems; none found.
- I ran the service and fiddled around with the API to see if I noticed any obvious regressions; none found.
I think we should get this merged ASAP. @dmos62 is it ready to go?
id: str # noqa: NT001 | ||
display_name: str # noqa: NT001 | ||
db_types: Collection[DatabaseType] # noqa: NT001 |
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.
Why are these needed?
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.
For clarity. These mixins only support objects that have these attributes. I didn't see another way to state that concisely and clearly. Also, this being actual type annotations, instead of a comment, helps with IDE complaining that referencing these attributes in this class is a mistake.
I'm open to getting rid of it, but I think this is a useful exception to the no-type-hints rule.
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.
@dmos62 You've clearly been busy with this PR 😲
I'm not reviewing the back-end code, but I looked over the front end changes and E2E changes. I added a couple small commits. Looks good!
@@ -15,8 +15,7 @@ services: | |||
service: | |||
build: | |||
context: . | |||
# Change this to Dockerfile.integ-tests to be able to run e2e integ tests | |||
dockerfile: Dockerfile | |||
dockerfile: ${DOCKERFILE} |
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 great idea, moving this config to .env
. I added 7cdfa7c to update the documentation to reflect this change. If I'm understanding this change correctly, then all existing devs will need to add DOCKERFILE=Dockerfile
or DOCKERFILE=Dockerfile.integ-tests
to their .env
before they can re-build the container. Yes? If so, we should give everyone a heads up after merging this PR.
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.
Right! I had forgotten about this! Thanks!
Specifically, my suggestion would have been to do cp .env.example .env
.
@@ -22,6 +23,7 @@ def test_convert_text_column_to_number(page, go_to_patents_data_table): | |||
expect(page.locator(toast_box)).to_be_visible() | |||
|
|||
|
|||
@pytest.mark.skip(reason="unclear why test is failing: deferring for later") |
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.
@dmos62 was this failing for you locally? Or just in CI? I just ran it locally and it passed for me. Maybe we don't need to skip it?
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 was failing for me locally. Could we try and resolve this outside this PR? I'd love to get this merged soon.
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.
Yep. Sounds good.
I've enabled auto-merge. Thanks for the reviews @mathemancer and @seancolsen! I also disabled test parallelization by default, because @mathemancer discovered a bug, where we can't have more than 7 threads, due to the testing suite not cleaning up unused database connections (i think that's the reason). |
The initial goal of refactor was to centralize and improve our db/ui type logic, of which there is a lot. That dominoed into a lot of secondary refactors, because I often couldn't make the changes I needed outright.
Checklist
Update index.md
).master
branch of the repositoryvisible errors.
Developer Certificate of Origin
Developer Certificate of Origin