[ 
https://issues.apache.org/jira/browse/BEAM-9547?focusedWorklogId=466405&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-466405
 ]

ASF GitHub Bot logged work on BEAM-9547:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 04/Aug/20 19:12
            Start Date: 04/Aug/20 19:12
    Worklog Time Spent: 10m 
      Work Description: apilloud commented on a change in pull request #12459:
URL: https://github.com/apache/beam/pull/12459#discussion_r465257198



##########
File path: sdks/python/apache_beam/dataframe/frame_base.py
##########
@@ -147,7 +149,11 @@ def wrapper(*args, **kwargs):
       else:
         try:
           # pylint: disable=deprecated-method
-          ix = inspect.getargspec(func).args.index(key)
+          if sys.version_info < (3, ):

Review comment:
       nit: this appears more than once in this file, might it be worth adding 
a `getargspec` helper function?

##########
File path: sdks/python/apache_beam/dataframe/frame_base.py
##########
@@ -226,6 +232,68 @@ def wrapper(self, *args, **kwargs):
   return wrapper
 
 
+def maybe_inplace(func):
+  @functools.wraps(func)
+  def wrapper(self, inplace=False, **kwargs):
+    result = func(self, **kwargs)
+    if inplace:
+      self._expr = result._expr
+    else:
+      return result
+
+  return wrapper
+
+
+def args_to_kwargs(base_type):
+  def wrap(func):
+    if sys.version_info < (3, ):
+      getargspec = inspect.getargspec
+    else:
+      getargspec = inspect.getfullargspec
+
+    # This is used to map all positional arguments to keyword arguments.
+    base = getattr(base_type, func.__name__)
+    while hasattr(base, '__wrapped__'):
+      base = base.__wrapped__
+    base_argspec = getargspec(base)
+    arg_names = base_argspec.args
+
+    # These are used to populate any defaults in base for arguments in func.
+    if base_argspec.defaults:
+      arg_to_default = dict(
+          zip(
+              base_argspec.args[-len(base_argspec.defaults):],
+              base_argspec.defaults))
+    else:
+      arg_to_default = {}
+
+    unwrapped_func = func
+    while hasattr(unwrapped_func, '__wrapped__'):
+      unwrapped_func = unwrapped_func.__wrapped__
+    # args that do not have defaults in func, but do have defaults in base

Review comment:
       This comment is a little confusing, I believe it is describing the 
contents of `populate_defaults`?
   
   After spending some time reading through this, it might be clearer if you 
broke this into a function that returned `arg_to_default`, and a second that 
returned `populate_defaults`.

##########
File path: sdks/python/apache_beam/dataframe/frame_base.py
##########
@@ -226,6 +232,68 @@ def wrapper(self, *args, **kwargs):
   return wrapper
 
 
+def maybe_inplace(func):
+  @functools.wraps(func)
+  def wrapper(self, inplace=False, **kwargs):
+    result = func(self, **kwargs)
+    if inplace:
+      self._expr = result._expr
+    else:
+      return result
+
+  return wrapper
+
+
+def args_to_kwargs(base_type):

Review comment:
       This seems generic and useful enough that I'm surprised it isn't in a 
dataframes library.

##########
File path: sdks/python/apache_beam/dataframe/frame_base.py
##########
@@ -226,6 +232,68 @@ def wrapper(self, *args, **kwargs):
   return wrapper
 
 
+def maybe_inplace(func):
+  @functools.wraps(func)
+  def wrapper(self, inplace=False, **kwargs):
+    result = func(self, **kwargs)
+    if inplace:
+      self._expr = result._expr
+    else:
+      return result
+
+  return wrapper
+
+
+def args_to_kwargs(base_type):
+  def wrap(func):
+    if sys.version_info < (3, ):
+      getargspec = inspect.getargspec
+    else:
+      getargspec = inspect.getfullargspec
+
+    # This is used to map all positional arguments to keyword arguments.
+    base = getattr(base_type, func.__name__)
+    while hasattr(base, '__wrapped__'):
+      base = base.__wrapped__
+    base_argspec = getargspec(base)
+    arg_names = base_argspec.args
+
+    # These are used to populate any defaults in base for arguments in func.
+    if base_argspec.defaults:
+      arg_to_default = dict(

Review comment:
       `arg_to_default` might be clearer as `arg_to_base_default` or 
`base_defaults`?




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

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 466405)
    Time Spent: 1h 20m  (was: 1h 10m)

> Implement all pandas operations (or raise WontImplementError)
> -------------------------------------------------------------
>
>                 Key: BEAM-9547
>                 URL: https://issues.apache.org/jira/browse/BEAM-9547
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-py-core
>            Reporter: Brian Hulette
>            Assignee: Robert Bradshaw
>            Priority: P2
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> We should have an implementation for every DataFrame, Series, and GroupBy 
> method. Everything that's not actually implemented should get a default 
> implementation that raises WontImplementError
> SeeĀ https://github.com/apache/beam/pull/10757#discussion_r389132292



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to