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

pseudo actions omitted from Target.actions #12985

Open
shahms opened this issue Feb 9, 2021 · 6 comments
Open

pseudo actions omitted from Target.actions #12985

shahms opened this issue Feb 9, 2021 · 6 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: bug

Comments

@shahms
Copy link

shahms commented Feb 9, 2021

Description of the problem / feature request:

When accessing Target.actions from an aspect, pseudo actions are absent.

Feature requests: what underlying problem are you trying to solve with this feature?

Replacing extra_actions with aspects.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Given BUILD:

# BUILD
action_listener(
    name = "py_listener",
    extra_actions = [":debug"],
    mnemonics = ["Python"],
)

extra_action(
    name = "debug",
    cmd = "echo 'Action Executed' > $(output $(ACTION_ID).txt)",
    out_templates = [
        "$(ACTION_ID).pb",
    ],
)

py_library(
    name = "library",
    srcs = ["library.py"],
)

And aspect.bzl

def _impl(target, ctx):
    print([a.mnemonic for a in target.actions])
    return []

debug = aspect(
    implementation = _impl,
)

Running the commands yields:

$ bazel build --experimental_action_listener=//dummy:py_listener //dummy:library
...
$ cat $ cat bazel-out/k8-fastbuild/extra_actions/dummy/debug/dummy/5a77db9045fb63dcc930dd78ea2df50dabf4ae0aabadcd8176ede0cbff2b5c1e.txt
Action Executed
$ bazel build --aspectc=//dummy:aspect.bzl%debug //dummy:library
$ bazel build --aspects=dummy/aspect.bzl%debug //dummy:library
INFO: Build option --experimental_action_listener has changed, discarding analysis cache.
DEBUG: /usr/local/google/home/shahms/src/kythe/dummy/aspect.bzl:2:10: []
...
$

(Note, in particular, the empty list of action mnemonics in the DEBUG line)

What operating system are you running Bazel on?

Ubuntu

What's the output of bazel info release?

release 4.0.0

@brandjon brandjon added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Build-Language type: bug and removed team-Starlark untriaged labels Feb 19, 2021
@shahms
Copy link
Author

shahms commented Jun 4, 2021

It looks like this is somewhat intentional:

  void addPyExtraActionPseudoAction() {
    if (ruleContext.getConfiguration().getActionListeners().isEmpty()) {
      return;
    }

Just removing that check fixes the issue, although I'm not sure about other impact it may have.

@brandjon brandjon added untriaged team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts and removed team-Build-Language labels Nov 4, 2022
@comius comius removed the untriaged label Feb 15, 2023
@comius
Copy link
Contributor

comius commented Feb 15, 2023

I believe pseudo actions were added just to support extra_actions and will be removed.

Is there something you can't access using an aspect? The info should be there.

@shahms
Copy link
Author

shahms commented Feb 15, 2023

When migrating from extra_actions to aspects, it's simplest to avoid changing too much at once and there remain rule implementations which only expose relevant information via pseudo actions (which were, indeed, only added to support extra_action). I don't think it's particularly critical that they remain, but it's a stumbling block when migrating.

@comius comius added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) labels Feb 15, 2023
@comius
Copy link
Contributor

comius commented Feb 15, 2023

Ah ok, if it helps you move faster, please submit a PR (maybe you need to update Starlarkified calls as well). But consider pseudo actions deprecated.

@shahms
Copy link
Author

shahms commented Feb 16, 2023

At this point I believe we've already worked around the problem, but it was a speedbump to do so.

Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: bug
Projects
None yet
Development

No branches or pull requests

4 participants