This is an automated email from the ASF dual-hosted git repository.
tvalentyn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new aaad864 [BEAM-7372] remove aliases created for python 2 (#14012)
aaad864 is described below
commit aaad864c9acb22e35050f974a7ac74fb7638f085
Author: yoshiki.obata <[email protected]>
AuthorDate: Sun Feb 21 06:04:07 2021 +0900
[BEAM-7372] remove aliases created for python 2 (#14012)
---
sdks/python/apache_beam/dataframe/frame_base.py | 16 +++++++---------
sdks/python/apache_beam/internal/pickler.py | 10 +++++-----
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/sdks/python/apache_beam/dataframe/frame_base.py
b/sdks/python/apache_beam/dataframe/frame_base.py
index b5b7afa..ad6e3c2 100644
--- a/sdks/python/apache_beam/dataframe/frame_base.py
+++ b/sdks/python/apache_beam/dataframe/frame_base.py
@@ -17,7 +17,8 @@
from __future__ import absolute_import
import functools
-import inspect
+from inspect import getfullargspec
+from inspect import unwrap
from typing import Any
from typing import Callable
from typing import Dict
@@ -30,9 +31,6 @@ import pandas as pd
from apache_beam.dataframe import expressions
from apache_beam.dataframe import partitionings
-_getargspec = inspect.getfullargspec
-_unwrap = inspect.unwrap
-
class DeferredBase(object):
@@ -188,7 +186,7 @@ def _proxy_function(
value = kwargs[key]
else:
try:
- ix = _getargspec(func).args.index(key)
+ ix = getfullargspec(func).args.index(key)
except ValueError:
# TODO: fix for delegation?
continue
@@ -333,7 +331,7 @@ def maybe_inplace(func):
def args_to_kwargs(base_type):
def wrap(func):
- arg_names = _getargspec(_unwrap(getattr(base_type, func.__name__))).args
+ arg_names = getfullargspec(unwrap(getattr(base_type, func.__name__))).args
@functools.wraps(func)
def wrapper(*args, **kwargs):
@@ -352,7 +350,7 @@ def args_to_kwargs(base_type):
def populate_defaults(base_type):
def wrap(func):
- base_argspec = _getargspec(_unwrap(getattr(base_type, func.__name__)))
+ base_argspec = getfullargspec(unwrap(getattr(base_type, func.__name__)))
if not base_argspec.defaults:
return func
@@ -361,9 +359,9 @@ def populate_defaults(base_type):
base_argspec.args[-len(base_argspec.defaults):],
base_argspec.defaults))
- unwrapped_func = _unwrap(func)
+ unwrapped_func = unwrap(func)
# args that do not have defaults in func, but do have defaults in base
- func_argspec = _getargspec(unwrapped_func)
+ func_argspec = getfullargspec(unwrapped_func)
num_non_defaults = len(func_argspec.args) - len(func_argspec.defaults or
())
defaults_to_populate = set(
func_argspec.args[:num_non_defaults]).intersection(
diff --git a/sdks/python/apache_beam/internal/pickler.py
b/sdks/python/apache_beam/internal/pickler.py
index 9f0c123..4b9ec2a 100644
--- a/sdks/python/apache_beam/internal/pickler.py
+++ b/sdks/python/apache_beam/internal/pickler.py
@@ -57,7 +57,7 @@ class _NoOpContextManager(object):
# Pickling, especially unpickling, causes broken module imports on Python 3
# if executed concurrently, see: BEAM-8651, http://bugs.python.org/issue38884.
-_pickle_lock_unless_py2 = threading.RLock()
+_pickle_lock = threading.RLock()
# Dill 0.28.0 renamed dill.dill to dill._dill:
#
https://github.com/uqfoundation/dill/commit/f0972ecc7a41d0b8acada6042d557068cac69baa
# TODO: Remove this once Beam depends on dill >= 0.2.8
@@ -242,7 +242,7 @@ def dumps(o, enable_trace=True, use_zlib=False):
# type: (...) -> bytes
"""For internal use only; no backwards-compatibility guarantees."""
- with _pickle_lock_unless_py2:
+ with _pickle_lock:
try:
s = dill.dumps(o)
except Exception: # pylint: disable=broad-except
@@ -281,7 +281,7 @@ def loads(encoded, enable_trace=True, use_zlib=False):
del c # Free up some possibly large and no-longer-needed memory.
- with _pickle_lock_unless_py2:
+ with _pickle_lock:
try:
return dill.loads(s)
except Exception: # pylint: disable=broad-except
@@ -303,12 +303,12 @@ def dump_session(file_path):
create and load the dump twice to have consistent results in the worker and
the running session. Check: https://github.com/uqfoundation/dill/issues/195
"""
- with _pickle_lock_unless_py2:
+ with _pickle_lock:
dill.dump_session(file_path)
dill.load_session(file_path)
return dill.dump_session(file_path)
def load_session(file_path):
- with _pickle_lock_unless_py2:
+ with _pickle_lock:
return dill.load_session(file_path)