This commit is contained in:
Clarence Ng 2022-06-24 17:54:44 -07:00
parent f7d0ad3bb7
commit f53a7f115b
6 changed files with 51 additions and 37 deletions

View file

@ -14,7 +14,7 @@ filter_files=True
# are also carefully crafted.
# For the rest we will gradually remove them from the blacklist as we
# reformat the code to follow the style guide.
skip_glob=python/ray/__init__.py,python/ray/setup-dev.py,python/ray/dag/*.py,doc/*,ci/*,python/ray/_raylet*,python/ray/_private/*,python/ray/air/*,python/ray/cloudpickle/*,python/ray/core/*,dashboard/*,python/ray/data/*,python/ray/experimental/*,python/ray/includes/*,python/ray/internal/*,python/ray/ray_operator/*,python/ray/scripts/*,python/ray/serve/*,python/ray/sgd/*,python/ray/streaming/*,python/ray/tests/*,python/ray/tests/*,python/ray/train/*,python/ray/tune/*,python/ray/util/*,python/ray/workers/*,python/ray/workflow/*,rllib/*,release/*,
skip_glob=python/ray/__init__.py,python/ray/setup-dev.py,python/ray/dag/*.py,doc/*,ci/*,python/ray/_private/*,python/ray/air/*,dashboard/*,python/ray/data/*,python/ray/experimental/*,python/ray/includes/*,python/ray/internal/*,python/ray/ray_operator/*,python/ray/scripts/*,python/ray/serve/*,python/ray/sgd/*,python/ray/streaming/*,python/ray/tests/*,python/ray/tests/*,python/ray/train/*,python/ray/tune/*,python/ray/util/*,python/ray/workers/*,python/ray/workflow/*,rllib/*,release/*,
known_local_folder=ray
known_afterray=psutil,setproctitle

View file

@ -4,8 +4,7 @@ import os
from pickle import PicklingError
from ray.cloudpickle.cloudpickle import * # noqa
from ray.cloudpickle.cloudpickle_fast import CloudPickler, dumps, dump # noqa
from ray.cloudpickle.cloudpickle_fast import CloudPickler, dump, dumps # noqa
# Conform to the convention used by python serialization libraries, which
# expose their Pickler subclass at top-level under the "Pickler" name.

View file

@ -45,24 +45,25 @@ from __future__ import print_function
import builtins
import dis
import opcode
import platform
import sys
import types
import weakref
import uuid
import threading
import types
import typing
import uuid
import warnings
import weakref
from collections import OrderedDict
from pickle import _getattribute
from typing import Callable, Generic, Tuple, Union
import opcode
from .compat import pickle
from collections import OrderedDict
from typing import Generic, Union, Tuple, Callable
from pickle import _getattribute
try: # pragma: no branch
import typing_extensions as _typing_extensions
from typing_extensions import Literal, Final
from typing_extensions import Final, Literal
except ImportError:
_typing_extensions = Literal = Final = None

View file

@ -10,34 +10,51 @@ Note that the C Pickler subclassing API is CPython-specific. Therefore, some
guards present in cloudpickle.py that were written to handle PyPy specificities
are not present in cloudpickle_fast.py
"""
import _collections_abc
import abc
import copyreg
import io
import itertools
import logging
import sys
import struct
import sys
import types
import weakref
import typing
from enum import Enum
import weakref
from collections import ChainMap, OrderedDict
from enum import Enum
import _collections_abc
from .compat import pickle, Pickler
from .cloudpickle import (
_extract_code_globals, _BUILTIN_TYPE_NAMES, DEFAULT_PROTOCOL,
_find_imported_submodules, _get_cell_contents, _should_pickle_by_reference,
_builtin_type, _get_or_create_tracker_id, _make_skeleton_class,
_make_skeleton_enum, _extract_class_dict, dynamic_subimport, subimport,
_typevar_reduce, _get_bases, _make_cell, _make_empty_cell, CellType,
_is_parametrized_type_hint, PYPY, cell_set,
parametrized_type_hint_getinitargs, _create_parametrized_type_hint,
_BUILTIN_TYPE_NAMES,
DEFAULT_PROTOCOL,
PYPY,
CellType,
_builtin_type,
_create_parametrized_type_hint,
_extract_class_dict,
_extract_code_globals,
_find_imported_submodules,
_get_bases,
_get_cell_contents,
_get_or_create_tracker_id,
_is_parametrized_type_hint,
_make_cell,
_make_dict_items,
_make_dict_keys,
_make_dict_values,
_make_empty_cell,
_make_skeleton_class,
_make_skeleton_enum,
_should_pickle_by_reference,
_typevar_reduce,
builtin_code_type,
_make_dict_keys, _make_dict_values, _make_dict_items,
cell_set,
dynamic_subimport,
parametrized_type_hint_getinitargs,
subimport,
)
from .compat import Pickler, pickle
if pickle.HIGHEST_PROTOCOL >= 5 and not PYPY:
# Shorthands similar to pickle.dump/pickle.dumps
@ -551,8 +568,9 @@ class CloudPickler(Pickler):
# TODO(suquark): Remove this patch when we use numpy >= 1.20.0 by default.
# We import 'numpy.core' here, so numpy would register the
# ufunc serializer to 'copyreg.dispatch_table' before we override it.
import numpy.core
import numpy
import numpy.core
# Override the original numpy ufunc serializer.
dispatch_table[numpy.ufunc] = _ufunc_reduce

View file

@ -24,4 +24,5 @@ elif sys.version_info < (3, 8):
from pickle import _Pickler as Pickler # noqa: F401
else:
import pickle # noqa: F401
from _pickle import Pickler # noqa: F401

View file

@ -1,13 +1,8 @@
from pickle import (
_Pickler,
_Unpickler as Unpickler,
_loads as loads,
_load as load,
PickleError,
PicklingError,
UnpicklingError,
HIGHEST_PROTOCOL,
)
from pickle import HIGHEST_PROTOCOL, PickleError, PicklingError, UnpicklingError
from pickle import _load as load
from pickle import _loads as loads
from pickle import _Pickler
from pickle import _Unpickler as Unpickler
__all__ = [
"PickleError",