derrickaw commented on code in PR #38130:
URL: https://github.com/apache/beam/pull/38130#discussion_r3093146314


##########
sdks/python/apache_beam/yaml/yaml_mapping.py:
##########
@@ -178,18 +177,34 @@ def _check_mapping_arguments(
     raise ValueError(f'{transform_name} cannot specify "name" without "path"')
 
 
-# js2py's JsObjectWrapper object has a self-referencing __dict__ property
-# that cannot be pickled without implementing the __getstate__ and
-# __setstate__ methods.
-class _CustomJsObjectWrapper(JsObjectWrapper):
-  def __init__(self, js_obj):
-    super().__init__(js_obj.__dict__['_obj'])
+class _QuickJsCallable:
+  def __init__(self, source, name=None):
+    self.source = source
+    self.name = name
+    self._func = None
+
+  def _get_func(self):
+    if self._func is None:
+      if quickjs is None:
+        raise ValueError("quickjs is not installed.")
+      context = quickjs.Context()
+      if self.name:
+        context.eval(self.source)
+        self._func = context.get(self.name)
+      else:
+        self._func = context.eval(self.source)
+    return self._func
+
+  def __call__(self, *args, **kwargs):
+    return self._get_func()(*args, **kwargs)

Review Comment:
   done



-- 
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