Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompute the rank of a data node in all the scenario config DAGs. #2072

Merged
merged 21 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0c6205d
Precompute the rank of a data node in all the scenario config DAGs.
jrobinAV Oct 16, 2024
e20bbf5
Update taipy/core/config/scenario_config.py
jrobinAV Oct 16, 2024
2a31b4b
linter
jrobinAV Oct 16, 2024
ab593ba
Fredd's feedback
jrobinAV Oct 17, 2024
e6285e1
fix wrong test
jrobinAV Oct 17, 2024
5d4aa27
sort/filter Datanodes by rank
Oct 17, 2024
dbd2949
@trgiangdo comments
Oct 19, 2024
dd28e51
Merge branch 'develop' into feature/#2071-rank-datanodes-in-selector
FredLL-Avaiga Oct 24, 2024
39276e5
Merge branch 'develop' into feature/#2071-rank-datanodes-in-selector
FredLL-Avaiga Oct 30, 2024
a6317fe
Merge branch 'develop' into feature/#2071-rank-datanodes-in-selector
FredLL-Avaiga Nov 14, 2024
3ba5c9c
Open _get_rank(scenario_config_id) API in DataNode class
jrobinAV Nov 27, 2024
f55f699
Merge branch 'develop' into feature/#2071-rank-datanodes-in-selector
jrobinAV Nov 27, 2024
4d43793
Merge branch 'develop' into feature/#2071-rank-datanodes-in-selector
jrobinAV Nov 27, 2024
f2c12f2
- tree by ownership
Nov 29, 2024
84d2fec
lint
Nov 29, 2024
4d18c1e
JR doc
FredLL-Avaiga Nov 29, 2024
b05931f
Merge branch 'develop' into feature/#2071-rank-datanodes-in-selector
FredLL-Avaiga Nov 29, 2024
ea7a7e2
Merge branch 'develop' into feature/#2071-rank-datanodes-in-selector
jrobinAV Dec 3, 2024
7d2ab36
Code factorization and code formatting after merge
jrobinAV Dec 3, 2024
0d0f0db
Merge branch 'develop' into feature/#2071-rank-datanodes-in-selector
jrobinAV Dec 9, 2024
59afe69
Fix linter
jrobinAV Dec 9, 2024
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
12 changes: 10 additions & 2 deletions frontend/taipy-gui/packaging/taipy-gui.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,20 @@ export interface TableProps extends TaipyPaginatedTableProps {
}
export declare const Table: (props: TableProps) => JSX.Element;

