scope 0.4.0__tar.gz → 0.4.2__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.
- {scope-0.4.0 → scope-0.4.2}/PKG-INFO +1 -1
- {scope-0.4.0 → scope-0.4.2}/requirements.txt +1 -1
- {scope-0.4.0 → scope-0.4.2}/scope/__init__.py +1 -1
- {scope-0.4.0 → scope-0.4.2}/scope/reader.py +1 -1
- {scope-0.4.0 → scope-0.4.2}/tests/test_float.py +10 -22
- {scope-0.4.0 → scope-0.4.2}/tests/test_image.py +8 -31
- {scope-0.4.0 → scope-0.4.2}/tests/test_video.py +3 -3
- scope-0.4.2/viewer/__main__.py +20 -0
- scope-0.4.2/viewer/config.py +15 -0
- {scope-0.4.0 → scope-0.4.2}/viewer/server.py +6 -18
- scope-0.4.0/viewer/__main__.py +0 -24
- {scope-0.4.0 → scope-0.4.2}/scope/formats.py +0 -0
- {scope-0.4.0 → scope-0.4.2}/scope/writer.py +0 -0
- {scope-0.4.0 → scope-0.4.2}/setup.py +0 -0
- {scope-0.4.0 → scope-0.4.2}/viewer/__init__.py +0 -0
- {scope-0.4.0 → scope-0.4.2}/viewer/dist/favicon.png +0 -0
- {scope-0.4.0 → scope-0.4.2}/viewer/dist/index.html +0 -0
- {scope-0.4.0 → scope-0.4.2}/viewer/dist/logo.png +0 -0
- {scope-0.4.0 → scope-0.4.2}/viewer/filesystems.py +0 -0
|
@@ -21,7 +21,7 @@ class Reader:
|
|
|
21
21
|
self.logdir = logdir / 'scope'
|
|
22
22
|
self.fmts = {x.extension: x for x in formats}
|
|
23
23
|
self.cols = {}
|
|
24
|
-
for child in sorted(logdir.glob('*')):
|
|
24
|
+
for child in sorted(self.logdir.glob('*')):
|
|
25
25
|
basename, ext = child.name.rsplit('.', 1)
|
|
26
26
|
key = basename.replace('-', '/')
|
|
27
27
|
assert re.match(r'[a-z0-9_]+(/[a-z0-9_]+)?', key), key
|
|
@@ -12,9 +12,10 @@ class TestFloat:
|
|
|
12
12
|
writer.add(0, {'foo': 12})
|
|
13
13
|
writer.add(5, {'foo': 42, 'bar': np.float64(np.pi)})
|
|
14
14
|
writer.flush()
|
|
15
|
-
|
|
16
|
-
assert
|
|
17
|
-
assert (logdir / '
|
|
15
|
+
filenames = (logdir / 'scope').glob('*')
|
|
16
|
+
assert {x.name for x in filenames} == {'foo.float', 'bar.float'}
|
|
17
|
+
assert (logdir / 'scope/foo.float').stat().st_size == (8 + 8) * 2
|
|
18
|
+
assert (logdir / 'scope/bar.float').stat().st_size == (8 + 8) * 1
|
|
18
19
|
reader = scope.Reader(logdir)
|
|
19
20
|
assert reader.keys() == tuple(sorted(['foo', 'bar']))
|
|
20
21
|
assert reader.length('foo') == 2
|
|
@@ -29,9 +30,10 @@ class TestFloat:
|
|
|
29
30
|
writer.add(step, {'foo': step, 'bar': step})
|
|
30
31
|
writer.flush()
|
|
31
32
|
writer.flush() # Block until previous flush is done.
|
|
32
|
-
|
|
33
|
-
assert
|
|
34
|
-
assert (logdir / '
|
|
33
|
+
filenames = (logdir / 'scope').glob('*')
|
|
34
|
+
assert {x.name for x in filenames} == {'foo.float', 'bar.float'}
|
|
35
|
+
assert (logdir / 'scope/foo.float').stat().st_size == (8 + 8) * 10
|
|
36
|
+
assert (logdir / 'scope/bar.float').stat().st_size == (8 + 8) * 10
|
|
35
37
|
reader = scope.Reader(logdir)
|
|
36
38
|
assert equal(reader['foo'], (np.arange(10), np.arange(10)))
|
|
37
39
|
assert equal(reader['bar'], (np.arange(10), np.arange(10)))
|
|
@@ -41,27 +43,13 @@ class TestFloat:
|
|
|
41
43
|
writer = scope.Writer(logdir, workers=0)
|
|
42
44
|
writer.add(0, {'foo/bar': 12})
|
|
43
45
|
writer.flush()
|
|
44
|
-
|
|
46
|
+
filenames = (logdir / 'scope').glob('*')
|
|
47
|
+
assert {x.name for x in filenames} == {'foo-bar.float'}
|
|
45
48
|
reader = scope.Reader(logdir)
|
|
46
49
|
assert reader.keys() == ('foo/bar',)
|
|
47
50
|
assert reader.length('foo/bar') == 1
|
|
48
51
|
assert equal(reader['foo/bar'], ([0], [12]), (np.int64, np.float64))
|
|
49
52
|
|
|
50
|
-
# def test_slicing(self, tmpdir):
|
|
51
|
-
# logdir = pathlib.Path(tmpdir)
|
|
52
|
-
# writer = scope.Writer(logdir, workers=0)
|
|
53
|
-
# writer.add(0, {'foo': 12})
|
|
54
|
-
# writer.add(5, {'foo': 42})
|
|
55
|
-
# writer.flush()
|
|
56
|
-
# reader = scope.Reader(logdir)
|
|
57
|
-
# assert equal(reader['foo', 0], ([0], [12]))
|
|
58
|
-
# assert equal(reader['foo', :2], ([0], [12]))
|
|
59
|
-
# assert equal(reader['foo', :5], ([0], [12]))
|
|
60
|
-
# assert equal(reader['foo', :6], ([0, 5], [12, 42]))
|
|
61
|
-
# assert equal(reader['foo', 1:6], ([5], [42]))
|
|
62
|
-
# assert equal(reader['foo', :-1], ([], []))
|
|
63
|
-
# assert equal(reader['foo', 7:], ([], []))
|
|
64
|
-
|
|
65
53
|
|
|
66
54
|
def equal(actuals, references, dtypes=None):
|
|
67
55
|
dtypes = dtypes or [x.dtype for x in actuals]
|
|
@@ -14,9 +14,9 @@ class TestImage:
|
|
|
14
14
|
writer.add(0, {'foo': img1})
|
|
15
15
|
writer.add(5, {'foo': img2})
|
|
16
16
|
writer.flush()
|
|
17
|
-
assert {x.name for x in logdir.glob('*')} == {'foo.png'}
|
|
18
|
-
assert (logdir / 'foo.png
|
|
19
|
-
assert len(list((logdir / 'foo.png').glob('*'))) == 1 + 2
|
|
17
|
+
assert {x.name for x in (logdir / 'scope').glob('*')} == {'foo.png'}
|
|
18
|
+
assert (logdir / 'scope/foo.png/index').stat().st_size == (8 + 8) * 2
|
|
19
|
+
assert len(list((logdir / 'scope/foo.png').glob('*'))) == 1 + 2
|
|
20
20
|
reader = scope.Reader(logdir)
|
|
21
21
|
assert reader.keys() == ('foo',)
|
|
22
22
|
assert reader.length('foo') == 2
|
|
@@ -33,11 +33,11 @@ class TestImage:
|
|
|
33
33
|
writer.add(step, {key: np.full((64, 128, 3), step, np.uint8)})
|
|
34
34
|
writer.flush()
|
|
35
35
|
writer.flush() # Block until previous flush is done.
|
|
36
|
-
assert {x.name for x in logdir.glob('*')} == {
|
|
36
|
+
assert {x.name for x in (logdir / 'scope').glob('*')} == {
|
|
37
37
|
'foo.png', 'bar.png', 'baz.png'}
|
|
38
38
|
for key in ('foo', 'bar', 'baz'):
|
|
39
|
-
assert (logdir / f'{key}.png
|
|
40
|
-
assert len(list((logdir / f'{key}.png').glob('*'))) == 1 + 5
|
|
39
|
+
assert (logdir / f'scope/{key}.png/index').stat().st_size == (8 + 8) * 5
|
|
40
|
+
assert len(list((logdir / f'scope/{key}.png').glob('*'))) == 1 + 5
|
|
41
41
|
reader = scope.Reader(logdir)
|
|
42
42
|
assert reader.keys() == tuple(sorted(['foo', 'bar', 'baz']))
|
|
43
43
|
for key in ('foo', 'bar', 'baz'):
|
|
@@ -55,34 +55,11 @@ class TestImage:
|
|
|
55
55
|
writer = scope.Writer(logdir, workers=0)
|
|
56
56
|
writer.add(0, {'foo/bar': img})
|
|
57
57
|
writer.flush()
|
|
58
|
-
assert {x.name for x in logdir.glob('*')} == {'foo-bar.png'}
|
|
59
|
-
assert len(list((logdir / 'foo-bar.png').glob('*'))) == 1 + 1
|
|
58
|
+
assert {x.name for x in (logdir / 'scope').glob('*')} == {'foo-bar.png'}
|
|
59
|
+
assert len(list((logdir / 'scope/foo-bar.png').glob('*'))) == 1 + 1
|
|
60
60
|
reader = scope.Reader(logdir)
|
|
61
61
|
assert reader.keys() == ('foo/bar',)
|
|
62
62
|
assert reader.length('foo/bar') == 1
|
|
63
63
|
_, filenames = reader['foo/bar']
|
|
64
64
|
assert len(filenames) == 1
|
|
65
65
|
assert (reader.load('foo/bar', filenames[0]) == img).all()
|
|
66
|
-
|
|
67
|
-
# def test_slicing(self, tmpdir):
|
|
68
|
-
# logdir = pathlib.Path(tmpdir)
|
|
69
|
-
# writer = scope.Writer(logdir, workers=0)
|
|
70
|
-
# img1 = np.ones((64, 128, 3), np.uint8) + 12
|
|
71
|
-
# img2 = np.ones((64, 128, 3), np.uint8) + 255
|
|
72
|
-
# writer.add(0, {'foo': img1})
|
|
73
|
-
# writer.add(5, {'foo': img2})
|
|
74
|
-
# writer.flush()
|
|
75
|
-
# assert {x.name for x in logdir.glob('*')} == {'foo.png'}
|
|
76
|
-
# assert (logdir / 'foo.png' / 'index').stat().st_size == (8 + 8) * 2
|
|
77
|
-
# reader = scope.Reader(logdir)
|
|
78
|
-
# assert reader.keys() == ('foo',)
|
|
79
|
-
# assert reader.length('foo') == 2
|
|
80
|
-
# steps, values = reader['foo']
|
|
81
|
-
# assert (steps == np.array([0, 5])).all()
|
|
82
|
-
# assert (values == np.array([img1, img2])).all()
|
|
83
|
-
# assert (reader['foo', 0][1] == img1[None]).all()
|
|
84
|
-
# assert (reader['foo', :5][1] == img1[None]).all()
|
|
85
|
-
# assert (reader['foo', :6][1] == np.array([img1, img2])).all()
|
|
86
|
-
# assert (reader['foo', 1:6][1] == img2[None]).all()
|
|
87
|
-
# assert reader['foo', :-1][1] == ()
|
|
88
|
-
# assert reader['foo', 6:][1] == ()
|
|
@@ -14,12 +14,12 @@ class TestVideo:
|
|
|
14
14
|
writer.add(0, {'foo': vid1})
|
|
15
15
|
writer.add(5, {'foo': vid2})
|
|
16
16
|
writer.flush()
|
|
17
|
-
names = {x.name for x in logdir.glob('*')}
|
|
17
|
+
names = {x.name for x in (logdir / 'scope').glob('*')}
|
|
18
18
|
assert len(names) == 1
|
|
19
19
|
name = list(names)[0]
|
|
20
20
|
assert name in ('foo.mp4', 'foo.webm')
|
|
21
|
-
assert (logdir / name / 'index').stat().st_size == (8 + 8) * 2
|
|
22
|
-
assert len(list((logdir / name).glob('*'))) == 1 + 2
|
|
21
|
+
assert (logdir / 'scope' / name / 'index').stat().st_size == (8 + 8) * 2
|
|
22
|
+
assert len(list((logdir / 'scope' / name).glob('*'))) == 1 + 2
|
|
23
23
|
reader = scope.Reader(logdir)
|
|
24
24
|
assert reader.keys() == ('foo',)
|
|
25
25
|
assert reader.length('foo') == 2
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
import uvicorn
|
|
5
|
+
from . import config
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
config = config.config
|
|
9
|
+
|
|
10
|
+
print(config)
|
|
11
|
+
|
|
12
|
+
sys.path.insert(0, str(pathlib.Path(__file__).parent))
|
|
13
|
+
|
|
14
|
+
uvicorn.run(
|
|
15
|
+
'server:app',
|
|
16
|
+
host='0.0.0.0',
|
|
17
|
+
port=config.port,
|
|
18
|
+
reload=config.debug,
|
|
19
|
+
workers=None if config.debug else config.workers,
|
|
20
|
+
)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
import elements
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
config = elements.Flags(
|
|
7
|
+
port=int(os.environ.get('SCOPE_PORT', 8000)),
|
|
8
|
+
basedir=os.environ.get('SCOPE_BASEDIR', ''),
|
|
9
|
+
filesystem=os.environ.get('SCOPE_FILESYSTEM', 'elements'),
|
|
10
|
+
maxdepth=2,
|
|
11
|
+
workers=32,
|
|
12
|
+
debug=False,
|
|
13
|
+
).parse()
|
|
14
|
+
|
|
15
|
+
assert config.basedir, config.basedir
|
|
@@ -1,36 +1,24 @@
|
|
|
1
1
|
import concurrent.futures
|
|
2
2
|
import functools
|
|
3
|
-
import os
|
|
4
3
|
import pathlib
|
|
5
4
|
import struct
|
|
6
5
|
|
|
7
|
-
import elements
|
|
8
6
|
import fastapi
|
|
9
7
|
import fastapi.responses
|
|
10
8
|
import fastapi.staticfiles
|
|
11
9
|
|
|
12
10
|
import filesystems
|
|
11
|
+
import config
|
|
13
12
|
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
maxdepth=2,
|
|
19
|
-
debug=False,
|
|
20
|
-
).parse()
|
|
21
|
-
print(args)
|
|
22
|
-
assert args.basedir, args.basedir
|
|
23
|
-
basedir = args.basedir.rstrip('/')
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
config = config.config
|
|
15
|
+
app = fastapi.FastAPI(debug=config.debug)
|
|
16
|
+
basedir = config.basedir.rstrip('/')
|
|
26
17
|
fs = dict(
|
|
27
18
|
elements=filesystems.Elements,
|
|
28
19
|
fileutil=filesystems.Fileutil,
|
|
29
20
|
local=filesystems.Local,
|
|
30
|
-
)[
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
app = fastapi.FastAPI(debug=args.debug)
|
|
21
|
+
)[config.filesystem]()
|
|
34
22
|
|
|
35
23
|
|
|
36
24
|
@app.get('/api/exps')
|
|
@@ -101,7 +89,7 @@ dist = pathlib.Path(__file__).parent / 'dist'
|
|
|
101
89
|
app.mount('/', fastapi.staticfiles.StaticFiles(directory=dist, html=True))
|
|
102
90
|
|
|
103
91
|
|
|
104
|
-
def find_runs(folder, maxdepth=
|
|
92
|
+
def find_runs(folder, maxdepth=config.maxdepth, workers=64):
|
|
105
93
|
if not workers:
|
|
106
94
|
runs = []
|
|
107
95
|
queue = [(folder, 0)]
|
scope-0.4.0/viewer/__main__.py
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import pathlib
|
|
3
|
-
import sys
|
|
4
|
-
|
|
5
|
-
import elements
|
|
6
|
-
import uvicorn
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
args, sys.argv[1:] = elements.Flags(
|
|
10
|
-
port=int(os.environ.get('SCOPE_SERVER_PORT', 8000)),
|
|
11
|
-
workers=32,
|
|
12
|
-
debug=False,
|
|
13
|
-
).parse_known()
|
|
14
|
-
|
|
15
|
-
sys.argv.append(f'--debug={args.debug}')
|
|
16
|
-
sys.path.insert(0, str(pathlib.Path(__file__).parent))
|
|
17
|
-
|
|
18
|
-
uvicorn.run(
|
|
19
|
-
'server:app',
|
|
20
|
-
host='0.0.0.0',
|
|
21
|
-
port=args.port,
|
|
22
|
-
reload=args.debug,
|
|
23
|
-
workers=None if args.debug else args.workers,
|
|
24
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|