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

Refactor directory structure and unify frontend and backend #21

Merged
merged 4 commits into from
May 28, 2024

Conversation

K-dash
Copy link
Collaborator

@K-dash K-dash commented May 28, 2024

@ryansurf
This PR addresses the directory structure changes discussed in #19 (comment).

The modifications turned out to be more extensive than initially anticipated. Please refer to the commit messages for the specific changes made.
65ea49e
e7acc8f
136f2e0
60001d6

I have also thoroughly verified that the application runs without issues using Docker and that the frontend functionality works as expected.

Once this PR is merged, I can start working on creating the unit test files!

Please review the changes and provide any feedback or suggestions.
Please feel free to ask if you have any questions or uncertainties.


Most significant change

The main.py file has been renamed to cli.py.

The reason for changing main.py to cli.py was to resolve the naming conflict between the module name and the function name when importing the main function in test_code.py.
Initially, the main.py file contained a function named main. In the test_code.py file, the main function was imported using from src.main import main.
However, this approach resulted in importing the main module instead of directly calling the main function. The error message TypeError: 'module' object is not callable was encountered.
To resolve this issue, two changes were made:

  1. The main.py file was renamed to cli.py. This avoids the naming conflict between the module and the function.
  2. The main function within cli.py was renamed to run. This allows test_code.py to import the run function using from src.cli import run.

These changes resolved the naming conflict between the module and the function, enabling the test code to execute successfully.

Additionally, renaming main.py to cli.py provides a clearer indication of the file's role and purpose within the project.

Fixes #20

- Remove backend/frontend directories and move files under src
- Rename frontend directory to static (convention for Flask)
- Update import paths and references accordingly
- Rename main.py to cli.py to avoid naming conflicts
- Allow Flask app to accept requests from all network interfaces(0.0.0.0)
- Modify test directory structure to match the updated source directory
- Update import paths and references in test files
- Adjust pytest.yaml configuration to reflect the new directory structure
@K-dash K-dash mentioned this pull request May 28, 2024
src/server.py Show resolved Hide resolved
README.md Show resolved Hide resolved
Copy link
Owner

@ryansurf ryansurf left a comment

Choose a reason for hiding this comment

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

Fantastic work. Reworking the structure was more tedious than I imagined, thanks for tackling it. Nice catch on the Docker container IP

src/cli.py Show resolved Hide resolved
Copy link
Owner

Choose a reason for hiding this comment

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

Looks like you cleaned up the code, very nice. Are you using Pylint?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ryansurf
I ran the code through the Black formatter.
By the way, since there is currently no linter implemented, how about using ruff? Ruff not only has a linter function but also a formatter function, so you can unify everything under ruff and eliminate Black :)

https://github.com/astral-sh/ruff

Copy link
Owner

Choose a reason for hiding this comment

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

Ah, forgot about the black formatter 😂

Two birds one stone! Sounds like a good plan to me, lets do it

src/server.py Show resolved Hide resolved
@ryansurf ryansurf merged commit c60474c into ryansurf:main May 28, 2024
2 checks passed
@K-dash K-dash deleted the refactor/unify-directory-structure branch May 29, 2024 01:58
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.

Change directory structure
2 participants