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

Replace utils module #666

Merged
merged 22 commits into from Mar 16, 2023
Merged

Replace utils module #666

merged 22 commits into from Mar 16, 2023

Conversation

iron3oxide
Copy link
Contributor

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Having a utils module is considered a code smell in most cases, including this one. It did way too much different stuff and even required circular imports in some places. This PR distributes the code formerly contained in the utils module in a logically coherent manner into new and existing modules. It also includes minor fixups that were necessary to pass all tests; the most notable one being the clear separation of web directory creation, frontend package installation and frontend setup. This fixup should increase testability in general, as the frontend setup called the frontend package installation function in the previous code, which made it way harder to mock said installation.

Type of change

Refactoring

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you successfully ran tests with your changes locally?

jh added 15 commits March 12, 2023 20:50
Having a utils module is a code smell in most cases, including this one. The included functionality can be logically distributed to new and existing modules.
This is where all console related code will live. It wraps Console and Prompt methods.
This is where everything that is checked, installed or initialized before the app is built/exported will live.
This is where everything regarding string and object formatting happens.
This is where import magic happens
Every path-related functionality will live here, e.g. join()
Everything regarding processes/ports will happen here
Custom types and type-related functions will live here, e.g. _issubclass()
This is where every functionality egarding actual building and exporting of the app lives
This is where everything regarding execution of the app happens
This can live here, can't it?
@Alek99 Alek99 changed the title Replace smelly utils module Replace utils module Mar 12, 2023
Copy link
Contributor

@picklelo picklelo left a comment

Choose a reason for hiding this comment

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

Thanks for breaking this up - that file was getting big and had many circular imports.

Could we make the following changes:

  • Create a pynecone/utils directory where all these new files will go under
  • Move the new files into the new folder e.g. pynecone/utils/format.py and pynecone/utils/imports.py
  • In the files that import these, import the module rather than the individual functions - for example from pynecone.utils import format and then call the functions like format.format_state

jh added 2 commits March 12, 2023 23:13
Also renamed two modules: run -> exec, path -> path_ops
Forgot to check tests for errors resulting from new import strategy
@iron3oxide
Copy link
Contributor Author

Done, that probably won't fix the workflow error from the first run though. I'll dig into that.

Seems like it was never needed here until now
@iron3oxide
Copy link
Contributor Author

Seems like from __future__ import annotations was never needed in route.py until now. I think this should fix the workflow errors, but I haven't been able to set rtx up to test with 3.7 or 3.8 yet, so only a rerun will tell for sure.

@iron3oxide
Copy link
Contributor Author

Forgot to lint the docstrings 🤦‍♂️. Sorry for the delay, should work now.

@picklelo
Copy link
Contributor

Thanks for fixing the build! We're cutting a release tonight, I'll merge this in afterwards.

@iron3oxide iron3oxide mentioned this pull request Mar 15, 2023
11 tasks
Copy link
Contributor

@picklelo picklelo left a comment

Choose a reason for hiding this comment

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

Just one issue, otherwise seems to work well!

pynecone/compiler/utils.py Outdated Show resolved Hide resolved
Copy link
Contributor

@picklelo picklelo left a comment

Choose a reason for hiding this comment

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

thanks for the huge refactor

@picklelo
Copy link
Contributor

Looking into why the integration test is failing

@picklelo
Copy link
Contributor

Talked with @ElijahAhianyo offline - looks like this is because we need to update pcweb and pynecone at the same time. I ran the integration test manually and it passed, so I'll merge this in.

@picklelo picklelo merged commit 7067baf into reflex-dev:main Mar 16, 2023
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

2 participants