I have a project directory set up as follows:
project/
src/
__init__.py
data/
__init__.py
pull_data.py
format_data.py
update_data.py
model/
__init__.py
train.py
predict.py
The main thing I will be doing is running train.py
and predict.py
which both update my data then train and predict respectively. I would also like to be able to run the other python files independently as well if needed.
My question are, is this an appropriate way to set up my project directory and how am I supposed to import the files?
The python files look something like this:
# update_data.py
from pull_data import pull_data # how? this is in same directory
from format_data import format_data # how? this is in same directory
def update_data():
pull_data() # this is in the same directory
format_data() # this is in the same directory
# other stuff
if __name__ == '__main__':
update_data()
,
# train.py
from update_data import update_data # how? this is in ../data
def train():
update_data()
# other stuff
if __name__ == '__main__':
train()
,
# predict.py
from update_data import update_data # how? this is in ../data
def predict():
update_data()
# other stuff
if __name__ == '__main__':
predict()
I was also under the assumption that I should run the code from the src
directory with something like python model/train.py
. I'm open to improvements to that as well.