Skip to content

Commit ee9278c

Browse files
committed
Rename processed_data to computed
1 parent 7a98715 commit ee9278c

File tree

10 files changed

+32
-33
lines changed

10 files changed

+32
-33
lines changed

pydatalab/schemas/cell.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@
239239
"title": "Bokeh Plot Data",
240240
"type": "object"
241241
},
242-
"processed_data": {
243-
"title": "Processed Data",
242+
"computed": {
243+
"title": "Computed",
244244
"type": "object"
245245
},
246246
"metadata": {

pydatalab/schemas/equipment.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@
203203
"title": "Bokeh Plot Data",
204204
"type": "object"
205205
},
206-
"processed_data": {
207-
"title": "Processed Data",
206+
"computed": {
207+
"title": "Computed",
208208
"type": "object"
209209
},
210210
"metadata": {

pydatalab/schemas/sample.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@
292292
"title": "Bokeh Plot Data",
293293
"type": "object"
294294
},
295-
"processed_data": {
296-
"title": "Processed Data",
295+
"computed": {
296+
"title": "Computed",
297297
"type": "object"
298298
},
299299
"metadata": {

pydatalab/schemas/startingmaterial.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@
345345
"title": "Bokeh Plot Data",
346346
"type": "object"
347347
},
348-
"processed_data": {
349-
"title": "Processed Data",
348+
"computed": {
349+
"title": "Computed",
350350
"type": "object"
351351
},
352352
"metadata": {

pydatalab/src/pydatalab/apps/chat/blocks.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def _prepare_item_json_for_chat(self, item_id: str, item_data: dict | None = Non
208208
str(file["immutable_id"]): file["name"] for file in item_data.get("files", [])
209209
}
210210

211-
big_data_keys = ["bokeh_plot_data", "b64_encoded_image"]
211+
big_data_keys = ["bokeh_plot_data", "b64_encoded_image", "computed"]
212212
for block in item_data.get("blocks_obj", {}).values():
213213
block_fields_to_remove = ["item_id", "block_id", "collection_id"] + big_data_keys
214214
[block.pop(field, None) for field in block_fields_to_remove]
@@ -218,13 +218,12 @@ def _prepare_item_json_for_chat(self, item_id: str, item_data: dict | None = Non
218218
"acquisition_parameters",
219219
"carrier_offset_Hz",
220220
"nscans",
221-
"processed_data",
222221
"processed_data_shape",
223222
"processing_parameters",
224223
"pulse_program",
225224
"selected_process",
226225
]
227-
[block.pop(field, None) for field in NMR_fields_to_remove]
226+
[block["metadata"].pop(field, None) for field in NMR_fields_to_remove]
228227

229228
# replace file_id with the actual filename
230229
file_id = block.pop("file_id", None)

pydatalab/src/pydatalab/apps/xrd/blocks.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ def generate_xrd_plot(self, filenames: list[str | Path] | None = None) -> None:
262262
pattern_df["normalized intensity (staggered)"] += ind
263263
pattern_dfs.append(pattern_df)
264264

265-
self.data["processed_data"] = {}
266-
self.data["processed_data"]["peak_data"] = peak_information
265+
self.data["computed"] = {}
266+
self.data["computed"]["peak_data"] = peak_information
267267

268268
elif filenames is None:
269269
file_info = get_file_info_by_id(self.data["file_id"], update_if_live=True)
@@ -285,11 +285,9 @@ def generate_xrd_plot(self, filenames: list[str | Path] | None = None) -> None:
285285
f"{self.data.get('wavelength', self.defaults['wavelength'])} Å"
286286
)
287287
peak_model = PeakInformation(**peak_data)
288-
if "processed_data" not in self.data:
289-
self.data["processed_data"] = {"peak_data": {}}
290-
self.data["processed_data"]["peak_data"][str(file_info["immutable_id"])] = (
291-
peak_model.dict()
292-
)
288+
if "computed" not in self.data:
289+
self.data["computed"] = {"peak_data": {}}
290+
self.data["computed"]["peak_data"][str(file_info["immutable_id"])] = peak_model.dict()
293291
pattern_dfs = [pattern_df]
294292

295293
else:
@@ -306,9 +304,9 @@ def generate_xrd_plot(self, filenames: list[str | Path] | None = None) -> None:
306304
pattern_dfs.append(pattern_df)
307305

308306
peak_model = PeakInformation(**peak_data)
309-
if "processed_data" not in self.data:
310-
self.data["processed_data"] = {"peak_data": {}}
311-
self.data["processed_data"]["peak_data"][f] = peak_model.dict()
307+
if "computed" not in self.data:
308+
self.data["computed"] = {"peak_data": {}}
309+
self.data["computed"]["peak_data"][f] = peak_model.dict()
312310
pattern_dfs = [pattern_df]
313311

314312
if pattern_dfs:

pydatalab/src/pydatalab/blocks/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def update_from_web(self, data: dict):
328328
)
329329
self.data.update(
330330
self.block_db_model(**data).dict(
331-
exclude={"processed_data", "metadata", "bokeh_plot_data", "b64_encoded_image"},
331+
exclude={"computed", "metadata", "bokeh_plot_data", "b64_encoded_image"},
332332
exclude_unset=True,
333333
)
334334
)

pydatalab/src/pydatalab/models/blocks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class DataBlockResponse(BaseModel):
4747
bokeh_plot_data: dict | None
4848
"""A JSON-encoded string containing the Bokeh plot data, if any."""
4949

50-
processed_data: dict | None = None
51-
"""Any processed data associated with the block, small enough to store and filter directly in the database,
50+
computed: dict | None = None
51+
"""Any processed or computed data associated with the block, small enough to store and filter directly in the database,
5252
i.e., strings or a few hundred numbers not exceeding 16KB in size.
5353
Examples could include peak positions, and widths, but not the full spectrum.
5454
"""

pydatalab/tests/server/test_blocks.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ def test_xrd_block_lifecycle(admin_client, default_sample_dict):
258258

259259
web_block = response.json["new_block_data"]
260260
assert "bokeh_plot_data" in web_block
261-
assert "processed_data" in web_block
261+
assert "computed" in web_block
262262
assert web_block["wavelength"] == 2.0
263-
assert "peak_data" in web_block["processed_data"]
263+
assert "peak_data" in web_block["computed"]
264264
assert "file_id" in web_block
265265
assert web_block["file_id"] == file_id
266266
assert web_block.get("errors") is None
@@ -269,7 +269,7 @@ def test_xrd_block_lifecycle(admin_client, default_sample_dict):
269269
db = block.to_db()
270270
# 'computed' keys should be dropped when loading from web
271271
assert "bokeh_plot_data" not in db
272-
assert "processed_data" not in db
272+
assert "computed" not in db
273273
assert db["wavelength"] == 2.0
274274

275275
# But they should still be in the database
@@ -280,8 +280,8 @@ def test_xrd_block_lifecycle(admin_client, default_sample_dict):
280280
assert response.json["status"] == "success"
281281
assert "blocks_obj" in item_data
282282
block = item_data["blocks_obj"][block_id]
283-
assert "processed_data" in block
284-
assert "peak_data" in block["processed_data"]
283+
assert "computed" in block
284+
assert "peak_data" in block["computed"]
285285
assert block["wavelength"] == 2.0
286286

287287

@@ -461,7 +461,7 @@ def test_create_sample_with_example_files(
461461
assert response.json["new_block_data"]["bokeh_plot_data"] is not None
462462

463463
if block_type == "xrd":
464-
assert response.json["new_block_data"]["processed_data"]["peak_data"] is not None
464+
assert response.json["new_block_data"]["computed"]["peak_data"] is not None
465465

466466
response = admin_client.get(f"/get-item-data/{sample_id}")
467467
assert response.status_code == 200
@@ -472,4 +472,4 @@ def test_create_sample_with_example_files(
472472

473473
if block_type == "xrd":
474474
doc = database.items.find_one({"item_id": sample_id}, projection={"blocks_obj": 1})
475-
assert doc["blocks_obj"][block_id]["processed_data"]["peak_data"] is not None
475+
assert doc["blocks_obj"][block_id]["computed"]["peak_data"] is not None

webapp/src/server_fetch_utils.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,8 @@ export async function updateBlockFromServer(
506506
// - Will strip known "large data" keys, even if not formalised, e.g., bokeh_plot_data.
507507
//
508508
delete block_data.bokeh_plot_data;
509-
delete block_data.processed_data;
509+
delete block_data.b64_encoded_image;
510+
delete block_data.computed;
510511
delete block_data.metadata;
511512

512513
store.commit("setBlockUpdating", block_id);
@@ -581,8 +582,9 @@ export function saveItem(item_id) {
581582
for (const block_id in item_data.blocks_obj) {
582583
const block = item_data.blocks_obj[block_id];
583584
block.bokeh_plot_data = null;
584-
block.processed_data = null;
585+
block.computed = null;
585586
block.metadata = null;
587+
block.b64_encoded_image = null;
586588
}
587589
}
588590

0 commit comments

Comments
 (0)