tvalentyn commented on code in PR #31495: URL: https://github.com/apache/beam/pull/31495#discussion_r1679997222
########## sdks/python/apache_beam/transforms/managed.py: ########## @@ -0,0 +1,173 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. +# + +"""Managed Transforms. + +This module builds and instantiates turnkey transforms that can be managed by Review Comment: what does 'managed by the runner' practically mean for a user? or where to find more information about it? ########## sdks/python/apache_beam/transforms/managed.py: ########## @@ -0,0 +1,173 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. +# + +"""Managed Transforms. + +This module builds and instantiates turnkey transforms that can be managed by +the underlying runner. + +Using Managed Transforms +======================== +Managed transforms have a defined configuration and can be built using an +inline :class:`dict` like so:: + + results = p | beam.managed.Read( + beam.managed.ICEBERG, Review Comment: I am curious about the boundaries for the 'managed' scope. 1) Is it always a source/sink, or potentially any transform? 2) is the transform being managed is named 'Read'? if so, why I wonder if beam.managed.ICEBERG should be part of a config instead of a separate argument here. ########## sdks/python/apache_beam/transforms/managed.py: ########## @@ -0,0 +1,173 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. +# + +"""Managed Transforms. + +This module builds and instantiates turnkey transforms that can be managed by +the underlying runner. + +Using Managed Transforms +======================== +Managed transforms have a defined configuration and can be built using an +inline :class:`dict` like so:: + + results = p | beam.managed.Read( + beam.managed.ICEBERG, + config={"param_1": "foo", + "param_2": "bar"}) + +A YAML configuration file can also be used to build a Managed transform. Say we +have the following `config.yaml` file:: + + param_1: "foo" + param_2: "bar" + +Simply provide the location to the file like so:: + + input_rows = p | beam.Create(...) + input_rows | beam.managed.Write( + beam.managed.KAFKA, + config_url="path/to/config.yaml") + +Available transforms +==================== +Available transforms are: + +- **Kafka** +- **Iceberg** + +**Note:** inputs and outputs need to be PCollections of Beam +:py:class:`apache_beam.pvalue.Row` elements. + +**Note:** This Managed API uses Java's ManagedSchemaTransform under the hood. +""" + +from typing import Any +from typing import Dict +from typing import Optional + +import yaml + +from apache_beam.transforms.external import BeamJarExpansionService +from apache_beam.transforms.external import SchemaAwareExternalTransform +from apache_beam.transforms.ptransform import PTransform + +ICEBERG = "iceberg" +KAFKA = "kafka" +_MANAGED_IDENTIFIER = "beam:transform:managed:v1" +_GRADLE_TARGETS = { + "sdks:java:io:expansion-service:shadowJar": [KAFKA, ICEBERG], +} + +__all__ = ["ICEBERG", "KAFKA", "Read", "Write"] + + +class Read(PTransform): + """Read using Managed Transforms""" + READ_TRANSFORMS = { + ICEBERG: "beam:schematransform:org.apache.beam:iceberg_read:v1", Review Comment: I think we should define the URNs in protos and reference through common_urns.py or python_urns.py instead since this is shared across SDKs? ########## sdks/python/apache_beam/transforms/managed.py: ########## @@ -0,0 +1,173 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. +# + +"""Managed Transforms. + +This module builds and instantiates turnkey transforms that can be managed by +the underlying runner. + +Using Managed Transforms +======================== +Managed transforms have a defined configuration and can be built using an +inline :class:`dict` like so:: + + results = p | beam.managed.Read( + beam.managed.ICEBERG, + config={"param_1": "foo", + "param_2": "bar"}) + +A YAML configuration file can also be used to build a Managed transform. Say we +have the following `config.yaml` file:: + + param_1: "foo" + param_2: "bar" + +Simply provide the location to the file like so:: + + input_rows = p | beam.Create(...) + input_rows | beam.managed.Write( + beam.managed.KAFKA, + config_url="path/to/config.yaml") + +Available transforms +==================== +Available transforms are: + +- **Kafka** +- **Iceberg** + +**Note:** inputs and outputs need to be PCollections of Beam +:py:class:`apache_beam.pvalue.Row` elements. + +**Note:** This Managed API uses Java's ManagedSchemaTransform under the hood. +""" + +from typing import Any +from typing import Dict +from typing import Optional + +import yaml + +from apache_beam.transforms.external import BeamJarExpansionService +from apache_beam.transforms.external import SchemaAwareExternalTransform +from apache_beam.transforms.ptransform import PTransform + +ICEBERG = "iceberg" +KAFKA = "kafka" +_MANAGED_IDENTIFIER = "beam:transform:managed:v1" +_GRADLE_TARGETS = { + "sdks:java:io:expansion-service:shadowJar": [KAFKA, ICEBERG], +} + +__all__ = ["ICEBERG", "KAFKA", "Read", "Write"] + + +class Read(PTransform): + """Read using Managed Transforms""" + READ_TRANSFORMS = { Review Comment: should we s/READ_TRANSFORMS/_READ_TRANSFORMS? or is it intentionally public so that it can be dynamically modified? ########## sdks/python/apache_beam/transforms/managed.py: ########## @@ -0,0 +1,173 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. +# + +"""Managed Transforms. + +This module builds and instantiates turnkey transforms that can be managed by +the underlying runner. + +Using Managed Transforms +======================== +Managed transforms have a defined configuration and can be built using an +inline :class:`dict` like so:: + + results = p | beam.managed.Read( + beam.managed.ICEBERG, + config={"param_1": "foo", + "param_2": "bar"}) + +A YAML configuration file can also be used to build a Managed transform. Say we +have the following `config.yaml` file:: + + param_1: "foo" + param_2: "bar" + +Simply provide the location to the file like so:: + + input_rows = p | beam.Create(...) + input_rows | beam.managed.Write( + beam.managed.KAFKA, + config_url="path/to/config.yaml") + +Available transforms +==================== +Available transforms are: + +- **Kafka** Review Comment: Consider: - "Read and Write for Apache Kafka" - "Read and Write for Apache Iceberg" ########## sdks/python/apache_beam/transforms/managed.py: ########## @@ -0,0 +1,173 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. +# + +"""Managed Transforms. + +This module builds and instantiates turnkey transforms that can be managed by +the underlying runner. + +Using Managed Transforms +======================== +Managed transforms have a defined configuration and can be built using an +inline :class:`dict` like so:: + + results = p | beam.managed.Read( + beam.managed.ICEBERG, + config={"param_1": "foo", + "param_2": "bar"}) + +A YAML configuration file can also be used to build a Managed transform. Say we +have the following `config.yaml` file:: + + param_1: "foo" Review Comment: would it make sense to provide a real kafka config here? -- 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]
