实用工具¶
Utility组件是ready-to-use个内置的。这些是
执行著名二进制文件(例如/bin/cp)
并旨在作为教程材料或工作流程中有意义阶段之间的粘合操作的组件。
- torchx.components.utils.echo(msg: str = 'hello world', image: str = 'ghcr.io/pytorch/torchx:0.1.0rc1', num_replicas: int = 1) → torchx.specs.api.AppDef[source]¶
向标准输出(调用/bin/echo)发送消息
- Parameters
msg – 要回显的信息
图像 – 使用的图像
num_replicas – 运行的副本数量
- torchx.components.utils.touch(file: str, image: str = 'ghcr.io/pytorch/torchx:0.1.0rc1') → torchx.specs.api.AppDef[source]¶
触碰一个文件(调用 touch)
- Parameters
文件 – 创建的文件
图像 – 要使用的图像
- torchx.components.utils.sh(*args: str, image: str = 'ghcr.io/pytorch/torchx:0.1.0rc1', num_replicas: int = 1) → torchx.specs.api.AppDef[source]¶
通过 sh 运行提供的命令。目前 sh 不支持环境变量替换。
- Parameters
args – 命令行参数
图像 – 使用的图像
num_replicas – 运行的副本数量
- torchx.components.utils.copy(src: str, dst: str, image: str = 'ghcr.io/pytorch/torchx:0.1.0rc1') → torchx.specs.api.AppDef[source]¶
复制文件从源路径到目标路径。源路径和目标路径可以是任何有效的 fsspec URL。
这不支持递归复制或目录。
- Parameters
src – 源 fsspec 文件位置
dst – 目标fsspec文件位置
图像 – 包含复制应用的图像
- 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.0rc1') → torchx.specs.api.AppDef[source]¶
评估 booth 函数,
f(x1, x2) = (x1 + 2*x2 - 7)^2 + (2*x1 + x2 - 5)^2。 输出结果可通过FsspecResultTracker(outdir)[trial_idx]访问- Parameters
x1 – x1
x2 – x2
trial_idx – 如果不运行超参数优化,请忽略
tracker_base – 跟踪器基础输出目录的URI(例如 s3://foo/bar)
图像 – 包含展位应用程序的图像