checkpointer 1.0.0__py3-none-any.whl → 1.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,5 @@
1
1
  import inspect
2
2
  from types import FunctionType, CodeType
3
- from relib.raypipe import raypipe
4
3
  import relib.hashing as hashing
5
4
  from pathlib import Path
6
5
  from .utils import unwrap_func
@@ -18,11 +17,9 @@ def get_function_body(func):
18
17
  return '\n'.join(lines)
19
18
 
20
19
  def get_code_children(__code__):
21
- return raypipe \
22
- .filter(lambda const: isinstance(const, CodeType)) \
23
- .flat_map(get_code_children) \
24
- .do(lambda children: list(__code__.co_names) + children) \
25
- .compute(__code__.co_consts)
20
+ consts = [const for const in __code__.co_consts if isinstance(const, CodeType)]
21
+ children = [child for const in consts for child in get_code_children(const)]
22
+ return list(__code__.co_names) + children
26
23
 
27
24
  def get_func_children(func, neighbor_funcs=[]):
28
25
  def get_candidate_func(co_name):
@@ -36,23 +33,20 @@ def get_func_children(func, neighbor_funcs=[]):
36
33
 
37
34
  code_children = get_code_children(func.__code__)
38
35
 
39
- func_children = raypipe \
40
- .map(get_candidate_func) \
41
- .filter(clear_candidate) \
42
- .compute(code_children)
36
+ func_children = [get_candidate_func(child) for child in code_children]
37
+ func_children = [child for child in func_children if clear_candidate(child)]
43
38
 
44
- funcs = raypipe \
45
- .flat_map(lambda child_func: \
46
- get_func_children(child_func, func_children)
47
- ) \
48
- .do(lambda grand_children: [func] + grand_children) \
49
- .sort_distinct(lambda func: func.__name__) \
50
- .compute(func_children)
39
+ funcs = [func] + [
40
+ deep_child
41
+ for child_func in func_children
42
+ for deep_child in get_func_children(child_func, func_children)
43
+ ]
44
+ funcs = sorted(set(funcs), key=lambda func: func.__name__)
51
45
 
52
46
  return funcs
53
47
 
54
48
  def get_function_hash(func):
55
49
  funcs = [func] + get_func_children(func)
56
- function_bodies = raypipe.map(get_function_body).compute(funcs)
50
+ function_bodies = list(map(get_function_body, funcs))
57
51
  function_bodies_hash = hashing.hash(function_bodies)
58
52
  return function_bodies_hash
checkpointer/utils.py CHANGED
@@ -1,4 +1,4 @@
1
- import asyncio
1
+ import types
2
2
 
3
3
  def unwrap_func(func):
4
4
  if hasattr(func, '__wrapped__'):
@@ -6,7 +6,7 @@ def unwrap_func(func):
6
6
  else:
7
7
  return func
8
8
 
9
- @asyncio.coroutine
9
+ @types.coroutine
10
10
  def coroutine_as_generator(coroutine):
11
11
  val = yield from coroutine
12
12
  return val
@@ -1,16 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: checkpointer
3
- Version: 1.0.0
4
- Summary: UNKNOWN
3
+ Version: 1.1.0
5
4
  Home-page: https://github.com/Reddan/checkpointer
6
5
  Author: Hampus Hallman
7
6
  Author-email: me@hampushallman.com
8
7
  License: MIT
9
- Platform: UNKNOWN
10
8
  Requires-Python: ~=3.5
11
9
  License-File: LICENSE.txt
12
10
  Requires-Dist: relib
13
11
  Requires-Dist: termcolor
14
12
 
15
- UNKNOWN
16
-
@@ -1,13 +1,13 @@
1
1
  checkpointer/__init__.py,sha256=_RYcKsZbeUf08KZ-DcXlNn4eAMWh2LN9o-KvchYVmmk,380
2
2
  checkpointer/checkpoint.py,sha256=FyL78HvAvPtgl-esiAkt-CdekT18J2Sh0SriMtX4QLc,2367
3
- checkpointer/function_body.py,sha256=kBsgCPeNgQzgXFToTuqQYYvAQicetXtv-UGwyd5b4Ew,1760
3
+ checkpointer/function_body.py,sha256=aitzBFoEIo_E-aL2oe4Nr_T_Oy8ehKInGb1XYjeLzX8,1703
4
4
  checkpointer/storage.py,sha256=Ofuh0dKF5vk4_B4djt3Q6qyZhIO5f59uCNCZjMrto0U,1782
5
- checkpointer/utils.py,sha256=5CFQHUAlrORFpcg-TGuvAUQDeCEXvvx6yPl8mor5jh8,381
5
+ checkpointer/utils.py,sha256=Kzh2qXxq2Lgjiqfv6KcOwXdw7sh70uCn4a_uXYwLhiM,377
6
6
  checkpointer/storages/bcolz_storage.py,sha256=Yk7FI75noe9hZBWVFIRetiFSR7tkzbryYlBmxX-lVlw,2728
7
7
  checkpointer/storages/memory_storage.py,sha256=S4SgKSApbQE-pxxKRWLNJqyZMRQwaw5-N0DOIsZM7mE,364
8
8
  checkpointer/storages/pickle_storage.py,sha256=zcnX1GG6XPHvVxi7gCab5oFxKoz5E7LZHYH74VL1hkY,1542
9
- checkpointer-1.0.0.dist-info/LICENSE.txt,sha256=2c7g4mni-RUemFGkk6GnoFwknh-leF04BF_J_3gp4sg,1054
10
- checkpointer-1.0.0.dist-info/METADATA,sha256=kmuSQOTbRa5KaFBlr48K-Fin7bRD3L7aIZiC0Lx8v6o,317
11
- checkpointer-1.0.0.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
12
- checkpointer-1.0.0.dist-info/top_level.txt,sha256=uF0eyHpShnsHI3sobErnhQ8LWCT8DPViqAznKeTaZlw,13
13
- checkpointer-1.0.0.dist-info/RECORD,,
9
+ checkpointer-1.1.0.dist-info/LICENSE.txt,sha256=2c7g4mni-RUemFGkk6GnoFwknh-leF04BF_J_3gp4sg,1054
10
+ checkpointer-1.1.0.dist-info/METADATA,sha256=_isCKu9zdEI1Z-umSB6mr-X7lEVBVjlU_QvRNYolUNQ,273
11
+ checkpointer-1.1.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
12
+ checkpointer-1.1.0.dist-info/top_level.txt,sha256=uF0eyHpShnsHI3sobErnhQ8LWCT8DPViqAznKeTaZlw,13
13
+ checkpointer-1.1.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.37.0)
2
+ Generator: bdist_wheel (0.42.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5