export interface FilterColumnDesc extends ColumnDesc {
params?: number[];
}
export interface FilterDesc {
col: string;
action: string;
value: string | number | boolean | Date;
type: string;
params?: number[];
}
export interface TableFilterProps {
fieldHeader?: string;
fieldHeaderTooltip?: string;
columns: Record<string, ColumnDesc>;
columns: Record<string, FilterColumnDesc>;
colsOrder?: Array<string>;
onValidate: (data: Array<FilterDesc>) => void;
appliedFilters?: Array<FilterDesc>;
Expand All @@ -144,15 +148,19 @@ export interface TableFilterProps {
}
export declare const TableFilter: (props: TableFilterProps) => JSX.Element;

export interface SortColumnDesc extends ColumnDesc {
params?: number[];
}
export interface SortDesc {
col: string;
order: boolean;
params?: number[];
}

export interface TableSortProps {
fieldHeader?: string;
fieldHeaderTooltip?: string;
columns: Record<string, ColumnDesc>;
columns: Record<string, SortColumnDesc>;
colsOrder?: Array<string>;
onValidate: (data: Array<SortDesc>) => void;
appliedSorts?: Array<SortDesc>;
Expand Down
27 changes: 18 additions & 9 deletions frontend/taipy-gui/src/components/Taipy/TableFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ import { getDateTime, getTypeFromDf } from "../../utils";
import { getSuffixedClassNames } from "./utils";
import { MatchCase } from "../icons/MatchCase";

export interface FilterColumnDesc extends ColumnDesc {
params?: number[];
}

interface TableFilterProps {
fieldHeader?: string;
fieldHeaderTooltip?: string;
columns: Record<string, ColumnDesc>;
columns: Record<string, FilterColumnDesc>;
colsOrder?: Array<string>;
onValidate: (data: Array<FilterDesc>) => void;
appliedFilters?: Array<FilterDesc>;
Expand All @@ -51,7 +55,7 @@ interface FilterRowProps {
fieldHeader?: string;
fieldHeaderTooltip?: string;
filter?: FilterDesc;
columns: Record<string, ColumnDesc>;
columns: Record<string, FilterColumnDesc>;
colsOrder: Array<string>;
setFilter: (idx: number, fd: FilterDesc, remove?: boolean) => void;
}
Expand Down Expand Up @@ -98,7 +102,7 @@ const getActionsByType = (colType?: string) =>
(colType === "any" ? { ...actionsByType.string, ...actionsByType.number } : actionsByType.string);

const getFilterDesc = (
columns: Record<string, ColumnDesc>,
columns: Record<string, FilterColumnDesc>,
colId?: string,
act?: string,
val?: string,
Expand All @@ -118,13 +122,14 @@ const getFilterDesc = (
? colType === "number"
? parseFloat(val)
: colType === "boolean"
? val === "1"
: colType === "date"
? getDateTime(val)
: val
? val === "1"
: colType === "date"
? getDateTime(val)
: val
: val,
type: colType,
matchCase: !!matchCase,
params: columns[colId].params,
} as FilterDesc;
} catch (e) {
console.info("Could not parse value ", val, e);
Expand Down Expand Up @@ -231,7 +236,11 @@ const FilterRow = (props: FilterRowProps) => {
<FormControl margin="dense">
<InputLabel>{fieldHeader}</InputLabel>
<Tooltip title={fieldHeaderTooltip} placement="top">
<Select value={colId || ""} onChange={onColSelect} input={<OutlinedInput label={fieldHeader} />}>
<Select
value={colId || ""}
onChange={onColSelect}
input={<OutlinedInput label={fieldHeader} />}
>
{colsOrder.map((col) =>
columns[col].filter ? (
<MenuItem key={col} value={col}>
Expand Down Expand Up @@ -352,7 +361,7 @@ const TableFilter = (props: TableFilterProps) => {
onValidate,
appliedFilters,
className = "",
filteredCount
filteredCount,
} = props;

const [showFilter, setShowFilter] = useState(false);
Expand Down
24 changes: 17 additions & 7 deletions frontend/taipy-gui/src/components/Taipy/TableSort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@ import { getSuffixedClassNames } from "./utils";
export interface SortDesc {
col: string;
order: boolean;
params?: number[];
}

export interface SortColumnDesc extends ColumnDesc {
params?: number[];
}

interface TableSortProps {
fieldHeader?: string;
fieldHeaderTooltip?: string;
columns: Record<string, ColumnDesc>;
columns: Record<string, SortColumnDesc>;
colsOrder?: Array<string>;
onValidate: (data: Array<SortDesc>) => void;
appliedSorts?: Array<SortDesc>;
Expand Down Expand Up @@ -73,12 +78,13 @@ const badgeSx = {
};
const orderCaptionSx = { ml: 1 };

const getSortDesc = (columns: Record<string, ColumnDesc>, colId?: string, asc?: boolean) =>
const getSortDesc = (columns: Record<string, SortColumnDesc>, colId?: string, asc?: boolean) =>
colId && asc !== undefined
? ({
col: columns[colId].dfid,
order: !!asc,
} as SortDesc)
col: columns[colId].dfid,
order: !!asc,
params: columns[colId].params,
} as SortDesc)
: undefined;

const SortRow = (props: SortRowProps) => {
Expand Down Expand Up @@ -138,7 +144,11 @@ const SortRow = (props: SortRowProps) => {
<FormControl margin="dense">
<InputLabel>Column</InputLabel>
<Tooltip title={fieldHeaderTooltip} placement="top">
<Select value={colId || ""} onChange={onColSelect} input={<OutlinedInput label={fieldHeader} />}>
<Select
value={colId || ""}
onChange={onColSelect}
input={<OutlinedInput label={fieldHeader} />}
>
{cols.map((col) => (
<MenuItem key={col} value={col}>
{columns[col].title || columns[col].dfid}
Expand Down Expand Up @@ -183,7 +193,7 @@ const TableSort = (props: TableSortProps) => {
columns,
onValidate,
appliedSorts,
className = ""
className = "",
} = props;

const [showSort, setShowSort] = useState(false);
Expand Down
1 change: 1 addition & 0 deletions frontend/taipy-gui/src/components/Taipy/tableUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export interface FilterDesc {
value: string | number | boolean | Date;
type: string;
matchcase?: boolean;
params?: number[];
}

export const defaultColumns = {} as Record<string, ColumnDesc>;
Expand Down
8 changes: 5 additions & 3 deletions frontend/taipy-gui/src/extensions/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import FileSelector from "../components/Taipy/FileSelector";
import Login from "../components/Taipy/Login";
import Router from "../components/Router";
import Table from "../components/Taipy/Table";
import TableFilter from "../components/Taipy/TableFilter";
import TableFilter, { FilterColumnDesc } from "../components/Taipy/TableFilter";
import { FilterDesc } from "../components/Taipy/tableUtils";
import TableSort, { SortDesc } from "../components/Taipy/TableSort";
import {getComponentClassName} from "../components/Taipy/TaipyStyle";
import TableSort, { SortColumnDesc, SortDesc } from "../components/Taipy/TableSort";
import { getComponentClassName } from "../components/Taipy/TaipyStyle";
import Metric from "../components/Taipy/Metric";
import { useLovListMemo, LoV, LoVElt } from "../components/Taipy/lovUtils";
import { LovItem } from "../utils/lov";
Expand Down Expand Up @@ -72,12 +72,14 @@ export {

export type {
ColumnDesc,
FilterColumnDesc,
FilterDesc,
LoV,
LoVElt,
LovItem,
RowType,
RowValue,
SortColumnDesc,
SortDesc,
TaipyStore as Store,
TaipyState as State,
Expand Down
94 changes: 50 additions & 44 deletions frontend/taipy/src/CoreSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,41 @@ import { SimpleTreeView } from "@mui/x-tree-view/SimpleTreeView";
import { TreeItem } from "@mui/x-tree-view/TreeItem";

import {
useDispatch,
useModule,
getUpdateVar,
createRequestUpdateAction,
createSendUpdateAction,
getSuffixedClassNames,
getUpdateVar,
useClassNames,
useDispatch,
useDispatchRequestUpdateOnFirstRender,
createRequestUpdateAction,
useModule,
useDynamicProperty,
ColumnDesc,
FilterColumnDesc,
FilterDesc,
TableFilter,
SortColumnDesc,
SortDesc,
TableFilter,
TableSort,
useClassNames,
getSuffixedClassNames,
} from "taipy-gui";

import { Cycles, Cycle, DataNodes, NodeType, Scenarios, Scenario, DataNode, Sequence, Sequences } from "./utils/types";
import { Cycle, Cycles, DataNode, DataNodes, NodeType, Scenario, Scenarios, Sequence, Sequences } from "./utils/types";
import {
Cycle as CycleIcon,
Datanode as DatanodeIcon,
Sequence as SequenceIcon,
Scenario as ScenarioIcon,
Sequence as SequenceIcon,
} from "./icons";
import {
getUpdateVarNames,
iconLabelSx,
tinyIconButtonSx,
tinySelPinIconButtonSx,
BadgePos,
BadgeSx,
BaseTreeViewSx,
CoreProps,
FlagSx,
ParentItemSx,
getUpdateVarNames,
iconLabelSx,
tinyIconButtonSx,
tinySelPinIconButtonSx,
} from "./utils";

export interface EditProps {
Expand Down Expand Up @@ -282,7 +283,7 @@ const filterTree = (entities: Entities, search: string, leafType: NodeType, coun
count.nb++;
return emptyEntity;
})
.filter((i) => (i as unknown[]).length !== 0);
.filter((item) => (item as unknown[]).length > 3 && (item[3] == leafType || !item[2] || item[2].length > 0));
if (top && count.nb == 0) {
return entities;
}
Expand Down Expand Up @@ -502,21 +503,22 @@ const CoreSelector = (props: CoreSelectorProps) => {
const colFilters = useMemo(() => {
try {
const res = props.filter
? (JSON.parse(props.filter) as Array<[string, string, string, string[]]>)
? (JSON.parse(props.filter) as Array<[string, string, string, string[], number[]]>)
: undefined;
return Array.isArray(res)
? res.reduce((pv, [name, id, coltype, lov], idx) => {
? res.reduce((pv, [name, id, colType, lov, params], idx) => {
pv[name] = {
dfid: id,
title: name,
type: coltype,
type: colType,
index: idx,
filter: true,
lov: lov,
lov,
freeLov: !!lov,
params
};
return pv;
}, {} as Record<string, ColumnDesc>)
}, {} as Record<string, FilterColumnDesc>)
: undefined;
} catch {
return undefined;
Expand All @@ -531,18 +533,20 @@ const CoreSelector = (props: CoreSelectorProps) => {
if (old.length != filters.length || JSON.stringify(old) != jsonFilters) {
localStoreSet(jsonFilters, id, lovPropertyName, "filter");
const filterVar = getUpdateVar(updateCoreVars, "filter");
const lovVar = getUpdateVarNames(updateVars, lovPropertyName);
Promise.resolve().then(() =>
dispatch(
createRequestUpdateAction(
id,
module,
lovVar,
true,
filterVar ? { [filterVar]: filters } : undefined
if (filterVar) {
const lovVar = getUpdateVarNames(updateVars, lovPropertyName);
Promise.resolve().then(() =>
dispatch(
createRequestUpdateAction(
id,
module,
lovVar,
true,
{ [filterVar]: filters }
)
)
)
);
);
}
return filters;
}
return old;
Expand All @@ -554,12 +558,12 @@ const CoreSelector = (props: CoreSelectorProps) => {
// sort
const colSorts = useMemo(() => {
try {
const res = props.sort ? (JSON.parse(props.sort) as Array<[string, string]>) : undefined;
const res = props.sort ? (JSON.parse(props.sort) as Array<[string, string, number[]]>) : undefined;
return Array.isArray(res)
? res.reduce((pv, [name, id], idx) => {
pv[name] = { dfid: id, title: name, type: "str", index: idx };
? res.reduce((pv, [name, id, params], idx) => {
pv[name] = { dfid: id, title: name, type: "str", index: idx, params };
return pv;
}, {} as Record<string, ColumnDesc>)
}, {} as Record<string, SortColumnDesc>)
: undefined;
} catch {
return undefined;
Expand All @@ -574,15 +578,17 @@ const CoreSelector = (props: CoreSelectorProps) => {
if (old.length != sorts.length || JSON.stringify(old) != jsonSorts) {
localStoreSet(jsonSorts, id, lovPropertyName, "sort");
const sortVar = getUpdateVar(updateCoreVars, "sort");
dispatch(
createRequestUpdateAction(
id,
module,
getUpdateVarNames(updateVars, lovPropertyName),
true,
sortVar ? { [sortVar]: sorts } : undefined
)
);
if (sortVar) {
dispatch(
createRequestUpdateAction(
id,
module,
getUpdateVarNames(updateVars, lovPropertyName),
true,
{ [sortVar]: sorts }
)
);
}
return sorts;
}
return old;
Expand Down
1 change: 1 addition & 0 deletions taipy/core/config/data_node_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ def __init__(
suggest="exposed_type='pandas'",
)
properties["exposed_type"] = DataNodeConfig._EXPOSED_TYPE_PANDAS
self._ranks: Dict[str, int] = {}

def __copy__(self):
return DataNodeConfig(self.id, self._storage_type, self._scope, self._validity_period, **copy(self._properties))
Expand Down
Loading
Loading