Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mount args to some utils components #787

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading