The Image
class, which lets you specify a pre-built base Image to use
at launch time, as well as additional setup steps required for your program, such as installs and env vars.
- __init__(name: str | None = None, image_id: str | None = None, python_path: str | None = None)
Kubetorch Image object, specifying cluster setup properties and steps.
- Parameters:
name (str, optional) β Name to assign the Kubetorch image.
image_id (str, optional) β Machine image to use, if any. (Default:
None
)python_path (str, optional) β Absolute path to the Python executable to use for remote server and installs. (Default:
None
)Example
import kubetorch as kt my_image = ( kt.Image(name="base_image") .pip_install(["numpy", "pandas"]) .set_env_vars({"OMP_NUM_THREADS": 1}) )
Set up and use an existing Docker image.
image_id (str) β Docker image in the following format "<registry>/<image>:<tag>"
Pip install the given packages.
reqs (List[Package or str]) β List of packages to pip install on cluster and env.
force (bool, optional) β Whether to force re-install a package, if it already exists on the compute. (Default: False
)
Set environment variables.
env_vars (Dict) β Dict of environment variables and values to set.
Sync local package over and add to path.
package (Package or str) β Package to sync. Either the name of a local editably installed package, or the path to the folder to sync over.
force (bool, optional) β Whether to re-sync the package over, if already previously synced over. (Default: False
)
Run bash commands.
command (str) β Shell commands to run on the cluster.
force (bool) β Whether to rerun the command on the cluster, if previously run in image setup already. (Default: False
)
Sync the contents of the source directory into the destination.
source (str) β The source path.
dest (str) β The target path.
contents (bool, optional) β Whether the contents of the source directory or the directory
itself should be copied to destination.
If True
the contents of the source directory are copied to the destination, and the source
directory itself is not created at the destination.
If False
the source directory along with its contents are copied to the destination,
creating an additional directory layer at the destination. (Default: False
)
filter_options (str, optional) β The filter options for rsync. (Default: None
)
force (bool) β Whether to force run the rsync command again, even if already rsynced previously in the image. (Default: False
)