Polber commented on code in PR #30007: URL: https://github.com/apache/beam/pull/30007#discussion_r1458113195
########## sdks/python/apache_beam/yaml/README.md: ########## @@ -48,6 +48,40 @@ It should be noted that everything here is still under development, but any features already included are considered stable. Feedback is welcome at [email protected]. +## Running pipelines + +The Beam yaml parser is currently included as part of the Apache Beam Python SDK. +This can be installed (e.g. within a virtual environment) as + +``` +pip install apache_beam[yaml,gcp] +``` + +In addition, several of the provided transforms (such as SQL) are implemented +in Java and their expansion will require a working Java interpeter. (The +requisite artifacts will be automatically downloaded from the apache maven +repositories, so no further installs will be required.) +Docker is also currently required for local execution of these +cross-language-requiring transforms, but not for submission to a non-local +runner such as Flink or Dataflow. + +Once the prerequisites are installed, you can execute a pipeline defined +in a yaml file as + +``` +python -m apache_beam.yaml.main --yaml_pipeline_file=/path/to/pipeline.yaml [other pipeline options such as the runner] +``` + +You can do a dry-run of your pipeline using the render runner to see what the +execution graph is, e.g. + +``` +python -m apache_beam.yaml.main --yaml_pipeline_file=/path/to/pipeline.yaml --runner=apache_beam.runners.render.RenderRunner --render_output=out.png [--render_port=0] +``` Review Comment: It might be nice to mention that graphviz must be installed. I had to install it using these instructions: https://graphviz.org/download/ ########## sdks/python/apache_beam/yaml/yaml_provider.py: ########## @@ -554,17 +554,28 @@ def create_builtin_provider(): def create(elements: Iterable[Any], reshuffle: Optional[bool] = True): """Creates a collection containing a specified set of elements. - YAML/JSON-style mappings will be interpreted as Beam rows. For example:: + This transform always produces schema'd data. For example:: type: Create - elements: - - {first: 0, second: {str: "foo", values: [1, 2, 3]}} + config: + elements: [1, 2, 3] + + will result in an output with three elements with a schema of + Row(element=int) whereas YAML/JSON-style mappings will be interpreted + directly as Beam rows, e.g.:: + + type: Create + config: + elements: + - {first: 0, second: {str: "foo", values: [1, 2, 3]}} + - {first: 1, second: {str: "bar", values: [4, 5, 6]}} will result in a schema of the form (int, Row(string, List[int])). Review Comment: I added something similar in one of my PR's, if you want to add it here I can rebase mine on master (or exclude it entirely). ```suggestion will result in a schema of the form (int, Row(string, List[int])). This can also be expressed as YAML: type: Create config: elements: - first: 0 second: str: "foo" values: [1, 2, 3] - first: 1 second: str: "bar" values: [4, 5, 6] ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
