Skip to main content

add_common_files

Adds one or more local files to common files to the current branch.

Common files are shared code for all deployments and training jobs. Calling mb.deploy or mb.add_job will link common into deployments and training jobs. Git users should use modelbit add_common_files to symlink common files into deployments and training jobs.

Parameters

mb.add_common_files(files=)
  • files: Union[str, List[str], Dict[str, str]] The file(s) to add to common files.
    • as str: The path to a single file or directory.
    • as List[str]: Paths to multiple files or directories.
    • as Dict[str, str]: Pairs of file paths or directories. The key is the local file path, the value is the file path in common files.

Returns

No value is returned. A success status message is printed if the command is successful. An exception is thrown if any file path doesn't resolve to a file.

Examples

Add a single common file

Add the utils.py files, stored in the current directory, to common files.

mb.add_common_files("utils.py")

Adding multiple common files

Use a list to store multiple files into common files.

mb.add_common_files(["utils.py", "helpers.py"])

Adding a directory to common files

Supply a path instead of a file to add a directory, and all of its subdirectories, to common files.

mb.add_common_files("my_lib")

Adding files outside the current working directory

When adding files that are not in the current working directory, map their local paths to the desired paths in common files. To map /workspace/foo.py locally to foo.py in common use a dictionary:

mb.add_common_files({ "/workspace/foo.py": "foo.py" })

Similarly, to place files outside the current working directory into a subdirectory in common files, add the directory to the remote path:

mb.add_common_files({ "/workspace/lib/foo.py": "lib/foo.py" })

See also