Skip to content

Commit

Permalink
Merge branch 'dev' into chat_update
Browse files Browse the repository at this point in the history
  • Loading branch information
xinaesthete committed Feb 11, 2025
2 parents fd9bebb + 1af00f2 commit b7e3d4a
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 12 deletions.
6 changes: 5 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
"ms-toolsai.jupyter",
"github.vscode-github-actions",
"eamodio.gitlens"
]
],
"settings": {
"python.analysis.typeCheckingMode": "basic",
"python.defaultInterpreterPath": "/usr/local/bin/python"
}
}
},
"postStartCommand": "git config --global --add safe.directory /app"
Expand Down
25 changes: 25 additions & 0 deletions python/mdvtools/charts/view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import sys

# You may also pick one without version check, of course
if sys.version_info < (3, 11):
from typing_extensions import TypedDict, Required
else:
from typing import TypedDict, Required

from typing import Literal, Any
# from .chart_dicts import BaseChart


class Panel(TypedDict, total=False):
"""This describes a panel in a view."""

layout: Literal["gridstack", "absolute"]
panelWidth: int | float


class View(TypedDict, total=False):
"""This metadata of a view to be added to a project views.json file."""

initialCharts: Required[dict[str, list[Any]]] # todo
dataSources: dict[str, Panel]
links: dict[str, list[Any]] # todo
3 changes: 2 additions & 1 deletion python/mdvtools/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def convert_scanpy_to_mdv(
current_views = None
if not delete_existing:
current_views = mdv.views

else:
current_views = {}
# create datasource 'cells'
cell_table = scanpy_object.obs
cell_table["cell_id"] = cell_table.index
Expand Down
2 changes: 1 addition & 1 deletion python/mdvtools/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def combine_anndata():
# Process and combine the file
new_anndata = sc.read(temp_path)
convert_scanpy_to_mdv(project.dir, new_anndata, delete_existing=False, label=f"{label}_")
new_anndata.write(os.path.join(project.dir, "anndata.h5ad"))
new_anndata.write(os.path.join(project.dir, "anndata.h5ad")) # type: ignore - str output from os.path.join should be reliably PathLike
cleanup_folder(temp_folder)

return jsonify({'status': 'success', 'message': 'File merged successfully'}), 200
Expand Down
8 changes: 8 additions & 0 deletions src/charts/BaseChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ class BaseChart<T> {

//work out width and height based on container
this._setDimensions();
setTimeout(() => {
try {
//some charts weren't properly initialising the color legend, so doing it here may help that to be more consistent.
//there is an implementation of the method here in BaseChart, but we wrap in a try/catch as it assumes other associated methods are also implemented.
//Calling this in a timeout helps ensure that the chart is fully constructed before we try to do this.
this.setColorLegend();
} catch (e) { }
});
// provide some observable mobx state for useOuterContainer()
this.observable = makeAutoObservable({
container: this.__doc__.body,
Expand Down
8 changes: 4 additions & 4 deletions src/charts/charts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ export type DataColumn<T extends DataType> = {
sgtype?: "dense" | "sparse"; //?? any other options?
};
export type LoadedDataColumn<T extends DataType> = DataColumn<T> & Required<Pick<DataColumn<T>, "data">>;
function test(column: LoadedDataColumn<"text">) {
column.data;
column.values; //why does this degrade to 'any'?
}
// function test(column: LoadedDataColumn<"text">) {
// column.data;
// column.values; //why does this degrade to 'any'?
// }
// export type DataStore = {
// size: number;
// filterSize: number;
Expand Down
4 changes: 2 additions & 2 deletions src/charts/dialogs/ColumnPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export const ColumnPreview: React.FC<ColumnPreviewProps> = ({
</thead>
<tbody className="bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700">
{filteredColumns.length > 0 ? (
filteredColumns.map((column, index) => (
<tr key={index}>
filteredColumns.map((column) => (
<tr key={column.name}>
<td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dark:text-gray-100 select-text">
{column.name}
</td>
Expand Down
1 change: 1 addition & 0 deletions src/charts/dialogs/TiffMetadataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const TiffMetadataTable: React.FC<TiffMetadataTableProps> = ({ metadata }
<tbody className="bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700">
{filteredMetadata.length > 0 ? (
filteredMetadata.map((item, index) => (
// biome-ignore lint/suspicious/noArrayIndexKey: not sure if there's an appropriate key to use here - may need to add one.
<tr key={index}>
<td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dark:text-gray-100 select-text w-1/4">
{item.element || 'N/A'}
Expand Down
3 changes: 2 additions & 1 deletion src/charts/dialogs/utils/h5Processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -692,5 +692,6 @@ const processH5File = async (
}
};

export { NonAnnDataError, CompressionError, H5Metadata, MatrixValue, DatasetValue, ProcessOptions, H5DataType, TypedArray };
export { NonAnnDataError, CompressionError };
export type { H5Metadata, MatrixValue, DatasetValue, ProcessOptions, H5DataType, TypedArray };
export default processH5File;
1 change: 1 addition & 0 deletions src/react/components/DebugJsonDialogComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export default function ({ json, header }: { json: any; header?: string }) {
fontSize: '0.875rem',
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace'
}}
collapsed={1}
/>
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion src/react/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ export function useFilteredIndices() {
return;
}
}
setFilteredIndices(indices as Uint32Array<ArrayBuffer>);
//@ts-ignore ! there seems to be a discrepancy here after ts upgrade???
setFilteredIndices(indices);
});
// should I have a cleanup function to cancel the promise if it's not resolved
// by the time the effect is triggered again?
Expand Down
2 changes: 1 addition & 1 deletion src/react/screen_state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type BaseChart from "@/charts/BaseChart";
import type { BaseDialog } from "@/utilities/Dialog";
import { observer } from "mobx-react-lite";
import { createContext, useContext, useEffect, useState } from "react";
import { type createMdvPortal } from './react_utils';
import type { createMdvPortal } from './react_utils';
/** All charts and dialogs have this as an `observable` property that can be passed to
* {@link createMdvPortal} to allow access to the container they should render things like
* which allows Mobx Observer components to {@link useOuterContainer} for access to the container they should render things like
Expand Down

0 comments on commit b7e3d4a

Please sign in to comment.