Add --include_path option to include external folders in Docker build context#182
Add --include_path option to include external folders in Docker build context#182mikaelsimard5 merged 26 commits intomainfrom
Conversation
…text Copies folder into build context; at code exit the local copy is deleted.
… the installed 3.9 and uses system default (now > 3.12 which breaks the test)
… version of minio/mc so this does not happen in the future
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mikewoodward94
left a comment
There was a problem hiding this comment.
I apologise that this feature addition also became a bug fix, but thank you for finding the cause of the problems and also fixing those!
Great work here, just a small function to be added for safety/ease of debugging at the time of use.
mlops/Experiment.py
Outdated
| if include_path: | ||
| folder_name = os.path.basename(os.path.abspath(include_path)) | ||
| included_folder_dest = os.path.join(self.project_path, folder_name) | ||
| shutil.rmtree(included_folder_dest, ignore_errors=True) |
There was a problem hiding this comment.
I think this could result in accidental folder deletions, say someone accidentally set the include_path as "config" it would then delete the config folder (and do so silently).
Could we have a check_include_path() function that's called at init if the variable is passed? Think it just needs to do the following two things, and then can raise easy to action useful errors!
- Makes sure the path exists to include:
if not os.path.exists(include_path):
raise FileNotFoundError(f"Source folder does not exist: {include_path}")
- Makes sure the destination folder doesn't already exist:
if os.path.exists(included_folder_dest):
raise FileExistsError(f"Destination folder already exists: {included_folder_dest}. Please remove it first or rename your source folder.")
Feel free to add to this for anything else you think of thats worth checking.
There was a problem hiding this comment.
Good catch!
I think in general it makes more sense to perform this action while initiating the experiment (similarly to the check_dirty, env_setup, ... methods), so I moved the action from run() to init, and added the suggested checks - see c42301c (main changes), and 48bd4db and bccf904 (two small bug fixes to the logic implemented in c42301c).
Currently
mlops run()builds a docker image from the local context i.e. assumes the docker file is located at./Dockerfileand the image will be created from./.In some projects, there may be some shared utility folders outside of the context of mlops run() which may need to be included in the docker image. Rather than copy-pasting the necessary folders into the local context, you could now use
mlops run()with the-ioption to include a folder.This PR also corrects some of the GitHub actions tests that have been failing for the past year or so on any PR made - see specific comments in the Files changed tab for more.