From 2f2f1d69003211c62b0c4bed3f8c74a413c46188 Mon Sep 17 00:00:00 2001 From: kristynsmith Date: Wed, 7 Oct 2026 11:49:15 -0400 Subject: [PATCH 1/4] Add stable identifier pickling option to context --- sdks/python/apache_beam/pipeline.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdks/python/apache_beam/pipeline.py b/sdks/python/apache_beam/pipeline.py index fea42bbc0cb3..0e551703266d 100644 --- a/sdks/python/apache_beam/pipeline.py +++ b/sdks/python/apache_beam/pipeline.py @@ -1081,6 +1081,8 @@ def to_runner_api( # because other runners do not have this option. context.enable_best_effort_deterministic_pickling = getattr( self.runner, 'enable_best_effort_deterministic_pickling', False) + context.enable_stable_identifier_pickling = getattr( + self.runner, 'enable_stable_code_identifier_pickling', False) # The RunnerAPI spec requires certain transforms and side-inputs to have KV # inputs (and corresponding outputs). From 9c03511bcf02f0076698499b44d1cd1b4f11371e Mon Sep 17 00:00:00 2001 From: kristynsmith Date: Wed, 7 Oct 2026 11:51:13 -0400 Subject: [PATCH 2/4] Refactor config assignment in cloudpickle_pickler Replace config assignment with dataclasses.replace for stability. --- sdks/python/apache_beam/internal/cloudpickle_pickler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sdks/python/apache_beam/internal/cloudpickle_pickler.py b/sdks/python/apache_beam/internal/cloudpickle_pickler.py index cea4f01f803c..86b94fbf3b82 100644 --- a/sdks/python/apache_beam/internal/cloudpickle_pickler.py +++ b/sdks/python/apache_beam/internal/cloudpickle_pickler.py @@ -29,6 +29,7 @@ import base64 import bz2 +import dataclass import io import logging import sys @@ -187,7 +188,10 @@ def _dumps( with _pickle_lock: with io.BytesIO() as file: if enable_stable_code_identifier_pickling: - config = STABLE_CODE_IDENTIFIER_CONFIG + config = dataclasses.replace( + config, + get_code_object_params=STABLE_CODE_IDENTIFIER_CONFIG + .get_code_object_params) pickler = cloudpickle.CloudPickler(file, config=config) try: pickler.dispatch_table[type(flags.FLAGS)] = _pickle_absl_flags From 5477ec1efb3f6361887f31731601637943dafad8 Mon Sep 17 00:00:00 2001 From: kristynsmith Date: Wed, 7 Oct 2026 13:16:11 -0400 Subject: [PATCH 3/4] Fix import statement for dataclasses module --- sdks/python/apache_beam/internal/cloudpickle_pickler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/python/apache_beam/internal/cloudpickle_pickler.py b/sdks/python/apache_beam/internal/cloudpickle_pickler.py index 86b94fbf3b82..2d9404feab2f 100644 --- a/sdks/python/apache_beam/internal/cloudpickle_pickler.py +++ b/sdks/python/apache_beam/internal/cloudpickle_pickler.py @@ -29,7 +29,7 @@ import base64 import bz2 -import dataclass +import dataclasses import io import logging import sys From 88ae832d0d9a336b4dd81f2c7f58571b52c59b37 Mon Sep 17 00:00:00 2001 From: kristynsmith Date: Wed, 7 Oct 2026 14:30:01 -0400 Subject: [PATCH 4/4] Fix indentation in cloudpickle_pickler.py --- sdks/python/apache_beam/internal/cloudpickle_pickler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdks/python/apache_beam/internal/cloudpickle_pickler.py b/sdks/python/apache_beam/internal/cloudpickle_pickler.py index 2d9404feab2f..9710878f5b67 100644 --- a/sdks/python/apache_beam/internal/cloudpickle_pickler.py +++ b/sdks/python/apache_beam/internal/cloudpickle_pickler.py @@ -189,9 +189,9 @@ def _dumps( with io.BytesIO() as file: if enable_stable_code_identifier_pickling: config = dataclasses.replace( - config, - get_code_object_params=STABLE_CODE_IDENTIFIER_CONFIG - .get_code_object_params) + config, + get_code_object_params=STABLE_CODE_IDENTIFIER_CONFIG. + get_code_object_params) pickler = cloudpickle.CloudPickler(file, config=config) try: pickler.dispatch_table[type(flags.FLAGS)] = _pickle_absl_flags