From 17deeef402dc6d51d2e43f6c7aa1abc3490ab7c7 Mon Sep 17 00:00:00 2001 From: Danny Mccormick Date: Fri, 31 Oct 2025 10:49:38 -0400 Subject: [PATCH 1/9] Split some dependencies out of main beam package --- sdks/python/setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdks/python/setup.py b/sdks/python/setup.py index 9ed2a124e94d..e09ad86890c8 100644 --- a/sdks/python/setup.py +++ b/sdks/python/setup.py @@ -379,14 +379,12 @@ def get_portability_package_data(): install_requires=[ 'crcmod>=1.7,<2.0', 'cryptography>=39.0.0,<48.0.0', - 'orjson>=3.9.7,<4', 'fastavro>=0.23.6,<2', 'fasteners>=0.3,<1.0', # TODO(https://github.com/grpc/grpc/issues/37710): Unpin grpc 'grpcio>=1.33.1,<2,!=1.48.0,!=1.59.*,!=1.60.*,!=1.61.*,!=1.62.0,!=1.62.1,<1.66.0; python_version <= "3.12"', # pylint: disable=line-too-long 'grpcio>=1.67.0; python_version >= "3.13"', 'hdfs>=2.1.0,<3.0.0', - 'httplib2>=0.8,<0.23.0', 'jsonschema>=4.0.0,<5.0.0', 'jsonpickle>=3.0.0,<4.0.0', # numpy can have breaking changes in minor versions. @@ -411,7 +409,6 @@ def get_portability_package_data(): 'python-dateutil>=2.8.0,<3', 'pytz>=2018.3', 'redis>=5.0.0,<6', - 'regex>=2020.6.8', 'requests>=2.32.4,<3.0.0', 'sortedcontainers>=2.4.0', 'typing-extensions>=3.7.0', @@ -509,7 +506,10 @@ def get_portability_package_data(): # --extra-index-url or --index-url in requirements.txt in # Dataflow, which allows installing python packages from private # Python repositories in GAR. - 'keyrings.google-artifactregistry-auth' + 'keyrings.google-artifactregistry-auth', + 'httplib2>=0.8,<0.23.0', + 'orjson>=3.9.7,<4', + 'regex>=2020.6.8', ], 'interactive': [ 'facets-overview>=1.1.0,<2', From b79c3295a65daba256bc51833718dc7d2fd717fb Mon Sep 17 00:00:00 2001 From: Danny Mccormick Date: Fri, 31 Oct 2025 10:53:14 -0400 Subject: [PATCH 2/9] httplib used more broadly --- sdks/python/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/python/setup.py b/sdks/python/setup.py index e09ad86890c8..d9b35ae4c7be 100644 --- a/sdks/python/setup.py +++ b/sdks/python/setup.py @@ -385,6 +385,7 @@ def get_portability_package_data(): 'grpcio>=1.33.1,<2,!=1.48.0,!=1.59.*,!=1.60.*,!=1.61.*,!=1.62.0,!=1.62.1,<1.66.0; python_version <= "3.12"', # pylint: disable=line-too-long 'grpcio>=1.67.0; python_version >= "3.13"', 'hdfs>=2.1.0,<3.0.0', + 'httplib2>=0.8,<0.23.0', 'jsonschema>=4.0.0,<5.0.0', 'jsonpickle>=3.0.0,<4.0.0', # numpy can have breaking changes in minor versions. @@ -507,7 +508,6 @@ def get_portability_package_data(): # Dataflow, which allows installing python packages from private # Python repositories in GAR. 'keyrings.google-artifactregistry-auth', - 'httplib2>=0.8,<0.23.0', 'orjson>=3.9.7,<4', 'regex>=2020.6.8', ], From 29344d51fff1d2908b375d968b21b06db6ffcaf5 Mon Sep 17 00:00:00 2001 From: Danny Mccormick Date: Fri, 31 Oct 2025 10:56:16 -0400 Subject: [PATCH 3/9] A few more split outs --- sdks/python/setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdks/python/setup.py b/sdks/python/setup.py index d9b35ae4c7be..534324b83c18 100644 --- a/sdks/python/setup.py +++ b/sdks/python/setup.py @@ -386,7 +386,6 @@ def get_portability_package_data(): 'grpcio>=1.67.0; python_version >= "3.13"', 'hdfs>=2.1.0,<3.0.0', 'httplib2>=0.8,<0.23.0', - 'jsonschema>=4.0.0,<5.0.0', 'jsonpickle>=3.0.0,<4.0.0', # numpy can have breaking changes in minor versions. # Use a strict upper bound. @@ -406,7 +405,6 @@ def get_portability_package_data(): # 3. Exclude protobuf 4 versions that leak memory, see: # https://github.com/apache/beam/issues/28246 'protobuf>=3.20.3,<7.0.0.dev0,!=4.0.*,!=4.21.*,!=4.22.0,!=4.23.*,!=4.24.*', # pylint: disable=line-too-long - 'pydot>=1.2.0,<2', 'python-dateutil>=2.8.0,<3', 'pytz>=2018.3', 'redis>=5.0.0,<6', @@ -520,6 +518,7 @@ def get_portability_package_data(): # Skip version 6.1.13 due to # https://github.com/jupyter/jupyter_client/issues/637 'jupyter-client>=6.1.11,!=6.1.13,<8.2.1', + 'pydot>=1.2.0,<2', 'timeloop>=1.0.2,<2', 'nbformat>=5.0.5,<6', 'nbconvert>=6.2.0,<8', @@ -577,6 +576,7 @@ def get_portability_package_data(): 'virtualenv-clone>=0.5,<1.0', # https://github.com/PiotrDabkowski/Js2Py/issues/317 'js2py>=0.74,<1; python_version<"3.12"', + 'jsonschema>=4.0.0,<5.0.0', ] + dataframe_dependency, # Keep the following dependencies in line with what we test against # in https://github.com/apache/beam/blob/master/sdks/python/tox.ini From 4add682cd8d3ecd616a7b1a9ff9aaf31762b0336 Mon Sep 17 00:00:00 2001 From: Danny Mccormick Date: Fri, 31 Oct 2025 11:50:00 -0400 Subject: [PATCH 4/9] Try to fix linting --- sdks/python/apache_beam/io/gcp/bigquery_tools.py | 2 +- .../apache_beam/runners/interactive/display/pipeline_graph.py | 3 +-- sdks/python/apache_beam/yaml/json_utils.py | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/sdks/python/apache_beam/io/gcp/bigquery_tools.py b/sdks/python/apache_beam/io/gcp/bigquery_tools.py index b2fedb1746d4..c94f58e9e9e0 100644 --- a/sdks/python/apache_beam/io/gcp/bigquery_tools.py +++ b/sdks/python/apache_beam/io/gcp/bigquery_tools.py @@ -46,9 +46,9 @@ import fastavro import numpy as np -import regex import apache_beam +import regex from apache_beam import coders from apache_beam.internal.gcp import auth from apache_beam.internal.gcp.json_value import from_json_value diff --git a/sdks/python/apache_beam/runners/interactive/display/pipeline_graph.py b/sdks/python/apache_beam/runners/interactive/display/pipeline_graph.py index 1f1e315fea09..384c6989aad7 100644 --- a/sdks/python/apache_beam/runners/interactive/display/pipeline_graph.py +++ b/sdks/python/apache_beam/runners/interactive/display/pipeline_graph.py @@ -32,9 +32,8 @@ from typing import Tuple from typing import Union -import pydot - import apache_beam as beam +import pydot from apache_beam.portability.api import beam_runner_api_pb2 from apache_beam.runners.interactive import interactive_environment as ie from apache_beam.runners.interactive import pipeline_instrument as inst diff --git a/sdks/python/apache_beam/yaml/json_utils.py b/sdks/python/apache_beam/yaml/json_utils.py index 2d8f32051973..c33af89569f3 100644 --- a/sdks/python/apache_beam/yaml/json_utils.py +++ b/sdks/python/apache_beam/yaml/json_utils.py @@ -25,9 +25,8 @@ from typing import Any from typing import Optional -import jsonschema - import apache_beam as beam +import jsonschema from apache_beam.portability.api import schema_pb2 from apache_beam.typehints import schemas From 3c1bb8dbeb78c909d8aba57f4573a04337440904 Mon Sep 17 00:00:00 2001 From: Danny Mccormick Date: Fri, 31 Oct 2025 14:37:09 -0400 Subject: [PATCH 5/9] Guard imports --- sdks/python/apache_beam/io/gcp/bigquery_tools.py | 2 +- .../runners/interactive/display/pipeline_graph.py | 6 +++++- sdks/python/apache_beam/yaml/json_utils.py | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/sdks/python/apache_beam/io/gcp/bigquery_tools.py b/sdks/python/apache_beam/io/gcp/bigquery_tools.py index c94f58e9e9e0..ddab941f9278 100644 --- a/sdks/python/apache_beam/io/gcp/bigquery_tools.py +++ b/sdks/python/apache_beam/io/gcp/bigquery_tools.py @@ -48,7 +48,6 @@ import numpy as np import apache_beam -import regex from apache_beam import coders from apache_beam.internal.gcp import auth from apache_beam.internal.gcp.json_value import from_json_value @@ -70,6 +69,7 @@ # Protect against environments where bigquery library is not available. try: + import regex from apitools.base.py.exceptions import HttpError from apitools.base.py.exceptions import HttpForbiddenError from apitools.base.py.transfer import Upload diff --git a/sdks/python/apache_beam/runners/interactive/display/pipeline_graph.py b/sdks/python/apache_beam/runners/interactive/display/pipeline_graph.py index 384c6989aad7..10058351938e 100644 --- a/sdks/python/apache_beam/runners/interactive/display/pipeline_graph.py +++ b/sdks/python/apache_beam/runners/interactive/display/pipeline_graph.py @@ -33,12 +33,16 @@ from typing import Union import apache_beam as beam -import pydot from apache_beam.portability.api import beam_runner_api_pb2 from apache_beam.runners.interactive import interactive_environment as ie from apache_beam.runners.interactive import pipeline_instrument as inst from apache_beam.runners.interactive.display import pipeline_graph_renderer +try: + import pydot +except ImportError: + pass + # pylint does not understand context # pylint:disable=dangerous-default-value diff --git a/sdks/python/apache_beam/yaml/json_utils.py b/sdks/python/apache_beam/yaml/json_utils.py index c33af89569f3..832651a477dd 100644 --- a/sdks/python/apache_beam/yaml/json_utils.py +++ b/sdks/python/apache_beam/yaml/json_utils.py @@ -26,10 +26,14 @@ from typing import Optional import apache_beam as beam -import jsonschema from apache_beam.portability.api import schema_pb2 from apache_beam.typehints import schemas +try: + import jsonschema +except ImportError: + pass + JSON_ATOMIC_TYPES_TO_BEAM = { 'boolean': schema_pb2.BOOLEAN, 'integer': schema_pb2.INT64, From b5fac989e9f7fae001e7e398181967a1001d11ab Mon Sep 17 00:00:00 2001 From: Danny Mccormick Date: Fri, 31 Oct 2025 16:08:01 -0400 Subject: [PATCH 6/9] yaml test exclusions --- sdks/python/apache_beam/yaml/main_test.py | 6 ++++++ sdks/python/apache_beam/yaml/yaml_io_test.py | 6 ++++++ sdks/python/apache_beam/yaml/yaml_mapping_test.py | 6 ++++++ sdks/python/apache_beam/yaml/yaml_transform_test.py | 6 ++++++ sdks/python/tox.ini | 2 +- 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/sdks/python/apache_beam/yaml/main_test.py b/sdks/python/apache_beam/yaml/main_test.py index d233e0e2d73c..4f7775abc289 100644 --- a/sdks/python/apache_beam/yaml/main_test.py +++ b/sdks/python/apache_beam/yaml/main_test.py @@ -24,6 +24,11 @@ from apache_beam.yaml import main +try: + import jsonschema +except ImportError: + pass + TEST_PIPELINE = ''' pipeline: type: chain @@ -79,6 +84,7 @@ ''' +unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") class MainTest(unittest.TestCase): def test_pipeline_spec_from_file(self): with tempfile.TemporaryDirectory() as tmpdir: diff --git a/sdks/python/apache_beam/yaml/yaml_io_test.py b/sdks/python/apache_beam/yaml/yaml_io_test.py index a19dfd694a85..354b1a8d2664 100644 --- a/sdks/python/apache_beam/yaml/yaml_io_test.py +++ b/sdks/python/apache_beam/yaml/yaml_io_test.py @@ -32,6 +32,11 @@ from apache_beam.typehints import schemas as schema_utils from apache_beam.yaml.yaml_transform import YamlTransform +try: + import jsonschema +except ImportError: + pass + class FakeReadFromPubSub: def __init__( @@ -82,6 +87,7 @@ def __call__(self, topic, *, with_attributes, id_label, timestamp_attribute): return AssertThat(equal_to(self._messages)) +unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") class YamlPubSubTest(unittest.TestCase): def test_simple_read(self): with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( diff --git a/sdks/python/apache_beam/yaml/yaml_mapping_test.py b/sdks/python/apache_beam/yaml/yaml_mapping_test.py index cc2fe4639abc..0f674ca863be 100644 --- a/sdks/python/apache_beam/yaml/yaml_mapping_test.py +++ b/sdks/python/apache_beam/yaml/yaml_mapping_test.py @@ -30,6 +30,11 @@ from apache_beam.yaml import yaml_mapping from apache_beam.yaml.yaml_transform import YamlTransform +try: + import jsonschema +except ImportError: + pass + DATA = [ beam.Row(label='11a', conductor=11, rank=0), beam.Row(label='37a', conductor=37, rank=1), @@ -37,6 +42,7 @@ ] +unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") class YamlMappingTest(unittest.TestCase): def test_basic(self): with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( diff --git a/sdks/python/apache_beam/yaml/yaml_transform_test.py b/sdks/python/apache_beam/yaml/yaml_transform_test.py index 2ba49a1fab82..0038c6fc99ca 100644 --- a/sdks/python/apache_beam/yaml/yaml_transform_test.py +++ b/sdks/python/apache_beam/yaml/yaml_transform_test.py @@ -29,6 +29,11 @@ from apache_beam.yaml import yaml_provider from apache_beam.yaml.yaml_transform import YamlTransform +try: + import jsonschema +except ImportError: + pass + class CreateTimestamped(beam.PTransform): _yaml_requires_inputs = False @@ -83,6 +88,7 @@ def raise_on_big(row): } +unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") class YamlTransformE2ETest(unittest.TestCase): def test_composite(self): with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( diff --git a/sdks/python/tox.ini b/sdks/python/tox.ini index 8ea95ad8fc8b..921833d9f4b5 100644 --- a/sdks/python/tox.ini +++ b/sdks/python/tox.ini @@ -33,7 +33,7 @@ pip_pre = True # allow apps that support color to use it. passenv=TERM,CLOUDSDK_CONFIG,DOCKER_*,TESTCONTAINERS_*,TC_*,ALLOYDB_PASSWORD # Set [] options for pip installation of apache-beam tarball. -extras = test,dataframe +extras = test,dataframe,yaml # Don't warn that these commands aren't installed. allowlist_externals = false From ef5e2c9026aa5ec9eea0b1a4ca6ef9255e0b5d36 Mon Sep 17 00:00:00 2001 From: Danny Mccormick Date: Fri, 31 Oct 2025 16:26:18 -0400 Subject: [PATCH 7/9] yapf --- sdks/python/apache_beam/yaml/main_test.py | 3 ++- sdks/python/apache_beam/yaml/yaml_io_test.py | 2 ++ sdks/python/apache_beam/yaml/yaml_mapping_test.py | 3 ++- sdks/python/apache_beam/yaml/yaml_transform_test.py | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sdks/python/apache_beam/yaml/main_test.py b/sdks/python/apache_beam/yaml/main_test.py index 4f7775abc289..4156dd6014ee 100644 --- a/sdks/python/apache_beam/yaml/main_test.py +++ b/sdks/python/apache_beam/yaml/main_test.py @@ -83,8 +83,9 @@ - element: x ''' - unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") + + class MainTest(unittest.TestCase): def test_pipeline_spec_from_file(self): with tempfile.TemporaryDirectory() as tmpdir: diff --git a/sdks/python/apache_beam/yaml/yaml_io_test.py b/sdks/python/apache_beam/yaml/yaml_io_test.py index 354b1a8d2664..e88e6bf92698 100644 --- a/sdks/python/apache_beam/yaml/yaml_io_test.py +++ b/sdks/python/apache_beam/yaml/yaml_io_test.py @@ -88,6 +88,8 @@ def __call__(self, topic, *, with_attributes, id_label, timestamp_attribute): unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") + + class YamlPubSubTest(unittest.TestCase): def test_simple_read(self): with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( diff --git a/sdks/python/apache_beam/yaml/yaml_mapping_test.py b/sdks/python/apache_beam/yaml/yaml_mapping_test.py index 0f674ca863be..c2a0e1f45190 100644 --- a/sdks/python/apache_beam/yaml/yaml_mapping_test.py +++ b/sdks/python/apache_beam/yaml/yaml_mapping_test.py @@ -41,8 +41,9 @@ beam.Row(label='389a', conductor=389, rank=2), ] - unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") + + class YamlMappingTest(unittest.TestCase): def test_basic(self): with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( diff --git a/sdks/python/apache_beam/yaml/yaml_transform_test.py b/sdks/python/apache_beam/yaml/yaml_transform_test.py index 0038c6fc99ca..b78b5161d5fc 100644 --- a/sdks/python/apache_beam/yaml/yaml_transform_test.py +++ b/sdks/python/apache_beam/yaml/yaml_transform_test.py @@ -87,8 +87,9 @@ def raise_on_big(row): 'PyMap': lambda fn: beam.Map(python_callable.PythonCallableWithSource(fn)), } - unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") + + class YamlTransformE2ETest(unittest.TestCase): def test_composite(self): with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( From a1dc3202ca403f0391d044bfd56901013734f44c Mon Sep 17 00:00:00 2001 From: Danny Mccormick Date: Mon, 3 Nov 2025 08:29:04 -0500 Subject: [PATCH 8/9] correctly skip --- sdks/python/apache_beam/yaml/main_test.py | 4 +--- sdks/python/apache_beam/yaml/yaml_io_test.py | 4 +--- sdks/python/apache_beam/yaml/yaml_mapping_test.py | 4 +--- sdks/python/apache_beam/yaml/yaml_transform_unit_test.py | 1 + 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/sdks/python/apache_beam/yaml/main_test.py b/sdks/python/apache_beam/yaml/main_test.py index 4156dd6014ee..cfb74f584b0f 100644 --- a/sdks/python/apache_beam/yaml/main_test.py +++ b/sdks/python/apache_beam/yaml/main_test.py @@ -27,7 +27,7 @@ try: import jsonschema except ImportError: - pass + jsonschema = None TEST_PIPELINE = ''' pipeline: @@ -84,8 +84,6 @@ ''' unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") - - class MainTest(unittest.TestCase): def test_pipeline_spec_from_file(self): with tempfile.TemporaryDirectory() as tmpdir: diff --git a/sdks/python/apache_beam/yaml/yaml_io_test.py b/sdks/python/apache_beam/yaml/yaml_io_test.py index e88e6bf92698..f615df1236f7 100644 --- a/sdks/python/apache_beam/yaml/yaml_io_test.py +++ b/sdks/python/apache_beam/yaml/yaml_io_test.py @@ -35,7 +35,7 @@ try: import jsonschema except ImportError: - pass + jsonschema = None class FakeReadFromPubSub: @@ -88,8 +88,6 @@ def __call__(self, topic, *, with_attributes, id_label, timestamp_attribute): unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") - - class YamlPubSubTest(unittest.TestCase): def test_simple_read(self): with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( diff --git a/sdks/python/apache_beam/yaml/yaml_mapping_test.py b/sdks/python/apache_beam/yaml/yaml_mapping_test.py index c2a0e1f45190..90eede659371 100644 --- a/sdks/python/apache_beam/yaml/yaml_mapping_test.py +++ b/sdks/python/apache_beam/yaml/yaml_mapping_test.py @@ -33,7 +33,7 @@ try: import jsonschema except ImportError: - pass + jsonschema = None DATA = [ beam.Row(label='11a', conductor=11, rank=0), @@ -42,8 +42,6 @@ ] unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") - - class YamlMappingTest(unittest.TestCase): def test_basic(self): with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( diff --git a/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py b/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py index 14bd758ebae5..4bf81247c8d1 100644 --- a/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py +++ b/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py @@ -55,6 +55,7 @@ def new_pipeline(): pickle_library='cloudpickle')) +unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") class MainTest(unittest.TestCase): def assertYaml(self, expected, result): result = SafeLineLoader.strip_metadata(result) From eb9a1cacd8e599e7890ce98b84a243069c4af317 Mon Sep 17 00:00:00 2001 From: Danny Mccormick Date: Mon, 3 Nov 2025 08:53:13 -0500 Subject: [PATCH 9/9] Fix annotations --- sdks/python/apache_beam/yaml/main_test.py | 3 ++- sdks/python/apache_beam/yaml/yaml_io_test.py | 2 +- sdks/python/apache_beam/yaml/yaml_mapping_test.py | 3 ++- sdks/python/apache_beam/yaml/yaml_transform_test.py | 5 ++--- sdks/python/apache_beam/yaml/yaml_transform_unit_test.py | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sdks/python/apache_beam/yaml/main_test.py b/sdks/python/apache_beam/yaml/main_test.py index cfb74f584b0f..43b8caa1853b 100644 --- a/sdks/python/apache_beam/yaml/main_test.py +++ b/sdks/python/apache_beam/yaml/main_test.py @@ -83,7 +83,8 @@ - element: x ''' -unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") + +@unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") class MainTest(unittest.TestCase): def test_pipeline_spec_from_file(self): with tempfile.TemporaryDirectory() as tmpdir: diff --git a/sdks/python/apache_beam/yaml/yaml_io_test.py b/sdks/python/apache_beam/yaml/yaml_io_test.py index f615df1236f7..1e13038512cd 100644 --- a/sdks/python/apache_beam/yaml/yaml_io_test.py +++ b/sdks/python/apache_beam/yaml/yaml_io_test.py @@ -87,7 +87,7 @@ def __call__(self, topic, *, with_attributes, id_label, timestamp_attribute): return AssertThat(equal_to(self._messages)) -unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") +@unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") class YamlPubSubTest(unittest.TestCase): def test_simple_read(self): with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( diff --git a/sdks/python/apache_beam/yaml/yaml_mapping_test.py b/sdks/python/apache_beam/yaml/yaml_mapping_test.py index 90eede659371..169c86d7b87b 100644 --- a/sdks/python/apache_beam/yaml/yaml_mapping_test.py +++ b/sdks/python/apache_beam/yaml/yaml_mapping_test.py @@ -41,7 +41,8 @@ beam.Row(label='389a', conductor=389, rank=2), ] -unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") + +@unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") class YamlMappingTest(unittest.TestCase): def test_basic(self): with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( diff --git a/sdks/python/apache_beam/yaml/yaml_transform_test.py b/sdks/python/apache_beam/yaml/yaml_transform_test.py index b78b5161d5fc..d5950fb9efaf 100644 --- a/sdks/python/apache_beam/yaml/yaml_transform_test.py +++ b/sdks/python/apache_beam/yaml/yaml_transform_test.py @@ -32,7 +32,7 @@ try: import jsonschema except ImportError: - pass + jsonschema = None class CreateTimestamped(beam.PTransform): @@ -87,9 +87,8 @@ def raise_on_big(row): 'PyMap': lambda fn: beam.Map(python_callable.PythonCallableWithSource(fn)), } -unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") - +@unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") class YamlTransformE2ETest(unittest.TestCase): def test_composite(self): with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( diff --git a/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py b/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py index 4bf81247c8d1..59b1619b6512 100644 --- a/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py +++ b/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py @@ -55,7 +55,7 @@ def new_pipeline(): pickle_library='cloudpickle')) -unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") +@unittest.skipIf(jsonschema is None, "Yaml dependencies not installed") class MainTest(unittest.TestCase): def assertYaml(self, expected, result): result = SafeLineLoader.strip_metadata(result)