Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions js/global_variables/meta_gene.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ export const set_meta_gene = async (
meta_gene_url = `${base_url}/meta_gene_${seg_version}.parquet`;
}

console.log('meta_gene_url', meta_gene_url);
console.log('options.fetch', options.fetch);

const meta_gene_table = await get_arrow_table(
meta_gene_url,
options.fetch,
aws
);

console.log('meta_gene_table', meta_gene_table);

const gene_names = meta_gene_table.getChild('__index_level_0__').toArray();
const gene_mean = meta_gene_table.getChild('mean').toArray();
const gene_std = meta_gene_table.getChild('std').toArray();
Expand Down
36 changes: 30 additions & 6 deletions js/image_tile/get_image_dimensions.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
export const get_image_dimensions = async (
base_url,
image_name,
options,
aws
options = {}, // Safe default
aws = null // Safe default
) => {
const dzi_url = `${base_url}/pyramid_images/${image_name}.dzi`;
console.log('🔍 dzi_url:', dzi_url);

const response =
aws !== null
? await aws.fetch(dzi_url)
: await fetch(dzi_url, options.fetch);
let fetchFn;
let fetchOptions;

// Handle AWS fetch case
if (aws && typeof aws.fetch === 'function') {
fetchFn = aws.fetch;
fetchOptions = undefined; // aws.fetch usually includes its own signing logic
} else {
// Use custom fetch if provided, else fall back to global fetch
fetchFn = typeof options.fetch === 'function' ? options.fetch : fetch;
fetchOptions = options.requestOptions ?? {}; // Allow passing requestOptions
}

let response;
try {
response = await fetchFn(dzi_url, fetchOptions);
if (!response.ok) {
throw new Error(`HTTP ${response.status} - ${response.statusText}`);
}
} catch (error) {
console.error('❌ Fetch failed:', {
url: dzi_url,
error: error.message,
});
throw error;
}

const xmlText = await response.text();
const dziXML = new DOMParser().parseFromString(xmlText, 'text/xml');
Expand All @@ -26,5 +49,6 @@ export const get_image_dimensions = async (
),
};

console.log('📐 Parsed image dimensions:', dimensions);
return dimensions;
};
5 changes: 5 additions & 0 deletions js/read_parquet/get_arrow_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import { handleAsyncError } from '../temp_utils/errorHandler';
import { arrayBufferToArrowTable } from './arrayBufferToArrowTable';

export const get_arrow_table = async (url, fetch_options, aws) => {
console.log('start get_arrow_table func');
try {
console.log('start response');
console.log('url', url);

const response =
aws !== null ? await aws.fetch(url) : await fetch(url, fetch_options);
console.log('after response');

const arrayBuffer = await response.arrayBuffer();
const arrowTable = arrayBufferToArrowTable(arrayBuffer);
Expand Down
Loading
Loading