claudevdm commented on code in PR #38769:
URL: https://github.com/apache/beam/pull/38769#discussion_r3341850410


##########
sdks/python/apache_beam/ml/transforms/base.py:
##########
@@ -591,7 +592,18 @@ def save_attributes(
   def load_attributes(artifact_location):
     with FileSystems.open(os.path.join(artifact_location, 
_ATTRIBUTE_FILE_NAME),
                           'rb') as f:
-      return jsonpickle.decode(f.read())
+      # load_attributes runs eagerly during MLTransform.expand() at pipeline
+      # construction time, so the pipeline's options are available via the
+      # construction-time context.
+      pipeline_options = get_pipeline_options()
+      safe = True
+      if (pipeline_options is not None and
+          pipeline_options.is_compat_version_prior_to("2.75.0")):
+        # Keep the pre-2.75.0 jsonpickle behavior (safe=False permits
+        # eval-based decoding) for backwards compatibility with already-staged
+        # artifacts.
+        safe = False

Review Comment:
   The default in v 4+ is safe=True, so I think it is best if we align with the 
default behavior in the underlying library?
   
   Is the benefit of always setting to False simplicity? I don't have a strong 
opinion 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]

Reply via email to