dstack
dstack copied to clipboard
Add a Python example beyond a single Python script
So far doc shows example with a single script that can be run directly like python train.py. However a real project has folder structure with many .py files organized as module. These need to be pip-installed to be usable, for example a folder with mnist/train.py.
Take this folder structure for example:

Without any installation, when trying to run python mnist/train.py as entrypoint, the following error pops up:
2022-06-19 21:55 Traceback (most recent call last):
2022-06-19 21:55 File "/workflow/mnist/prepare_data.py", line 1, in <module>
2022-06-19 21:55 from mnist.train import DIR, MNISTDataModule
2022-06-19 21:55 ModuleNotFoundError: No module named 'mnist'
The module that is the folder mnist/ needs to be installed with pip install -e . (setup.py file must exist first). To do this in dstack it requires adding -e . to requirements.txt, example:
pytorch-lightning
pillow
torchvision
hydra-core==1.2.0
-e .
Only then will it run in dstack.