diff options
Diffstat (limited to 'examples/jsonnet')
-rw-r--r-- | examples/jsonnet/BUILD | 67 | ||||
-rw-r--r-- | examples/jsonnet/intersection.jsonnet | 60 | ||||
-rw-r--r-- | examples/jsonnet/intersection_golden.json | 48 | ||||
-rw-r--r-- | examples/jsonnet/invalid.jsonnet | 15 | ||||
-rw-r--r-- | examples/jsonnet/invalid.out | 2 | ||||
-rw-r--r-- | examples/jsonnet/shell-workflows.jsonnet | 21 | ||||
-rw-r--r-- | examples/jsonnet/wordcount.jsonnet | 59 | ||||
-rw-r--r-- | examples/jsonnet/wordcount_golden.json | 53 | ||||
-rw-r--r-- | examples/jsonnet/workflow.jsonnet | 46 |
9 files changed, 0 insertions, 371 deletions
diff --git a/examples/jsonnet/BUILD b/examples/jsonnet/BUILD deleted file mode 100644 index 72bc4eee69..0000000000 --- a/examples/jsonnet/BUILD +++ /dev/null @@ -1,67 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load( - "//tools/build_defs/jsonnet:jsonnet.bzl", - "jsonnet_library", - "jsonnet_to_json", - "jsonnet_to_json_test", -) - -jsonnet_library( - name = "workflow", - srcs = ["workflow.jsonnet"], -) - -jsonnet_to_json( - name = "wordcount", - src = "wordcount.jsonnet", - outs = ["wordcount.json"], - deps = [":workflow"], -) - -jsonnet_to_json_test( - name = "wordcount_test", - src = "wordcount.jsonnet", - golden = "wordcount_golden.json", - deps = [":workflow"], -) - -jsonnet_to_json( - name = "intersection", - src = "intersection.jsonnet", - outs = ["intersection.json"], - deps = [":workflow"], -) - -jsonnet_to_json_test( - name = "intersection_test", - src = "intersection.jsonnet", - golden = "intersection_golden.json", - deps = [":workflow"], -) - -jsonnet_library( - name = "shell-workflows-lib", - srcs = [ - "intersection.jsonnet", - "wordcount.jsonnet", - ], - deps = [":workflow"], -) - -jsonnet_to_json( - name = "shell-workflows", - src = "shell-workflows.jsonnet", - outs = [ - "intersection-workflow.json", - "wordcount-workflow.json", - ], - deps = [":shell-workflows-lib"], -) - -jsonnet_to_json_test( - name = "invalid_test", - src = "invalid.jsonnet", - error = 1, - golden = "invalid.out", -) diff --git a/examples/jsonnet/intersection.jsonnet b/examples/jsonnet/intersection.jsonnet deleted file mode 100644 index 17aa6a36ba..0000000000 --- a/examples/jsonnet/intersection.jsonnet +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -local workflow = import "examples/jsonnet/workflow.jsonnet"; - -// Workflow that performs an intersection of two files using shell commands. -{ - intersection: workflow.Workflow { - jobs: { - local input_file1 = "/tmp/list1", - local input_file2 = "/tmp/list2", - local sorted_file1 = "/tmp/list1_sorted", - local sorted_file2 = "/tmp/list2_sorted", - local intersection = "/tmp/intersection", - - SortJob:: workflow.ShJob { - input_file:: "", - output_file:: "", - command: "sort %s > %s" % [self.input_file, self.output_file], - inputs: [self.input_file], - outputs: [self.output_file], - }, - - sort_file1: self.SortJob { - input_file:: input_file1, - output_file:: sorted_file1, - }, - - sort_file2: self.SortJob { - input_file:: input_file2, - output_file:: sorted_file2, - }, - - intersect: workflow.ShJob { - deps: [ - ":sort_file1", - ":sort_file2", - ], - command: "comm -12 %s %s > %s" % - [sorted_file1, sorted_file2, intersection], - inputs: [ - sorted_file1, - sorted_file2, - ], - outputs: [intersection], - }, - } - } -} diff --git a/examples/jsonnet/intersection_golden.json b/examples/jsonnet/intersection_golden.json deleted file mode 100644 index 6e8fa63864..0000000000 --- a/examples/jsonnet/intersection_golden.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "intersection": { - "jobs": { - "intersect": { - "command": "comm -12 /tmp/list1_sorted /tmp/list2_sorted > /tmp/intersection", - "deps": [ - ":sort_file1", - ":sort_file2" - ], - "inputs": [ - "/tmp/list1_sorted", - "/tmp/list2_sorted" - ], - "outputs": [ - "/tmp/intersection" - ], - "type": "sh", - "vars": { } - }, - "sort_file1": { - "command": "sort /tmp/list1 > /tmp/list1_sorted", - "deps": [ ], - "inputs": [ - "/tmp/list1" - ], - "outputs": [ - "/tmp/list1_sorted" - ], - "type": "sh", - "vars": { } - }, - "sort_file2": { - "command": "sort /tmp/list2 > /tmp/list2_sorted", - "deps": [ ], - "inputs": [ - "/tmp/list2" - ], - "outputs": [ - "/tmp/list2_sorted" - ], - "type": "sh", - "vars": { } - } - }, - "retries": 5, - "schedule": { } - } -} diff --git a/examples/jsonnet/invalid.jsonnet b/examples/jsonnet/invalid.jsonnet deleted file mode 100644 index e911037832..0000000000 --- a/examples/jsonnet/invalid.jsonnet +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -error "Foo." diff --git a/examples/jsonnet/invalid.out b/examples/jsonnet/invalid.out deleted file mode 100644 index 6c220f5170..0000000000 --- a/examples/jsonnet/invalid.out +++ /dev/null @@ -1,2 +0,0 @@ -RUNTIME ERROR: Foo. - examples/jsonnet/invalid.jsonnet:15:1-12 diff --git a/examples/jsonnet/shell-workflows.jsonnet b/examples/jsonnet/shell-workflows.jsonnet deleted file mode 100644 index bcf44c76ec..0000000000 --- a/examples/jsonnet/shell-workflows.jsonnet +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -local wordcount = import "examples/jsonnet/wordcount.jsonnet"; -local intersection = import "examples/jsonnet/intersection.jsonnet"; - -{ - "wordcount-workflow.json": wordcount, - "intersection-workflow.json": intersection, -} diff --git a/examples/jsonnet/wordcount.jsonnet b/examples/jsonnet/wordcount.jsonnet deleted file mode 100644 index f1dfe2bfef..0000000000 --- a/examples/jsonnet/wordcount.jsonnet +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -local workflow = import "examples/jsonnet/workflow.jsonnet"; - -// Workflow that performs a wordcount using shell commands. -{ - wordcount: workflow.Workflow { - retries: 12, - schedule: workflow.Schedule { - start_date: "2015-11-15", - start_time: "17:30", - repeat_frequency: 1, - repeat_type: "week", - }, - jobs: { - local input_file = "/tmp/passage_test", - local tokens_file = "/tmp/tokens", - local sorted_tokens_file = "/tmp/sorted_tokens", - local counts_file = "/tmp/counts", - - // Reads the input file and produces an output file with one word per - // line. - tokenize: workflow.ShJob { - command: "tr ' ' '\n' < %s > %s" % [input_file, tokens_file], - inputs: [input_file], - outputs: [tokens_file], - }, - - // Takes the tokens file and produces a file with the tokens sorted. - sort: workflow.ShJob { - deps: [":tokenize"], - command: "sort %s > %s" % [tokens_file, sorted_tokens_file], - inputs: [tokens_file], - outputs: [sorted_tokens_file], - }, - - // Takes the file containing sorted tokens and produces a file containing - // the counts for each word. - count: workflow.ShJob { - deps: [":sort"], - command: "uniq -c %s > %s" % [sorted_tokens_file, counts_file], - inputs: [sorted_tokens_file], - outputs: [counts_file], - }, - } - } -} diff --git a/examples/jsonnet/wordcount_golden.json b/examples/jsonnet/wordcount_golden.json deleted file mode 100644 index 25d99cf3ab..0000000000 --- a/examples/jsonnet/wordcount_golden.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "wordcount": { - "jobs": { - "count": { - "command": "uniq -c /tmp/sorted_tokens > /tmp/counts", - "deps": [ - ":sort" - ], - "inputs": [ - "/tmp/sorted_tokens" - ], - "outputs": [ - "/tmp/counts" - ], - "type": "sh", - "vars": { } - }, - "sort": { - "command": "sort /tmp/tokens > /tmp/sorted_tokens", - "deps": [ - ":tokenize" - ], - "inputs": [ - "/tmp/tokens" - ], - "outputs": [ - "/tmp/sorted_tokens" - ], - "type": "sh", - "vars": { } - }, - "tokenize": { - "command": "tr ' ' '\n' < /tmp/passage_test > /tmp/tokens", - "deps": [ ], - "inputs": [ - "/tmp/passage_test" - ], - "outputs": [ - "/tmp/tokens" - ], - "type": "sh", - "vars": { } - } - }, - "retries": 12, - "schedule": { - "repeat_frequency": 1, - "repeat_type": "week", - "start_date": "2015-11-15", - "start_time": "17:30" - } - } -} diff --git a/examples/jsonnet/workflow.jsonnet b/examples/jsonnet/workflow.jsonnet deleted file mode 100644 index a093a0ec38..0000000000 --- a/examples/jsonnet/workflow.jsonnet +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Configuration for a hypothetical workflow scheduling system. -{ - // Configuration for a workflow. - Workflow:: { - schedule: {}, - retries: 5, - jobs: {}, - }, - - // Scheduling configuration for a workflow. - Schedule:: { - start_date: "", - start_time: "", - repeat_frequency: 0, - repeat_type: "", - }, - - // Base configuration for a Job in a workflow. - Job:: { - type: "base", - deps: [], - inputs: [], - outputs: [], - }, - - // Configuration for a job that runs a shell command. - ShJob:: self.Job { - type: "sh", - command: "", - vars: {}, - } -} |