Skip to content

Add --include_path option to include external folders in Docker build context#182

Merged
mikaelsimard5 merged 26 commits intomainfrom
feature/import_path
Apr 1, 2026
Merged

Add --include_path option to include external folders in Docker build context#182
mikaelsimard5 merged 26 commits intomainfrom
feature/import_path

Conversation

@mikaelsimard5
Copy link
Copy Markdown
Contributor

@mikaelsimard5 mikaelsimard5 commented Mar 25, 2026

Currently mlops run() builds a docker image from the local context i.e. assumes the docker file is located at ./Dockerfile and 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 -i option 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.

@mikaelsimard5 mikaelsimard5 added enhancement New feature or request bug Something isn't working labels Mar 25, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 25, 2026

Coverage

Coverage Report
FileStmtsMissCoverMissing
mlops
   Experiment.py1714077%48–53, 77, 82–83, 104, 106, 111, 167–178, 201–215, 234, 236–237, 285–286, 290–294, 298–299, 306–307
   ProjectFile.py23196%41
   cli.py551769%19–22, 36, 59–66, 86–88, 96–99, 107–108, 113
mlops/release
   Release.py33779%24, 28, 33–38
mlops/release/destinations
   ReleaseDestination.py9189%18
   SharepointDestination.py6267%12–13
   ZenodoDestination.py331942%21–25, 29–35, 43–60
mlops/release/sources
   MLFlowSource.py13654%13–14, 21–27
   ReleaseSource.py14286%14, 23
mlops/utils
   Config.py17170%1–24
TOTAL41111273% 

Tests Skipped Failures Errors Time
17 0 💤 0 ❌ 0 🔥 2m 55s ⏱️

@mikaelsimard5 mikaelsimard5 marked this pull request as draft March 25, 2026 16:37
@mikaelsimard5 mikaelsimard5 marked this pull request as ready for review March 26, 2026 10:19
Copy link
Copy Markdown
Collaborator

@mikewoodward94 mikewoodward94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

  1. Makes sure the path exists to include:
if not os.path.exists(include_path):
    raise FileNotFoundError(f"Source folder does not exist: {include_path}")
  1. 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.

Copy link
Copy Markdown
Contributor Author

@mikaelsimard5 mikaelsimard5 Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Collaborator

@mikewoodward94 mikewoodward94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mikaelsimard5 mikaelsimard5 merged commit 3fbab30 into main Apr 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants