From 7f810217352126f30c7d6d8386951e337ef07088 Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Tue, 8 Oct 2024 17:58:46 +0100 Subject: [PATCH] ok actually it wasn't working and still isn't --- .../src/webworkers/localBackendWorker.js | 6 ++++-- taxonium_data_handling/importing.js | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/taxonium_component/src/webworkers/localBackendWorker.js b/taxonium_component/src/webworkers/localBackendWorker.js index f9682c2d..f0d86a59 100644 --- a/taxonium_component/src/webworkers/localBackendWorker.js +++ b/taxonium_component/src/webworkers/localBackendWorker.js @@ -7,7 +7,8 @@ import { import { processNewickAndMetadata } from "../utils/processNewick.js"; import { processNextstrain } from "../utils/processNextstrain.js"; import { ReadableWebToNodeStream } from "readable-web-to-node-stream"; -import StreamValues from 'stream-json/streamers/StreamValues'; +import {parser } from "stream-json"; +import {streamValues } from "stream-json/streamers/StreamValues"; console.log("worker starting"); postMessage({ data: "Worker starting" }); @@ -213,8 +214,9 @@ onmessage = async (event) => { data.data, sendStatusMessage, ReadableWebToNodeStream, - StreamValues + parser,streamValues ); + console.log("processedUploadedData created"); } else if ( data.type === "upload" && diff --git a/taxonium_data_handling/importing.js b/taxonium_data_handling/importing.js index 04c0dfbc..6ab33881 100644 --- a/taxonium_data_handling/importing.js +++ b/taxonium_data_handling/importing.js @@ -65,13 +65,13 @@ function reduceMaxOrMin(array, accessFunction, maxOrMin) { } } -export const setUpStream = (the_stream, data, sendStatusMessage, StreamValues) => { +export const setUpStream = (the_stream, data, sendStatusMessage, parser, streamValues) => { const splitter = new StreamSplitter(); // Custom header parser using json-stream const headerParser = stream.pipeline( - StreamValues.parser({ jsonStreaming: true }), - StreamValues.streamValues(), + parser({ jsonStreaming: true }), + streamValues(), new stream.Writable({ objectMode: true, write(chunk, encoding, callback) { @@ -162,7 +162,7 @@ export const setUpStream = (the_stream, data, sendStatusMessage, StreamValues) = export const processJsonl = async ( jsonl, sendStatusMessage, - ReadableWebToNodeStream, StreamValues + ReadableWebToNodeStream, parser, streamValues ) => { console.log( "Worker processJsonl" //, jsonl @@ -178,7 +178,7 @@ export const processJsonl = async ( the_stream = new stream.PassThrough(); } let new_data = {}; - setUpStream(the_stream, new_data, sendStatusMessage,StreamValues); + setUpStream(the_stream, new_data, sendStatusMessage,parser, streamValues); if (status === "loaded") { const dataAsArrayBuffer = data;