Python Forum

Full Version: Python Project Structure for Modularity and Reusability with Multiple Entry Points
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am massively confused about the approach I should take to organizing my project structure (see below) for my machine learning experiments. My projects generally have multiple individual experiments (i.e., multiple entry points) that I need to run (e.g., experiment 1, experiment 2, etc...) and all the experiments need to be able to import custom code I wrote for things like different machine learning models (resent, vgg, etc...) or utilities (metrics, common functions, etc...) to name a couple. I need to be able to run this code locally on my computer, share it with other people so they can run it locally on their computers, and execute it on server environments. So, it needs to be very modular and easy to configure.

My understanding is that I can put a blank init.py file in every directory and sub directory and then call each experiment from the proj_root folder to run each experiment as a module (e.g., python -m experiments.experiment_1.run_exp1).

Is this good/current practice in python to accomplish my goals of code reusability and project modularity? I would prefer to avoid the overhead of using tools like docker. Thank you!

proj_root/
|
|-- models
|   |
|   |-- resnet_model.py
|   |-- vgg_model.py
|
|-- utils
|   |
|   |-- metrics.py
|   |-- common.py
|
|-- experiments
|   |
|   |-- experiment_1
|   |   |
|   |   |-- run_exp1.py
|   |
|   |-- experiment_2
|   |   |
|   |   |-- run_exp2.py