Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- ckpts/llama-3b/global_step100/bf16_zero_pp_rank_203_mp_rank_01_optim_states.pt +3 -0
- venv/lib/python3.10/site-packages/dill/__pycache__/__diff.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/__pycache__/__info__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/__pycache__/_objects.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/__pycache__/_shims.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/__pycache__/detect.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/__pycache__/logger.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/__pycache__/objtypes.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/__pycache__/pointers.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/__pycache__/session.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/__pycache__/settings.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/__pycache__/source.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/__pycache__/temp.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__init__.py +22 -0
- venv/lib/python3.10/site-packages/dill/tests/__main__.py +35 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/__main__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_abc.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_check.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_classdef.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_dataclasses.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_detect.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_dictviews.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_diff.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_extendpickle.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_fglobals.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_file.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_functions.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_functors.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_logger.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_mixins.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_module.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_moduledict.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_nested.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_objects.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_properties.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_pycapsule.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_recursive.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_registered.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_restricted.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_selected.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_session.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_source.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_temp.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_weakref.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/dill/tests/test_abc.py +169 -0
- venv/lib/python3.10/site-packages/dill/tests/test_check.py +62 -0
- venv/lib/python3.10/site-packages/dill/tests/test_classdef.py +340 -0
- venv/lib/python3.10/site-packages/dill/tests/test_dataclasses.py +35 -0
ckpts/llama-3b/global_step100/bf16_zero_pp_rank_203_mp_rank_01_optim_states.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eb7cbc5336202e8eff19a23ab261880576f644d5b0ef343018815bf83691469e
|
3 |
+
size 41830148
|
venv/lib/python3.10/site-packages/dill/__pycache__/__diff.cpython-310.pyc
ADDED
Binary file (5.85 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/__pycache__/__info__.cpython-310.pyc
ADDED
Binary file (10.7 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (3.67 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/__pycache__/_objects.cpython-310.pyc
ADDED
Binary file (14.3 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/__pycache__/_shims.cpython-310.pyc
ADDED
Binary file (6.58 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/__pycache__/detect.cpython-310.pyc
ADDED
Binary file (8.28 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/__pycache__/logger.cpython-310.pyc
ADDED
Binary file (8.87 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/__pycache__/objtypes.cpython-310.pyc
ADDED
Binary file (535 Bytes). View file
|
|
venv/lib/python3.10/site-packages/dill/__pycache__/pointers.cpython-310.pyc
ADDED
Binary file (3.43 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/__pycache__/session.cpython-310.pyc
ADDED
Binary file (18.9 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/__pycache__/settings.cpython-310.pyc
ADDED
Binary file (351 Bytes). View file
|
|
venv/lib/python3.10/site-packages/dill/__pycache__/source.cpython-310.pyc
ADDED
Binary file (25.9 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/__pycache__/temp.cpython-310.pyc
ADDED
Binary file (7.23 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__init__.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
#
|
3 |
+
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
|
4 |
+
# Copyright (c) 2018-2024 The Uncertainty Quantification Foundation.
|
5 |
+
# License: 3-clause BSD. The full license text is available at:
|
6 |
+
# - https://github.com/uqfoundation/dill/blob/master/LICENSE
|
7 |
+
"""
|
8 |
+
to run this test suite, first build and install `dill`.
|
9 |
+
|
10 |
+
$ python -m pip install ../..
|
11 |
+
|
12 |
+
|
13 |
+
then run the tests with:
|
14 |
+
|
15 |
+
$ python -m dill.tests
|
16 |
+
|
17 |
+
|
18 |
+
or, if `nose` is installed:
|
19 |
+
|
20 |
+
$ nosetests
|
21 |
+
|
22 |
+
"""
|
venv/lib/python3.10/site-packages/dill/tests/__main__.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
#
|
3 |
+
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
|
4 |
+
# Copyright (c) 2018-2024 The Uncertainty Quantification Foundation.
|
5 |
+
# License: 3-clause BSD. The full license text is available at:
|
6 |
+
# - https://github.com/uqfoundation/dill/blob/master/LICENSE
|
7 |
+
|
8 |
+
import glob
|
9 |
+
import os
|
10 |
+
import sys
|
11 |
+
import subprocess as sp
|
12 |
+
python = sys.executable
|
13 |
+
try:
|
14 |
+
import pox
|
15 |
+
python = pox.which_python(version=True) or python
|
16 |
+
except ImportError:
|
17 |
+
pass
|
18 |
+
shell = sys.platform[:3] == 'win'
|
19 |
+
|
20 |
+
suite = os.path.dirname(__file__) or os.path.curdir
|
21 |
+
tests = glob.glob(suite + os.path.sep + 'test_*.py')
|
22 |
+
|
23 |
+
|
24 |
+
if __name__ == '__main__':
|
25 |
+
|
26 |
+
failed = 0
|
27 |
+
for test in tests:
|
28 |
+
p = sp.Popen([python, test], shell=shell).wait()
|
29 |
+
if p:
|
30 |
+
print('F', end='', flush=True)
|
31 |
+
failed = 1
|
32 |
+
else:
|
33 |
+
print('.', end='', flush=True)
|
34 |
+
print('')
|
35 |
+
exit(failed)
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (381 Bytes). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/__main__.cpython-310.pyc
ADDED
Binary file (758 Bytes). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_abc.cpython-310.pyc
ADDED
Binary file (5.26 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_check.cpython-310.pyc
ADDED
Binary file (1.49 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_classdef.cpython-310.pyc
ADDED
Binary file (11.6 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_dataclasses.cpython-310.pyc
ADDED
Binary file (1.04 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_detect.cpython-310.pyc
ADDED
Binary file (5.1 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_dictviews.cpython-310.pyc
ADDED
Binary file (1.24 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_diff.cpython-310.pyc
ADDED
Binary file (1.54 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_extendpickle.cpython-310.pyc
ADDED
Binary file (1.28 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_fglobals.cpython-310.pyc
ADDED
Binary file (1.88 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_file.cpython-310.pyc
ADDED
Binary file (7.07 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_functions.cpython-310.pyc
ADDED
Binary file (4.56 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_functors.cpython-310.pyc
ADDED
Binary file (972 Bytes). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_logger.cpython-310.pyc
ADDED
Binary file (1.95 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_mixins.cpython-310.pyc
ADDED
Binary file (4.69 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_module.cpython-310.pyc
ADDED
Binary file (1.75 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_moduledict.cpython-310.pyc
ADDED
Binary file (1.73 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_nested.cpython-310.pyc
ADDED
Binary file (3.62 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_objects.cpython-310.pyc
ADDED
Binary file (1.89 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_properties.cpython-310.pyc
ADDED
Binary file (1.6 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_pycapsule.cpython-310.pyc
ADDED
Binary file (1.06 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_recursive.cpython-310.pyc
ADDED
Binary file (5.65 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_registered.cpython-310.pyc
ADDED
Binary file (1.51 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_restricted.cpython-310.pyc
ADDED
Binary file (983 Bytes). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_selected.cpython-310.pyc
ADDED
Binary file (3.22 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_session.cpython-310.pyc
ADDED
Binary file (8.19 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_source.cpython-310.pyc
ADDED
Binary file (5.32 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_temp.cpython-310.pyc
ADDED
Binary file (3.13 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/__pycache__/test_weakref.cpython-310.pyc
ADDED
Binary file (1.74 kB). View file
|
|
venv/lib/python3.10/site-packages/dill/tests/test_abc.py
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
#
|
3 |
+
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
|
4 |
+
# Copyright (c) 2023-2024 The Uncertainty Quantification Foundation.
|
5 |
+
# License: 3-clause BSD. The full license text is available at:
|
6 |
+
# - https://github.com/uqfoundation/dill/blob/master/LICENSE
|
7 |
+
"""
|
8 |
+
test dill's ability to pickle abstract base class objects
|
9 |
+
"""
|
10 |
+
import dill
|
11 |
+
import abc
|
12 |
+
from abc import ABC
|
13 |
+
import warnings
|
14 |
+
|
15 |
+
from types import FunctionType
|
16 |
+
|
17 |
+
dill.settings['recurse'] = True
|
18 |
+
|
19 |
+
class OneTwoThree(ABC):
|
20 |
+
@abc.abstractmethod
|
21 |
+
def foo(self):
|
22 |
+
"""A method"""
|
23 |
+
pass
|
24 |
+
|
25 |
+
@property
|
26 |
+
@abc.abstractmethod
|
27 |
+
def bar(self):
|
28 |
+
"""Property getter"""
|
29 |
+
pass
|
30 |
+
|
31 |
+
@bar.setter
|
32 |
+
@abc.abstractmethod
|
33 |
+
def bar(self, value):
|
34 |
+
"""Property setter"""
|
35 |
+
pass
|
36 |
+
|
37 |
+
@classmethod
|
38 |
+
@abc.abstractmethod
|
39 |
+
def cfoo(cls):
|
40 |
+
"""Class method"""
|
41 |
+
pass
|
42 |
+
|
43 |
+
@staticmethod
|
44 |
+
@abc.abstractmethod
|
45 |
+
def sfoo():
|
46 |
+
"""Static method"""
|
47 |
+
pass
|
48 |
+
|
49 |
+
class EasyAsAbc(OneTwoThree):
|
50 |
+
def __init__(self):
|
51 |
+
self._bar = None
|
52 |
+
|
53 |
+
def foo(self):
|
54 |
+
return "Instance Method FOO"
|
55 |
+
|
56 |
+
@property
|
57 |
+
def bar(self):
|
58 |
+
return self._bar
|
59 |
+
|
60 |
+
@bar.setter
|
61 |
+
def bar(self, value):
|
62 |
+
self._bar = value
|
63 |
+
|
64 |
+
@classmethod
|
65 |
+
def cfoo(cls):
|
66 |
+
return "Class Method CFOO"
|
67 |
+
|
68 |
+
@staticmethod
|
69 |
+
def sfoo():
|
70 |
+
return "Static Method SFOO"
|
71 |
+
|
72 |
+
def test_abc_non_local():
|
73 |
+
assert dill.copy(OneTwoThree) is not OneTwoThree
|
74 |
+
assert dill.copy(EasyAsAbc) is not EasyAsAbc
|
75 |
+
|
76 |
+
with warnings.catch_warnings():
|
77 |
+
warnings.simplefilter("ignore", dill.PicklingWarning)
|
78 |
+
assert dill.copy(OneTwoThree, byref=True) is OneTwoThree
|
79 |
+
assert dill.copy(EasyAsAbc, byref=True) is EasyAsAbc
|
80 |
+
|
81 |
+
instance = EasyAsAbc()
|
82 |
+
# Set a property that StockPickle can't preserve
|
83 |
+
instance.bar = lambda x: x**2
|
84 |
+
depickled = dill.copy(instance)
|
85 |
+
assert type(depickled) is type(instance) #NOTE: issue #612, test_abc_local
|
86 |
+
#NOTE: dill.copy of local (or non-local) classes should (not) be the same?
|
87 |
+
assert type(depickled.bar) is FunctionType
|
88 |
+
assert depickled.bar(3) == 9
|
89 |
+
assert depickled.sfoo() == "Static Method SFOO"
|
90 |
+
assert depickled.cfoo() == "Class Method CFOO"
|
91 |
+
assert depickled.foo() == "Instance Method FOO"
|
92 |
+
|
93 |
+
def test_abc_local():
|
94 |
+
"""
|
95 |
+
Test using locally scoped ABC class
|
96 |
+
"""
|
97 |
+
class LocalABC(ABC):
|
98 |
+
@abc.abstractmethod
|
99 |
+
def foo(self):
|
100 |
+
pass
|
101 |
+
|
102 |
+
def baz(self):
|
103 |
+
return repr(self)
|
104 |
+
|
105 |
+
labc = dill.copy(LocalABC)
|
106 |
+
assert labc is not LocalABC
|
107 |
+
assert type(labc) is type(LocalABC)
|
108 |
+
#NOTE: dill.copy of local (or non-local) classes should (not) be the same?
|
109 |
+
# <class '__main__.LocalABC'>
|
110 |
+
# <class '__main__.test_abc_local.<locals>.LocalABC'>
|
111 |
+
|
112 |
+
class Real(labc):
|
113 |
+
def foo(self):
|
114 |
+
return "True!"
|
115 |
+
|
116 |
+
def baz(self):
|
117 |
+
return "My " + super(Real, self).baz()
|
118 |
+
|
119 |
+
real = Real()
|
120 |
+
assert real.foo() == "True!"
|
121 |
+
|
122 |
+
try:
|
123 |
+
labc()
|
124 |
+
except TypeError as e:
|
125 |
+
# Expected error
|
126 |
+
pass
|
127 |
+
else:
|
128 |
+
print('Failed to raise type error')
|
129 |
+
assert False
|
130 |
+
|
131 |
+
labc2, pik = dill.copy((labc, Real()))
|
132 |
+
assert 'Real' == type(pik).__name__
|
133 |
+
assert '.Real' in type(pik).__qualname__
|
134 |
+
assert type(pik) is not Real
|
135 |
+
assert labc2 is not LocalABC
|
136 |
+
assert labc2 is not labc
|
137 |
+
assert isinstance(pik, labc2)
|
138 |
+
assert not isinstance(pik, labc)
|
139 |
+
assert not isinstance(pik, LocalABC)
|
140 |
+
assert pik.baz() == "My " + repr(pik)
|
141 |
+
|
142 |
+
def test_meta_local_no_cache():
|
143 |
+
"""
|
144 |
+
Test calling metaclass and cache registration
|
145 |
+
"""
|
146 |
+
LocalMetaABC = abc.ABCMeta('LocalMetaABC', (), {})
|
147 |
+
|
148 |
+
class ClassyClass:
|
149 |
+
pass
|
150 |
+
|
151 |
+
class KlassyClass:
|
152 |
+
pass
|
153 |
+
|
154 |
+
LocalMetaABC.register(ClassyClass)
|
155 |
+
|
156 |
+
assert not issubclass(KlassyClass, LocalMetaABC)
|
157 |
+
assert issubclass(ClassyClass, LocalMetaABC)
|
158 |
+
|
159 |
+
res = dill.dumps((LocalMetaABC, ClassyClass, KlassyClass))
|
160 |
+
|
161 |
+
lmabc, cc, kc = dill.loads(res)
|
162 |
+
assert type(lmabc) == type(LocalMetaABC)
|
163 |
+
assert not issubclass(kc, lmabc)
|
164 |
+
assert issubclass(cc, lmabc)
|
165 |
+
|
166 |
+
if __name__ == '__main__':
|
167 |
+
test_abc_non_local()
|
168 |
+
test_abc_local()
|
169 |
+
test_meta_local_no_cache()
|
venv/lib/python3.10/site-packages/dill/tests/test_check.py
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
#
|
3 |
+
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
|
4 |
+
# Copyright (c) 2008-2016 California Institute of Technology.
|
5 |
+
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
|
6 |
+
# License: 3-clause BSD. The full license text is available at:
|
7 |
+
# - https://github.com/uqfoundation/dill/blob/master/LICENSE
|
8 |
+
|
9 |
+
from dill import check
|
10 |
+
import sys
|
11 |
+
|
12 |
+
from dill.temp import capture
|
13 |
+
|
14 |
+
|
15 |
+
#FIXME: this doesn't catch output... it's from the internal call
|
16 |
+
def raise_check(func, **kwds):
|
17 |
+
try:
|
18 |
+
with capture('stdout') as out:
|
19 |
+
check(func, **kwds)
|
20 |
+
except Exception:
|
21 |
+
e = sys.exc_info()[1]
|
22 |
+
raise AssertionError(str(e))
|
23 |
+
else:
|
24 |
+
assert 'Traceback' not in out.getvalue()
|
25 |
+
finally:
|
26 |
+
out.close()
|
27 |
+
|
28 |
+
|
29 |
+
f = lambda x:x**2
|
30 |
+
|
31 |
+
|
32 |
+
def test_simple(verbose=None):
|
33 |
+
raise_check(f, verbose=verbose)
|
34 |
+
|
35 |
+
|
36 |
+
def test_recurse(verbose=None):
|
37 |
+
raise_check(f, recurse=True, verbose=verbose)
|
38 |
+
|
39 |
+
|
40 |
+
def test_byref(verbose=None):
|
41 |
+
raise_check(f, byref=True, verbose=verbose)
|
42 |
+
|
43 |
+
|
44 |
+
def test_protocol(verbose=None):
|
45 |
+
raise_check(f, protocol=True, verbose=verbose)
|
46 |
+
|
47 |
+
|
48 |
+
def test_python(verbose=None):
|
49 |
+
raise_check(f, python=None, verbose=verbose)
|
50 |
+
|
51 |
+
|
52 |
+
#TODO: test incompatible versions
|
53 |
+
#TODO: test dump failure
|
54 |
+
#TODO: test load failure
|
55 |
+
|
56 |
+
|
57 |
+
if __name__ == '__main__':
|
58 |
+
test_simple()
|
59 |
+
test_recurse()
|
60 |
+
test_byref()
|
61 |
+
test_protocol()
|
62 |
+
test_python()
|
venv/lib/python3.10/site-packages/dill/tests/test_classdef.py
ADDED
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
#
|
3 |
+
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
|
4 |
+
# Copyright (c) 2008-2016 California Institute of Technology.
|
5 |
+
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
|
6 |
+
# License: 3-clause BSD. The full license text is available at:
|
7 |
+
# - https://github.com/uqfoundation/dill/blob/master/LICENSE
|
8 |
+
|
9 |
+
import dill
|
10 |
+
from enum import EnumMeta
|
11 |
+
import sys
|
12 |
+
dill.settings['recurse'] = True
|
13 |
+
|
14 |
+
# test classdefs
|
15 |
+
class _class:
|
16 |
+
def _method(self):
|
17 |
+
pass
|
18 |
+
def ok(self):
|
19 |
+
return True
|
20 |
+
|
21 |
+
class _class2:
|
22 |
+
def __call__(self):
|
23 |
+
pass
|
24 |
+
def ok(self):
|
25 |
+
return True
|
26 |
+
|
27 |
+
class _newclass(object):
|
28 |
+
def _method(self):
|
29 |
+
pass
|
30 |
+
def ok(self):
|
31 |
+
return True
|
32 |
+
|
33 |
+
class _newclass2(object):
|
34 |
+
def __call__(self):
|
35 |
+
pass
|
36 |
+
def ok(self):
|
37 |
+
return True
|
38 |
+
|
39 |
+
class _meta(type):
|
40 |
+
pass
|
41 |
+
|
42 |
+
def __call__(self):
|
43 |
+
pass
|
44 |
+
def ok(self):
|
45 |
+
return True
|
46 |
+
|
47 |
+
_mclass = _meta("_mclass", (object,), {"__call__": __call__, "ok": ok})
|
48 |
+
|
49 |
+
del __call__
|
50 |
+
del ok
|
51 |
+
|
52 |
+
o = _class()
|
53 |
+
oc = _class2()
|
54 |
+
n = _newclass()
|
55 |
+
nc = _newclass2()
|
56 |
+
m = _mclass()
|
57 |
+
|
58 |
+
if sys.hexversion < 0x03090000:
|
59 |
+
import typing
|
60 |
+
class customIntList(typing.List[int]):
|
61 |
+
pass
|
62 |
+
else:
|
63 |
+
class customIntList(list[int]):
|
64 |
+
pass
|
65 |
+
|
66 |
+
# test pickles for class instances
|
67 |
+
def test_class_instances():
|
68 |
+
assert dill.pickles(o)
|
69 |
+
assert dill.pickles(oc)
|
70 |
+
assert dill.pickles(n)
|
71 |
+
assert dill.pickles(nc)
|
72 |
+
assert dill.pickles(m)
|
73 |
+
|
74 |
+
def test_class_objects():
|
75 |
+
clslist = [_class,_class2,_newclass,_newclass2,_mclass]
|
76 |
+
objlist = [o,oc,n,nc,m]
|
77 |
+
_clslist = [dill.dumps(obj) for obj in clslist]
|
78 |
+
_objlist = [dill.dumps(obj) for obj in objlist]
|
79 |
+
|
80 |
+
for obj in clslist:
|
81 |
+
globals().pop(obj.__name__)
|
82 |
+
del clslist
|
83 |
+
for obj in ['o','oc','n','nc']:
|
84 |
+
globals().pop(obj)
|
85 |
+
del objlist
|
86 |
+
del obj
|
87 |
+
|
88 |
+
for obj,cls in zip(_objlist,_clslist):
|
89 |
+
_cls = dill.loads(cls)
|
90 |
+
_obj = dill.loads(obj)
|
91 |
+
assert _obj.ok()
|
92 |
+
assert _cls.ok(_cls())
|
93 |
+
if _cls.__name__ == "_mclass":
|
94 |
+
assert type(_cls).__name__ == "_meta"
|
95 |
+
|
96 |
+
# test NoneType
|
97 |
+
def test_specialtypes():
|
98 |
+
assert dill.pickles(type(None))
|
99 |
+
assert dill.pickles(type(NotImplemented))
|
100 |
+
assert dill.pickles(type(Ellipsis))
|
101 |
+
assert dill.pickles(type(EnumMeta))
|
102 |
+
|
103 |
+
from collections import namedtuple
|
104 |
+
Z = namedtuple("Z", ['a','b'])
|
105 |
+
Zi = Z(0,1)
|
106 |
+
X = namedtuple("Y", ['a','b'])
|
107 |
+
X.__name__ = "X"
|
108 |
+
X.__qualname__ = "X" #XXX: name must 'match' or fails to pickle
|
109 |
+
Xi = X(0,1)
|
110 |
+
Bad = namedtuple("FakeName", ['a','b'])
|
111 |
+
Badi = Bad(0,1)
|
112 |
+
Defaults = namedtuple('Defaults', ['x', 'y'], defaults=[1])
|
113 |
+
Defaultsi = Defaults(2)
|
114 |
+
|
115 |
+
# test namedtuple
|
116 |
+
def test_namedtuple():
|
117 |
+
assert Z is dill.loads(dill.dumps(Z))
|
118 |
+
assert Zi == dill.loads(dill.dumps(Zi))
|
119 |
+
assert X is dill.loads(dill.dumps(X))
|
120 |
+
assert Xi == dill.loads(dill.dumps(Xi))
|
121 |
+
assert Defaults is dill.loads(dill.dumps(Defaults))
|
122 |
+
assert Defaultsi == dill.loads(dill.dumps(Defaultsi))
|
123 |
+
assert Bad is not dill.loads(dill.dumps(Bad))
|
124 |
+
assert Bad._fields == dill.loads(dill.dumps(Bad))._fields
|
125 |
+
assert tuple(Badi) == tuple(dill.loads(dill.dumps(Badi)))
|
126 |
+
|
127 |
+
class A:
|
128 |
+
class B(namedtuple("C", ["one", "two"])):
|
129 |
+
'''docstring'''
|
130 |
+
B.__module__ = 'testing'
|
131 |
+
|
132 |
+
a = A()
|
133 |
+
assert dill.copy(a)
|
134 |
+
|
135 |
+
assert dill.copy(A.B).__name__ == 'B'
|
136 |
+
assert dill.copy(A.B).__qualname__.endswith('.<locals>.A.B')
|
137 |
+
assert dill.copy(A.B).__doc__ == 'docstring'
|
138 |
+
assert dill.copy(A.B).__module__ == 'testing'
|
139 |
+
|
140 |
+
from typing import NamedTuple
|
141 |
+
|
142 |
+
def A():
|
143 |
+
class B(NamedTuple):
|
144 |
+
x: int
|
145 |
+
return B
|
146 |
+
|
147 |
+
assert type(dill.copy(A()(8))).__qualname__ == type(A()(8)).__qualname__
|
148 |
+
|
149 |
+
def test_dtype():
|
150 |
+
try:
|
151 |
+
import numpy as np
|
152 |
+
|
153 |
+
dti = np.dtype('int')
|
154 |
+
assert np.dtype == dill.copy(np.dtype)
|
155 |
+
assert dti == dill.copy(dti)
|
156 |
+
except ImportError: pass
|
157 |
+
|
158 |
+
|
159 |
+
def test_array_nested():
|
160 |
+
try:
|
161 |
+
import numpy as np
|
162 |
+
|
163 |
+
x = np.array([1])
|
164 |
+
y = (x,)
|
165 |
+
assert y == dill.copy(y)
|
166 |
+
|
167 |
+
except ImportError: pass
|
168 |
+
|
169 |
+
|
170 |
+
def test_array_subclass():
|
171 |
+
try:
|
172 |
+
import numpy as np
|
173 |
+
|
174 |
+
class TestArray(np.ndarray):
|
175 |
+
def __new__(cls, input_array, color):
|
176 |
+
obj = np.asarray(input_array).view(cls)
|
177 |
+
obj.color = color
|
178 |
+
return obj
|
179 |
+
def __array_finalize__(self, obj):
|
180 |
+
if obj is None:
|
181 |
+
return
|
182 |
+
if isinstance(obj, type(self)):
|
183 |
+
self.color = obj.color
|
184 |
+
def __getnewargs__(self):
|
185 |
+
return np.asarray(self), self.color
|
186 |
+
|
187 |
+
a1 = TestArray(np.zeros(100), color='green')
|
188 |
+
if not dill._dill.IS_PYPY:
|
189 |
+
assert dill.pickles(a1)
|
190 |
+
assert a1.__dict__ == dill.copy(a1).__dict__
|
191 |
+
|
192 |
+
a2 = a1[0:9]
|
193 |
+
if not dill._dill.IS_PYPY:
|
194 |
+
assert dill.pickles(a2)
|
195 |
+
assert a2.__dict__ == dill.copy(a2).__dict__
|
196 |
+
|
197 |
+
class TestArray2(np.ndarray):
|
198 |
+
color = 'blue'
|
199 |
+
|
200 |
+
a3 = TestArray2([1,2,3,4,5])
|
201 |
+
a3.color = 'green'
|
202 |
+
if not dill._dill.IS_PYPY:
|
203 |
+
assert dill.pickles(a3)
|
204 |
+
assert a3.__dict__ == dill.copy(a3).__dict__
|
205 |
+
|
206 |
+
except ImportError: pass
|
207 |
+
|
208 |
+
|
209 |
+
def test_method_decorator():
|
210 |
+
class A(object):
|
211 |
+
@classmethod
|
212 |
+
def test(cls):
|
213 |
+
pass
|
214 |
+
|
215 |
+
a = A()
|
216 |
+
|
217 |
+
res = dill.dumps(a)
|
218 |
+
new_obj = dill.loads(res)
|
219 |
+
new_obj.__class__.test()
|
220 |
+
|
221 |
+
# test slots
|
222 |
+
class Y(object):
|
223 |
+
__slots__ = ('y', '__weakref__')
|
224 |
+
def __init__(self, y):
|
225 |
+
self.y = y
|
226 |
+
|
227 |
+
value = 123
|
228 |
+
y = Y(value)
|
229 |
+
|
230 |
+
class Y2(object):
|
231 |
+
__slots__ = 'y'
|
232 |
+
def __init__(self, y):
|
233 |
+
self.y = y
|
234 |
+
|
235 |
+
def test_slots():
|
236 |
+
assert dill.pickles(Y)
|
237 |
+
assert dill.pickles(y)
|
238 |
+
assert dill.pickles(Y.y)
|
239 |
+
assert dill.copy(y).y == value
|
240 |
+
assert dill.copy(Y2(value)).y == value
|
241 |
+
|
242 |
+
def test_origbases():
|
243 |
+
assert dill.copy(customIntList).__orig_bases__ == customIntList.__orig_bases__
|
244 |
+
|
245 |
+
def test_attr():
|
246 |
+
import attr
|
247 |
+
@attr.s
|
248 |
+
class A:
|
249 |
+
a = attr.ib()
|
250 |
+
|
251 |
+
v = A(1)
|
252 |
+
assert dill.copy(v) == v
|
253 |
+
|
254 |
+
def test_metaclass():
|
255 |
+
class metaclass_with_new(type):
|
256 |
+
def __new__(mcls, name, bases, ns, **kwds):
|
257 |
+
cls = super().__new__(mcls, name, bases, ns, **kwds)
|
258 |
+
assert mcls is not None
|
259 |
+
assert cls.method(mcls)
|
260 |
+
return cls
|
261 |
+
def method(cls, mcls):
|
262 |
+
return isinstance(cls, mcls)
|
263 |
+
|
264 |
+
l = locals()
|
265 |
+
exec("""class subclass_with_new(metaclass=metaclass_with_new):
|
266 |
+
def __new__(cls):
|
267 |
+
self = super().__new__(cls)
|
268 |
+
return self""", None, l)
|
269 |
+
subclass_with_new = l['subclass_with_new']
|
270 |
+
|
271 |
+
assert dill.copy(subclass_with_new())
|
272 |
+
|
273 |
+
def test_enummeta():
|
274 |
+
from http import HTTPStatus
|
275 |
+
import enum
|
276 |
+
assert dill.copy(HTTPStatus.OK) is HTTPStatus.OK
|
277 |
+
assert dill.copy(enum.EnumMeta) is enum.EnumMeta
|
278 |
+
|
279 |
+
def test_inherit(): #NOTE: see issue #612
|
280 |
+
class Foo:
|
281 |
+
w = 0
|
282 |
+
x = 1
|
283 |
+
y = 1.1
|
284 |
+
a = ()
|
285 |
+
b = (1,)
|
286 |
+
n = None
|
287 |
+
|
288 |
+
class Bar(Foo):
|
289 |
+
w = 2
|
290 |
+
x = 1
|
291 |
+
y = 1.1
|
292 |
+
z = 0.2
|
293 |
+
a = ()
|
294 |
+
b = (1,)
|
295 |
+
c = (2,)
|
296 |
+
n = None
|
297 |
+
|
298 |
+
Baz = dill.copy(Bar)
|
299 |
+
|
300 |
+
import platform
|
301 |
+
is_pypy = platform.python_implementation() == 'PyPy'
|
302 |
+
assert Bar.__dict__ == Baz.__dict__
|
303 |
+
# ints
|
304 |
+
assert 'w' in Bar.__dict__ and 'w' in Baz.__dict__
|
305 |
+
assert Bar.__dict__['w'] is Baz.__dict__['w']
|
306 |
+
assert 'x' in Bar.__dict__ and 'x' in Baz.__dict__
|
307 |
+
assert Bar.__dict__['x'] is Baz.__dict__['x']
|
308 |
+
# floats
|
309 |
+
assert 'y' in Bar.__dict__ and 'y' in Baz.__dict__
|
310 |
+
same = Bar.__dict__['y'] is Baz.__dict__['y']
|
311 |
+
assert same if is_pypy else not same
|
312 |
+
assert 'z' in Bar.__dict__ and 'z' in Baz.__dict__
|
313 |
+
same = Bar.__dict__['z'] is Baz.__dict__['z']
|
314 |
+
assert same if is_pypy else not same
|
315 |
+
# tuples
|
316 |
+
assert 'a' in Bar.__dict__ and 'a' in Baz.__dict__
|
317 |
+
assert Bar.__dict__['a'] is Baz.__dict__['a']
|
318 |
+
assert 'b' in Bar.__dict__ and 'b' in Baz.__dict__
|
319 |
+
assert Bar.__dict__['b'] is not Baz.__dict__['b']
|
320 |
+
assert 'c' in Bar.__dict__ and 'c' in Baz.__dict__
|
321 |
+
assert Bar.__dict__['c'] is not Baz.__dict__['c']
|
322 |
+
# None
|
323 |
+
assert 'n' in Bar.__dict__ and 'n' in Baz.__dict__
|
324 |
+
assert Bar.__dict__['n'] is Baz.__dict__['n']
|
325 |
+
|
326 |
+
|
327 |
+
if __name__ == '__main__':
|
328 |
+
test_class_instances()
|
329 |
+
test_class_objects()
|
330 |
+
test_specialtypes()
|
331 |
+
test_namedtuple()
|
332 |
+
test_dtype()
|
333 |
+
test_array_nested()
|
334 |
+
test_array_subclass()
|
335 |
+
test_method_decorator()
|
336 |
+
test_slots()
|
337 |
+
test_origbases()
|
338 |
+
test_metaclass()
|
339 |
+
test_enummeta()
|
340 |
+
test_inherit()
|
venv/lib/python3.10/site-packages/dill/tests/test_dataclasses.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
#
|
3 |
+
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
|
4 |
+
# Author: Anirudh Vegesana ([email protected])
|
5 |
+
# Copyright (c) 2022-2024 The Uncertainty Quantification Foundation.
|
6 |
+
# License: 3-clause BSD. The full license text is available at:
|
7 |
+
# - https://github.com/uqfoundation/dill/blob/master/LICENSE
|
8 |
+
"""
|
9 |
+
test pickling a dataclass
|
10 |
+
"""
|
11 |
+
|
12 |
+
import dill
|
13 |
+
import dataclasses
|
14 |
+
|
15 |
+
def test_dataclasses():
|
16 |
+
# Issue #500
|
17 |
+
@dataclasses.dataclass
|
18 |
+
class A:
|
19 |
+
x: int
|
20 |
+
y: str
|
21 |
+
|
22 |
+
@dataclasses.dataclass
|
23 |
+
class B:
|
24 |
+
a: A
|
25 |
+
|
26 |
+
a = A(1, "test")
|
27 |
+
before = B(a)
|
28 |
+
save = dill.dumps(before)
|
29 |
+
after = dill.loads(save)
|
30 |
+
assert before != after # classes don't match
|
31 |
+
assert before == B(A(**dataclasses.asdict(after.a)))
|
32 |
+
assert dataclasses.asdict(before) == dataclasses.asdict(after)
|
33 |
+
|
34 |
+
if __name__ == '__main__':
|
35 |
+
test_dataclasses()
|