34 lines
No EOL
1.2 KiB
Markdown
34 lines
No EOL
1.2 KiB
Markdown
# Basic Graph - Random Number Generator
|
|
|
|
This example demonstrates a databuild_job that generates a random number seeded based on the partition ref.
|
|
|
|
## Configure
|
|
|
|
```bash
|
|
$ bazel run //:generate_number_job.cfg test_output
|
|
{"outputs":["test_output"],"inputs":[],"args":["test_output"],"env":{}}
|
|
```
|
|
|
|
## Execute
|
|
|
|
Generates a random number based on the hash of the partition ref and writes it to the output file.
|
|
|
|
```bash
|
|
$ bazel run //:generate_number_job.cfg test_output | bazel run //:generate_number_job
|
|
```
|
|
|
|
This will generate a random number for the partition "test_output" and write it to a file named "test_output".
|
|
|
|
You can verify that the random number is stable for the same partition ref by running the command multiple times:
|
|
|
|
```bash
|
|
$ bazel run //:generate_number_job.cfg test_output1 | bazel run //:generate_number_job
|
|
$ bazel run //:generate_number_job.cfg test_output1 | bazel run //:generate_number_job
|
|
```
|
|
|
|
And you can verify that different partition refs produce different random numbers:
|
|
|
|
```bash
|
|
$ bazel run //:generate_number_job.cfg test_output1 | bazel run //:generate_number_job
|
|
$ bazel run //:generate_number_job.cfg test_output2 | bazel run //:generate_number_job
|
|
``` |