Skip to content

ctx.actions.write doesn't propagate with_inputs dependencies if given an OutputArtifact rather than a str filename #1151

@lf-

Description

@lf-

We found a funny behaviour: if you use an Artifact in AnalysisActions.write() or AnalysisActions.write_json(), it won't propagate dependencies when with_inputs is True; you have to use the return value. This isn't true of e.g. ctx.actions.run, e.g., I think?

@JakobDegen says this is still a bug in main.

This gets annoying if one is using dynamic actions since the dynamic actions cannot pass anything out to the non-dynamic world except by putting something into an artifact, and you can't just .. replace the identity of the artifact like we have to do in this example:

Good:

    written = ctx.actions.write(
        "container_upload.sh",
        cmd_args(
            "#!/usr/bin/env bash",
            "set -euo pipefail",
            cmd_args(
                # ctx.attrs.build_container,
                "FIXME",
                cmd_args(build_plan, quote = "shell"),
                "\"$@\"",
                delimiter = " ",
            ),
        ),
        is_executable = True,
        with_inputs = True,
    )

Bad:

    runner = ctx.actions.declare_output("container_upload.sh")
    ctx.actions.write(
        runner.as_output(),
        cmd_args(
            "#!/usr/bin/env bash",
            "set -euo pipefail",
            cmd_args(
                # ctx.attrs.build_container,
                "FIXME",
                cmd_args(build_plan, quote = "shell"),
                "\"$@\"",
                delimiter = " ",
            ),
        ),
        is_executable = True,
        with_inputs = True,
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions