janhurst / unisa-tbi

Decision Support Tool for suspected Traumatic Brain Injuries
https://unisa-tbi.azurewebsites.net
1 stars 1 forks source link

Move Python files #37

Closed janhurst closed 2 years ago

janhurst commented 4 years ago

I'd like to move some of the Python source files around a little bit to help the build process work a little easier.

In Niki's branch most of the UI code is in a "Python" folder. In the master branch there is a src folder holding Python code laid out in packages. Having a "src" folder is something of a convention for Python projects as it is the default location when building distributable packages.

We can start by getting Niki to move the files in the "Python" folder to a folder named "src/ui" in Niki's branch. You can see how this looks if you look in my branch where I have done exactly that: https://github.com/janhurst/capstone/tree/jan/src/ui

This brings us to the wonderful world of Python modules, imports, and path issues. :)

Once the files are moved, Niki will need to update some import statements, starting with at least line 8 in her app.py

This currently does sys.path.append('Python/'). Using sys.path is considered bad practice, mostly because it can mess with other code. I don't really mind if you just change this to sys.path.append('src/ui/') for now, which should hopefully be all you need to get back up and running.

We will need to mess around a bit with these files anyway, and i'll raise some other issues for that.

A better way would be to change the import statements to be something like from ui import TranformInputData, but this will only work if you execute Flask from the right location, and with a PYTHONPATH environment variable. For reference, I launch Flask from VSCode using the following launcher:

image