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

Changed the structure to allow for running it locally #7

Merged
merged 3 commits into from
Jul 7, 2024

Conversation

DoodleyJC
Copy link
Collaborator

Due to modules and python paths, I changed some file locations and changed the references accordingly so its easier to run the flask stuff locally.

Copy link
Collaborator

@falsepopsky falsepopsky left a comment

Choose a reason for hiding this comment

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

Tested and works fine, i'm okay with the tasks in the backend folder, not sure about the src.
cc @amine4567

@DoodleyJC
Copy link
Collaborator Author

Alternatively to the removing of src folder, we could add the following lines to the tasks.py to help with the importing:

import os
import sys
sys.path.append(os.getcwd()+"\\backend")
import api

This kinda feels a bit spaghetti though.

@amine4567
Copy link
Collaborator

I am not a fan of removing the src folder from the backend, plus we would also need to remove the src folder from the frontend for consistency.

The best practice in my opinion is to set the PYTHONPATH with the absolute path to the backend/src directory.

Are you familiar with virtualenvs ? They are the best tools to isolate python environments between different projects when working outside a devcontainer. I personally like to use virtualenvwrapper which installs a set of commands to make easier to work with virtualenvs.

For example:

  • I created a virtualenv.
  • Installed the requirements-combined.txt using pip while inside the virtual env.
  • Set the PYTHONPATH in the activate script of the virtualenv. In my case : export PYTHONPATH=/home/amine456/projects/retro-olympics/www/backend/src
  • I run the invoke run-back command using the current main branch without changes and it works.

tasks.py
invoke is a python library meant to replace make, the main advantage is that we get to use python instead of shell commands. That's why it's best to have it in the root of the project directory, we could later add commands to build the front, both the front and backends, builds, ...

@amine4567
Copy link
Collaborator

If it's okay with everyone, I could update the README with instructions on how to use virtualenvs

@DoodleyJC
Copy link
Collaborator Author

I dont think removing src from the backend implies the removing of the src folder in the frontend. I think the way I have provided is a decent enough way to do it and it keeps the barrier for entry into the development nice and low which to me is a major advantage considering the difference in experience in our team. If there is a good reason to keep the src folder then im fine to keep it but could you please do the setup for it then and test whether it works.

@amine4567
Copy link
Collaborator

Okay, if it makes it easier to dev for everybody else, I am good with the PR

@amine4567 amine4567 merged commit 98485f2 into RetroOlympics:main Jul 7, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants