Skip to content

Commit

Permalink
add mount args
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-ai committed Nov 2, 2023
1 parent fb819df commit 2e1af6f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion torchx/components/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def python(
memMB: int = 1024,
h: Optional[str] = None,
num_replicas: int = 1,
mounts: Optional[List[str]] = None,
) -> specs.AppDef:
"""
Runs ``python`` with the specified module, command or script on the specified
Expand All @@ -157,6 +158,8 @@ def python(
memMB: cpu memory in MB per replica
h: a registered named resource (if specified takes precedence over cpu, gpu, memMB)
num_replicas: number of copies to run (each on its own container)
mounts: mounts to mount into the worker environment/container (ex. type=<bind/volume>,src=/host,dst=/job[,readonly]).
See scheduler documentation for more info.
:return:
"""
if sum([m is not None, c is not None, script is not None]) != 1:
Expand Down Expand Up @@ -184,6 +187,7 @@ def python(
resource=specs.resource(cpu=cpu, gpu=gpu, memMB=memMB, h=h),
args=[*cmd, *args],
env={"HYDRA_MAIN_MODULE": m} if m else {},
mounts=specs.parse_mounts(mounts) if mounts else [],
)
],
)
Expand Down Expand Up @@ -227,7 +231,7 @@ def binary(
)


def copy(src: str, dst: str, image: str = torchx.IMAGE) -> specs.AppDef:
def copy(src: str, dst: str, image: str = torchx.IMAGE, mounts: Optional[List[str]] = None,) -> specs.AppDef:
"""
copy copies the file from src to dst. src and dst can be any valid fsspec
url.
Expand All @@ -238,6 +242,8 @@ def copy(src: str, dst: str, image: str = torchx.IMAGE) -> specs.AppDef:
src: the source fsspec file location
dst: the destination fsspec file location
image: the image that contains the copy app
mounts: mounts to mount into the worker environment/container (ex. type=<bind/volume>,src=/host,dst=/job[,readonly]).
See scheduler documentation for more info.
"""

return specs.AppDef(
Expand All @@ -256,6 +262,7 @@ def copy(src: str, dst: str, image: str = torchx.IMAGE) -> specs.AppDef:
dst,
],
resource=specs.Resource(cpu=1, gpu=0, memMB=1024),
mounts=specs.parse_mounts(mounts) if mounts else [],
),
],
)
Expand Down

0 comments on commit 2e1af6f

Please sign in to comment.