Skip to content

Commit

Permalink
Fix error in worker declaration example sniplet
Browse files Browse the repository at this point in the history
With line:
```
  executable=ctx.attr.worker,
```
I got error like:
```
Error in run: in call to run(), parameter 'executable' got value of type 'Target', want 'File, string, or FilesToRunProvider'
```

Closes bazelbuild#14018.

PiperOrigin-RevId: 398826360
  • Loading branch information
bozaro authored and copybara-github committed Sep 24, 2021
1 parent 331370c commit b2a4983
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions site/docs/creating-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ for singleplex workers.

```json
{
args : [--some_argument],
inputs : [
{ /path/to/my/file/1 : fdk3e2ml23d},
{ /path/to/my/file/2 : 1fwqd4qdd }
],
request_id : 12
"args" : ["--some_argument"],
"inputs" : [
{ "/path/to/my/file/1" : "fdk3e2ml23d"},
{ "/path/to/my/file/2" : "1fwqd4qdd" }
],
"request_id" : 12
}
```

Expand All @@ -70,10 +70,9 @@ to redirect the `stdout` of any tools it uses to `stderr`.

```json
{
“exit_code” : 1,
“output” : “Action failed with the following message:\nCould not find input
file “/path/to/my/file/1”,
“request_id” : 12
"exit_code" : 1,
"output" : "Action failed with the following message:\nCould not find input file \"/path/to/my/file/1\"",
"request_id" : 12
}
```

Expand All @@ -84,7 +83,7 @@ id, so the request id must be specified if it is nonzero. This is a valid

```json
{
request_id : 12,
"request_id" : 12,
}
```

Expand Down Expand Up @@ -152,8 +151,8 @@ associated rule:

```python
java_binary(
name = worker,
srcs = [MyWorker.Java],
name = "worker",
srcs = ["MyWorker.Java"],
)
```

Expand Down Expand Up @@ -187,12 +186,12 @@ actions have a couple of requirements.
rule can write non-startup arguments for the worker to this flagfile.

* The _“execution-requirements”_ field, which takes a dictionary containing
`supports-workers : “1”`, `supports-multiplex-workers : “1”`, or both.
`"supports-workers" : "1"`, `"supports-multiplex-workers" : "1"`, or both.

The "arguments" and "execution-requirements" fields are required for all
actions sent to workers. Additionally, actions that should be executed by
JSON workers need to include `requires-worker-protocol : json` in the
execution requirements field. `requires-worker-protocol : proto` is also
JSON workers need to include `"requires-worker-protocol" : "json"` in the
execution requirements field. `"requires-worker-protocol" : "proto"` is also
a valid execution requirement, though it’s not required for proto workers,
since they are the default.

Expand All @@ -215,13 +214,14 @@ startup args, the call to `ctx.actions.run` might be:
```python
ctx.actions.run(
inputs=ctx.files.srcs,
outputs=[ctx.attr.output],
executable=ctx.attr.worker,
outputs=[ctx.outputs.output],
executable=ctx.executable.worker,
mnemonic="someMnemonic",
execution_requirements={
“supports-workers” : “1”,
“requires-worker-protocol” : “json},
arguments=ctx.attr.args + [“@flagfile”]
"supports-workers" : "1",
"requires-worker-protocol" : "json",
},
arguments=ctx.attr.args + ["@flagfile"]
)
```

Expand Down

0 comments on commit b2a4983

Please sign in to comment.