perago.require_file#

perago.require_file(path)[源代码]#

Require one workspace-relative file to exist.

require_file creates a guardrail object for WorkspaceSpec.pre or WorkspaceSpec.post. Paths are interpreted inside the task's workspace prefix and must use portable POSIX-style relative syntax.

Parameters:
pathstr or os.PathLike[str]

Workspace-relative file path. Absolute paths, .. segments, backslash-separated strings, and drive-qualified paths are rejected.

Returns:
Workspace guardrail

Guardrail consumed by perago.WorkspaceSpec.

Raises:
TaskDefinitionError

If path is empty or is not a valid workspace-relative path.

参数:

path (str | PathLike[str])

返回类型:

_WorkspaceGuardrail

参见

require_dir

Require one directory.

require_glob

Require files matching a glob.

forbid_glob

Reject files matching a glob.

Examples

>>> WorkspaceSpec(prefix="/", pre=[require_file("input/data.csv")])
WorkspaceSpec(...)