elements 3.8.2__tar.gz → 3.8.4__tar.gz
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.
- {elements-3.8.2/elements.egg-info → elements-3.8.4}/PKG-INFO +1 -1
- {elements-3.8.2 → elements-3.8.4}/elements/__init__.py +1 -1
- {elements-3.8.2 → elements-3.8.4}/elements/logger.py +20 -39
- {elements-3.8.2 → elements-3.8.4}/elements/path.py +3 -2
- {elements-3.8.2 → elements-3.8.4}/elements/usage.py +4 -2
- {elements-3.8.2 → elements-3.8.4}/elements/when.py +5 -4
- {elements-3.8.2 → elements-3.8.4/elements.egg-info}/PKG-INFO +1 -1
- {elements-3.8.2 → elements-3.8.4}/LICENSE +0 -0
- {elements-3.8.2 → elements-3.8.4}/MANIFEST.in +0 -0
- {elements-3.8.2 → elements-3.8.4}/README.md +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements/agg.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements/checkpoint.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements/config.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements/counter.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements/flags.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements/fps.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements/plotting.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements/printing.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements/rwlock.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements/timer.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements/tree.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements/utils.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements/uuid.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements.egg-info/SOURCES.txt +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements.egg-info/dependency_links.txt +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements.egg-info/requires.txt +0 -0
- {elements-3.8.2 → elements-3.8.4}/elements.egg-info/top_level.txt +0 -0
- {elements-3.8.2 → elements-3.8.4}/requirements-optional.txt +0 -0
- {elements-3.8.2 → elements-3.8.4}/requirements.txt +0 -0
- {elements-3.8.2 → elements-3.8.4}/setup.cfg +0 -0
- {elements-3.8.2 → elements-3.8.4}/setup.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/tests/test_basics.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/tests/test_checkpoint.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/tests/test_flags.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/tests/test_path.py +0 -0
- {elements-3.8.2 → elements-3.8.4}/tests/test_tree.py +0 -0
|
@@ -3,12 +3,11 @@ import concurrent.futures
|
|
|
3
3
|
import json
|
|
4
4
|
import os
|
|
5
5
|
import re
|
|
6
|
-
import time
|
|
7
6
|
|
|
8
7
|
import numpy as np
|
|
9
8
|
|
|
10
|
-
from . import printing
|
|
11
9
|
from . import path
|
|
10
|
+
from . import printing
|
|
12
11
|
from . import timer
|
|
13
12
|
|
|
14
13
|
|
|
@@ -68,15 +67,12 @@ class Logger:
|
|
|
68
67
|
self.add({name: value})
|
|
69
68
|
|
|
70
69
|
@timer.section('logger_write')
|
|
71
|
-
def write(self
|
|
72
|
-
if fps:
|
|
73
|
-
value = self._compute_fps()
|
|
74
|
-
if value is not None:
|
|
75
|
-
self.scalar('fps', value)
|
|
70
|
+
def write(self):
|
|
76
71
|
if not self._metrics:
|
|
77
72
|
return
|
|
78
73
|
for output in self.outputs:
|
|
79
|
-
|
|
74
|
+
with timer.section(type(output).__name__):
|
|
75
|
+
output(tuple(self._metrics))
|
|
80
76
|
self._metrics.clear()
|
|
81
77
|
|
|
82
78
|
def close(self):
|
|
@@ -88,18 +84,6 @@ class Logger:
|
|
|
88
84
|
except Exception as e:
|
|
89
85
|
print(f'Error waiting on output: {e}')
|
|
90
86
|
|
|
91
|
-
def _compute_fps(self):
|
|
92
|
-
step = int(self.step) * self.multiplier
|
|
93
|
-
if self._last_step is None:
|
|
94
|
-
self._last_time = time.time()
|
|
95
|
-
self._last_step = step
|
|
96
|
-
return None
|
|
97
|
-
steps = step - self._last_step
|
|
98
|
-
duration = time.time() - self._last_time
|
|
99
|
-
self._last_time += duration
|
|
100
|
-
self._last_step = step
|
|
101
|
-
return steps / duration
|
|
102
|
-
|
|
103
87
|
|
|
104
88
|
class AsyncOutput:
|
|
105
89
|
|
|
@@ -107,7 +91,9 @@ class AsyncOutput:
|
|
|
107
91
|
self._callback = callback
|
|
108
92
|
self._parallel = parallel
|
|
109
93
|
if parallel:
|
|
110
|
-
|
|
94
|
+
name = type(self).__name__
|
|
95
|
+
self._worker = concurrent.futures.ThreadPoolExecutor(
|
|
96
|
+
1, f'logger_{name}_async')
|
|
111
97
|
self._future = None
|
|
112
98
|
|
|
113
99
|
def wait(self):
|
|
@@ -144,19 +130,20 @@ class TerminalOutput:
|
|
|
144
130
|
scalars = dict(list(scalars.items())[:self._limit])
|
|
145
131
|
formatted = {k: self._format_value(v) for k, v in scalars.items()}
|
|
146
132
|
if self._name:
|
|
147
|
-
header = f'{"-"*20}[{self._name} Step {step}]{"-"*20}'
|
|
133
|
+
header = f'{"-" * 20}[{self._name} Step {step}]{"-" * 20}'
|
|
148
134
|
else:
|
|
149
|
-
header = f'{"-"*20}[Step {step}]{"-"*20}'
|
|
150
|
-
|
|
151
|
-
content = ' / '.join(f'{k} {v}' for k, v in formatted.items())
|
|
152
|
-
else:
|
|
153
|
-
content = 'No metrics.'
|
|
135
|
+
header = f'{"-" * 20}[Step {step}]{"-" * 20}'
|
|
136
|
+
content = ''
|
|
154
137
|
if self._pattern:
|
|
155
|
-
content += f"
|
|
138
|
+
content += f"Metrics filtered by: '{self._pattern.pattern}'"
|
|
156
139
|
elif truncated:
|
|
157
|
-
content += f'
|
|
158
|
-
|
|
159
|
-
|
|
140
|
+
content += f'{truncated} metrics truncated, filter to see specific keys.'
|
|
141
|
+
content += '\n'
|
|
142
|
+
if formatted:
|
|
143
|
+
content += ' / '.join(f'{k} {v}' for k, v in formatted.items())
|
|
144
|
+
else:
|
|
145
|
+
content += 'No metrics.'
|
|
146
|
+
printing.print_(f'\n{header}\n{content}\n', flush=True)
|
|
160
147
|
|
|
161
148
|
def _format_value(self, value):
|
|
162
149
|
value = float(value)
|
|
@@ -291,16 +278,10 @@ class TensorBoardOutput(AsyncOutput):
|
|
|
291
278
|
|
|
292
279
|
class WandBOutput:
|
|
293
280
|
|
|
294
|
-
def __init__(self, name,
|
|
281
|
+
def __init__(self, name, pattern=r'.*', **kwargs):
|
|
295
282
|
self._pattern = re.compile(pattern)
|
|
296
283
|
import wandb
|
|
297
|
-
wandb.init(
|
|
298
|
-
project='embodied',
|
|
299
|
-
name=name,
|
|
300
|
-
# sync_tensorboard=True,
|
|
301
|
-
entity='word-bots',
|
|
302
|
-
config=config and dict(config),
|
|
303
|
-
)
|
|
284
|
+
wandb.init(name=name, **kwargs)
|
|
304
285
|
self._wandb = wandb
|
|
305
286
|
|
|
306
287
|
def __call__(self, summaries):
|
|
@@ -200,8 +200,9 @@ class TFPath(Path):
|
|
|
200
200
|
path = str(self)
|
|
201
201
|
if 'a' in mode and path.startswith('/cns/'):
|
|
202
202
|
path += '%r=3.2'
|
|
203
|
-
if mode.startswith('x')
|
|
204
|
-
|
|
203
|
+
if mode.startswith('x'):
|
|
204
|
+
if self.exists():
|
|
205
|
+
raise FileExistsError(path)
|
|
205
206
|
mode = mode.replace('x', 'w')
|
|
206
207
|
with self.gfile.GFile(path, mode) as f:
|
|
207
208
|
yield f
|
|
@@ -193,8 +193,9 @@ class GcStats:
|
|
|
193
193
|
|
|
194
194
|
class MallocStats:
|
|
195
195
|
|
|
196
|
-
def __init__(self):
|
|
196
|
+
def __init__(self, root_module):
|
|
197
197
|
tracemalloc.start()
|
|
198
|
+
self.root_module = root_module
|
|
198
199
|
self.previous = None
|
|
199
200
|
|
|
200
201
|
@timer.section('malloc_stats')
|
|
@@ -207,7 +208,7 @@ class MallocStats:
|
|
|
207
208
|
log and print(stats['full'])
|
|
208
209
|
return stats
|
|
209
210
|
|
|
210
|
-
def _summary(self, snapshot, relative=None, top=50
|
|
211
|
+
def _summary(self, snapshot, relative=None, top=50):
|
|
211
212
|
if relative:
|
|
212
213
|
statistics = snapshot.compare_to(relative, 'traceback')
|
|
213
214
|
else:
|
|
@@ -216,6 +217,7 @@ class MallocStats:
|
|
|
216
217
|
for stat in statistics:
|
|
217
218
|
filename = stat.traceback[-1].filename
|
|
218
219
|
lineno = stat.traceback[-1].lineno
|
|
220
|
+
root = self.root_module
|
|
219
221
|
for frame in reversed(stat.traceback):
|
|
220
222
|
if f'/{root}/' in frame.filename:
|
|
221
223
|
filename = f'{root}/' + frame.filename.split(f'/{root}/')[-1]
|
|
@@ -68,19 +68,20 @@ class Until:
|
|
|
68
68
|
|
|
69
69
|
class Clock:
|
|
70
70
|
|
|
71
|
-
def __init__(self, every):
|
|
71
|
+
def __init__(self, every, first=True):
|
|
72
72
|
self._every = every
|
|
73
73
|
self._prev = None
|
|
74
|
+
self._first = first
|
|
74
75
|
|
|
75
76
|
def __call__(self, step=None):
|
|
76
77
|
if self._every < 0:
|
|
77
|
-
return True
|
|
78
|
-
if self._every == 0:
|
|
79
78
|
return False
|
|
79
|
+
if self._every == 0:
|
|
80
|
+
return True
|
|
80
81
|
now = time.time()
|
|
81
82
|
if self._prev is None:
|
|
82
83
|
self._prev = now
|
|
83
|
-
return
|
|
84
|
+
return self._first
|
|
84
85
|
if now >= self._prev + self._every:
|
|
85
86
|
# self._prev += self._every
|
|
86
87
|
self._prev = now
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|