Skip to content

Commit 93cd685

Browse files
committed
Working h5 backend
1 parent 538b79c commit 93cd685

File tree

5 files changed

+114
-106
lines changed

5 files changed

+114
-106
lines changed

CHANGELOG.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# Changelog
22

3+
- *0.3.0*
4+
- Abstraction layer for filesystem operations
5+
- Chunked and non-chunked filesystem storage
6+
- Better cache-layer management
37
- *0.2.0*
4-
- Refactor (@mlw214)
5-
- App factory
6-
- Code restyle
7-
- [Much more](https://github.com/aplbrain/bossphorus/commit/50cb3b6aced9fbe83c1fee51d5c7378b0095fdd9)
8+
- Refactor (@mlw214)
9+
- App factory
10+
- Code restyle
11+
- [Much more](https://github.com/aplbrain/bossphorus/commit/50cb3b6aced9fbe83c1fee51d5c7378b0095fdd9)
812
- **0.1.0** (May 14, 2018)
9-
- Initial commit and all pre-history
13+
- Initial commit and all pre-history

bossphorus/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def create_app(mgr: storagemanager.StorageManager = None):
3939
Create a Bossphorus server app.
4040
"""
4141
app = Flask(__name__)
42+
created = datetime.datetime.now()
4243
if mgr:
4344
manager = mgr
4445
else:
@@ -187,6 +188,7 @@ def home():
187188
"cache_stack": [*manager.get_stack_names()],
188189
"server_time": datetime.datetime.now(),
189190
"platform": sys.platform,
191+
"server_born": created,
190192
}
191193
)
192194

bossphorus/storagemanager/_ChunkedFilesystemStorageManager.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,7 @@ def __init__(
148148
self.block_size = block_size
149149

150150
self.fs = (
151-
{"npy": NpyChunkedFileInterface}.get(
152-
kwargs.get("preferred_format", "npy")
153-
)
151+
{"npy": NpyChunkedFileInterface}.get(kwargs.get("preferred_format", "npy"))
154152
)(self.storage_path, self.block_size)
155153

156154
def hasdata(
@@ -197,11 +195,11 @@ def setdata(
197195
data_partial = np.zeros(self.block_size, dtype="uint8")
198196

199197
data_partial[
200-
i[0][0]: i[0][1], i[1][0]: i[1][1], i[2][0]: i[2][1]
198+
i[0][0] : i[0][1], i[1][0] : i[1][1], i[2][0] : i[2][1]
201199
] = data[
202-
(f[0] + i[0][0]) - xs[0]: (f[0] + i[0][1]) - xs[0],
203-
(f[1] + i[1][0]) - ys[0]: (f[1] + i[1][1]) - ys[0],
204-
(f[2] + i[2][0]) - zs[0]: (f[2] + i[2][1]) - zs[0],
200+
(f[0] + i[0][0]) - xs[0] : (f[0] + i[0][1]) - xs[0],
201+
(f[1] + i[1][0]) - ys[0] : (f[1] + i[1][1]) - ys[0],
202+
(f[2] + i[2][0]) - zs[0] : (f[2] + i[2][1]) - zs[0],
205203
]
206204
data_partial = self.fs.store(data_partial, col, exp, chan, res, f)
207205

@@ -233,16 +231,16 @@ def getdata(
233231
for f, i in zip(files, indices):
234232
try:
235233
data_partial = self.fs.retrieve(col, exp, chan, res, f)[
236-
i[0][0]: i[0][1], i[1][0]: i[1][1], i[2][0]: i[2][1]
234+
i[0][0] : i[0][1], i[1][0] : i[1][1], i[2][0] : i[2][1]
237235
]
238236
except:
239237
data_partial = np.zeros(self.block_size, dtype="uint8")[
240-
i[0][0]: i[0][1], i[1][0]: i[1][1], i[2][0]: i[2][1]
238+
i[0][0] : i[0][1], i[1][0] : i[1][1], i[2][0] : i[2][1]
241239
]
242240
payload[
243-
(f[0] + i[0][0]) - xs[0]: (f[0] + i[0][1]) - xs[0],
244-
(f[1] + i[1][0]) - ys[0]: (f[1] + i[1][1]) - ys[0],
245-
(f[2] + i[2][0]) - zs[0]: (f[2] + i[2][1]) - zs[0],
241+
(f[0] + i[0][0]) - xs[0] : (f[0] + i[0][1]) - xs[0],
242+
(f[1] + i[1][0]) - ys[0] : (f[1] + i[1][1]) - ys[0],
243+
(f[2] + i[2][0]) - zs[0] : (f[2] + i[2][1]) - zs[0],
246244
] = data_partial
247245

248246
return payload

bossphorus/storagemanager/_RelayStorageManager.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ def getdata(
102102
)
103103

104104
def __repr__(self):
105-
return f"<RelayStorageManager [{str(self.boss_remote)}]>"
105+
return f"<RelayStorageManager [BossRemote]>"
106106

107107
def get_stack_names(self):
108108
if self.is_terminal:
109-
return [str(self)]
109+
return [str(self), f"↳{self.boss_remote}"]
110110
else:
111-
return [str(self), *self._next.get_stack_names()]
111+
return [str(self), f"↳{self.boss_remote}", *self._next.get_stack_names()]

bossphorus/templates/home.html

+90-86
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,105 @@
11
<!DOCTYPE html>
22
<html lang="en">
33

4-
<head>
5-
<meta charset="UTF-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8-
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
9-
<style>
10-
body,
11-
html {
12-
font-family: 'Roboto', sans-serif;
13-
max-width: 70em;
14-
margin: auto;
15-
}
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
9+
<style>
10+
body,
11+
html {
12+
font-family: 'Roboto', sans-serif;
13+
max-width: 70em;
14+
margin: auto;
15+
}
1616

17-
table {
18-
width: 100%;
19-
}
17+
table {
18+
width: 100%;
19+
}
2020

21-
tr {
22-
line-height: 1.5em;
23-
}
21+
tr {
22+
line-height: 1.5em;
23+
}
2424

25-
td {
26-
padding: 0em 1.3em;
27-
min-width: 10em;
28-
}
25+
td {
26+
padding: 0em 1.3em;
27+
min-width: 10em;
28+
}
2929

30-
table tr:nth-child(2n),
31-
thead {
32-
background: rgba(10, 10, 40, 0.05);
33-
}
30+
table tr:nth-child(2n),
31+
thead {
32+
background: rgba(10, 10, 40, 0.05);
33+
}
3434

35-
tr:hover {
36-
background: rgba(100, 100, 150, 0.1) !important;
37-
}
35+
tr:hover {
36+
background: rgba(100, 100, 150, 0.1) !important;
37+
}
3838

39-
blockquote {
40-
background: rgba(10, 20, 10, 0.05);
41-
padding: 1em;
42-
}
39+
blockquote {
40+
background: rgba(10, 20, 10, 0.05);
41+
padding: 1em;
42+
}
4343

44-
.img {
45-
width: 100px;
46-
height: 100px;
47-
background: url('/static/boss2x2.png') no-repeat center center;
48-
background-size: cover;
49-
}
44+
.img {
45+
width: 100px;
46+
height: 100px;
47+
background: url('/static/boss2x2.png') no-repeat center center;
48+
background-size: cover;
49+
}
5050

51-
.img:hover {
52-
background: url('/static/boss2x2.gif') no-repeat center center;
53-
background-size: cover;
54-
}
55-
</style>
56-
<title>bossphorus {{ version }}</title>
57-
</head>
51+
.img:hover {
52+
background: url('/static/boss2x2.gif') no-repeat center center;
53+
background-size: cover;
54+
}
55+
</style>
56+
<title>bossphorus {{ version }}</title>
57+
</head>
5858

59-
<body>
60-
<center>
61-
<h1>bossphorus is running.</h1>
62-
<h4>bossphorus version {{ version }}</h4>
63-
<div class="img"></div>
64-
</center>
59+
<body>
60+
<center>
61+
<h1>bossphorus is running.</h1>
62+
<h4>bossphorus version {{ version }}</h4>
63+
<div class="img"></div>
64+
</center>
6565

66-
<blockquote>
67-
<table>
68-
<thead>
69-
<tr>
70-
<th>Key</th>
71-
<th>Value</th>
72-
</tr>
73-
</thead>
74-
<tbody>
75-
<tr>
76-
<td>Version</td>
77-
<td>{{ version }}</td>
78-
</tr>
79-
<tr>
80-
<td rowspan="{{(cache_stack | length) + 1 }}">Cache Stack</td>
81-
<td><code>API Layer</code></td>
82-
</tr>
83-
{% for layer in cache_stack %}
84-
<tr>
85-
<td><code>{{ layer }}</code></td>
86-
</tr>
87-
{% endfor %}
88-
<tr>
89-
<td>Server Time</td>
90-
<td>{{ server_time }}</td>
91-
</tr>
92-
<tr>
93-
<td>Platform</td>
94-
<td>{{ platform }}</td>
95-
</tr>
96-
</tbody>
97-
</table>
98-
</blockquote>
99-
</body>
66+
<blockquote>
67+
<table>
68+
<thead>
69+
<tr>
70+
<th>Key</th>
71+
<th>Value</th>
72+
</tr>
73+
</thead>
74+
<tbody>
75+
<tr>
76+
<td>Version</td>
77+
<td>{{ version }}</td>
78+
</tr>
79+
<tr>
80+
<td rowspan="{{(cache_stack | length) + 1 }}">Cache Stack</td>
81+
<td><code>API Layer</code></td>
82+
</tr>
83+
{% for layer in cache_stack %}
84+
<tr>
85+
<td><code>{{ layer }}</code></td>
86+
</tr>
87+
{% endfor %}
88+
<tr>
89+
<td>Server Time</td>
90+
<td>{{ server_time }}</td>
91+
</tr>
92+
<tr>
93+
<td>Platform</td>
94+
<td>{{ platform }}</td>
95+
</tr>
96+
<tr>
97+
<td>Server Up Since</td>
98+
<td>{{ server_born }}</td>
99+
</tr>
100+
</tbody>
101+
</table>
102+
</blockquote>
103+
</body>
100104

101105
</html>

0 commit comments

Comments
 (0)