Utils¶
This contains TorchX utility components that are ready-to-use out of the box. These are
components that simply execute well known binaries (e.g. cp)
and are meant to be used as tutorial materials or glue operations between
meaningful stages in a workflow.
- torchx.components.utils.echo(msg: str = 'hello world', image: str = 'ghcr.io/pytorch/torchx:0.1.1', num_replicas: int = 1) → torchx.specs.api.AppDef[source]¶
Echos a message to stdout (calls echo)
- Parameters
msg – message to echo
image – image to use
num_replicas – number of replicas to run
- torchx.components.utils.touch(file: str, image: str = 'ghcr.io/pytorch/torchx:0.1.1') → torchx.specs.api.AppDef[source]¶
Touches a file (calls touch)
- Parameters
file – file to create
image – the image to use
- torchx.components.utils.sh(*args: str, image: str = 'ghcr.io/pytorch/torchx:0.1.1', num_replicas: int = 1) → torchx.specs.api.AppDef[source]¶
Runs the provided command via sh. Currently sh does not support environment variable substitution.
- Parameters
args – bash arguments
image – image to use
num_replicas – number of replicas to run
- torchx.components.utils.copy(src: str, dst: str, image: str = 'ghcr.io/pytorch/torchx:0.1.1') → torchx.specs.api.AppDef[source]¶
copy copies the file from src to dst. src and dst can be any valid fsspec url.
This does not support recursive copies or directories.
- Parameters
src – the source fsspec file location
dst – the destination fsspec file location
image – the image that contains the copy app
- torchx.components.utils.python(*args: str, m: Optional[str] = None, c: Optional[str] = None, image: str = 'ghcr.io/pytorch/torchx:0.1.1', name: str = 'torchx_utils_python', host: str = 'aws_t3.medium', num_replicas: int = 1) → torchx.specs.api.AppDef[source]¶
Runs
python -c CMDorpython -m MODULEon the specified image and host. Use--to separate component args and program args (e.g.torchx run utils.python --m foo.main -- --args to --main)- Parameters
args – arguments passed to the program in sys.argv[1:] (ignored with –c)
m – run library module as a script
c – program passed as string (may error if scheduler has a length limit on args)
image – image to run on
name – name of the job
host – a registered named resource
num_replicas – number of copies to run (each on its own container)
- Returns
- torchx.components.utils.booth(x1: float, x2: float, trial_idx: int = 0, tracker_base: str = '/tmp/torchx-util-booth', image: str = 'ghcr.io/pytorch/torchx:0.1.1') → torchx.specs.api.AppDef[source]¶
Evaluates the booth function,
f(x1, x2) = (x1 + 2*x2 - 7)^2 + (2*x1 + x2 - 5)^2. Output result is accessible viaFsspecResultTracker(outdir)[trial_idx]- Parameters
x1 – x1
x2 – x2
trial_idx – ignore if not running hpo
tracker_base – URI of the tracker’s base output directory (e.g. s3://foo/bar)
image – the image that contains the booth app