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

Merge release/v1.1.0 to develop #5126

Merged
merged 5 commits into from
Nov 16, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const PathEntryCounts = ({ modal, path }: PathEntryCountsProps) => {
[modal, path]
);
const hasFilters = useRecoilValue(fos.fieldIsFiltered({ modal, path }));
const queryPerformance = useRecoilValue(fos.queryPerformance);
const queryPerformance = useRecoilValue(fos.queryPerformance) && !modal;
const shown = useRecoilValue(showEntryCounts({ modal, path }));

// empty path means we are showing grid sample count which is always allowed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Lightning = ({
};

const IconWrapper = ({ modal, path }: { modal: boolean; path: string }) => {
const disabled = useRecoilValue(fos.isDisabledFilterPath(path));
const disabled = useRecoilValue(fos.isDisabledFilterPath(path)) && !modal;
const expandedPath = useRecoilValue(fos.expandPath(path));
const frameFilteringDisabled =
useRecoilValue(fos.isDisabledFrameFilterPath(path)) && !modal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const useTitleTemplate = ({
path: string;
}) => {
return function useTitleTemplate({ hoverHandlers, hoverTarget, container }) {
const disabled = useRecoilValue(fos.isDisabledFilterPath(path));
const enabled = !useRecoilValue(fos.isDisabledCheckboxPath(path));
const isFilterMode = useRecoilValue(fos.isSidebarFilterMode);
const expandedPath = useRecoilValue(fos.expandPath(path));

Expand All @@ -97,10 +97,10 @@ const useTitleTemplate = ({
<Hidden path={path} />
</Suspense>
)}
{!disabled && isFilterMode && (
{enabled && isFilterMode && (
<PathEntryCounts key="count" modal={modal} path={expandedPath} />
)}
{!disabled && <Icon modal={modal} path={path} />}
{enabled && <Icon modal={modal} path={path} />}
</NameAndCountContainer>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const DEFAULT_MAX_INLINE = 1;
export default function ActionsMenu(props: ActionsPropsType) {
const { actions, maxInline = DEFAULT_MAX_INLINE, size } = props;

if (actions.length === maxInline) {
if (actions.length <= maxInline) {
return (
<Stack direction="row" spacing={0.5} justifyContent="flex-end">
{actions.map((action) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default function TableView(props: ViewPropsType) {
selected_color,
size = "small",
variant = "filled",
max_inline_actions = 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add TypeScript type definition for max_inline_actions

The new prop should be properly typed in the view schema type definition to maintain type safety.

Add the type definition to the view schema interface:

interface ViewSchema {
  // ... existing props
  max_inline_actions?: number;
}

} = view;
const { rows, selectedCells, selectedRows, selectedColumns } =
getTableData(props);
Expand Down Expand Up @@ -198,6 +199,7 @@ export default function TableView(props: ViewPropsType) {
<ActionsMenu
actions={getRowActions(rowIndex)}
size={size}
maxInline={max_inline_actions}
/>
)}
</TableCell>
Expand Down
21 changes: 16 additions & 5 deletions fiftyone/server/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,15 @@ def _first(
if sort:
pipeline.append({"$match": {path: {"$ne": None}}})

pipeline.append({"$sort": {path: sort}})

return pipeline + [
{"$group": {"_id": {"$min" if sort == 1 else "$max": f"${path}"}}}
{
"$group": {
"_id": None,
"value": {"$min" if sort == 1 else "$max": f"${path}"},
}
}
]


Expand Down Expand Up @@ -458,7 +465,11 @@ def _match_arrays(dataset: fo.Dataset, path: str, is_frame_field: bool):

def _parse_result(data):
if data and data[0]:
return data[0].get("_id", None)
value = data[0]
if value.get("value", None) is not None:
return value["value"]

return value.get("_id", None)

return None

Expand All @@ -468,13 +479,13 @@ def _unwind(dataset: fo.Dataset, path: str, is_frame_field: bool):
path = None
pipeline = []

prefix = ""
if is_frame_field:
path = keys[0]
keys = keys[1:]
prefix = "frames."

for key in keys:
path = ".".join([path, key]) if path else key
field = dataset.get_field(path)
field = dataset.get_field(f"{prefix}{path}")
while isinstance(field, fof.ListField):
pipeline.append({"$unwind": f"${path}"})
field = field.field
Expand Down
14 changes: 7 additions & 7 deletions tests/unittests/lightning_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,13 @@ async def test_floats(self, dataset: fo.Dataset):
dataset,
dict(
float=-1.0,
float_list=[-1.0],
float_list=[0.0, -1.0],
inf=-1.0,
inf_list=[-1.0],
inf_list=[0.0, -1.0],
nan=-1.0,
nan_list=[-1.0],
nan_list=[0.0, -1.0],
ninf=-1.0,
ninf_list=[-1.0],
ninf_list=[0.0, -1.0],
),
dict(
float=0.0,
Expand All @@ -508,13 +508,13 @@ async def test_floats(self, dataset: fo.Dataset):
),
dict(
float=1.0,
float_list=[1.0],
float_list=[0.0, 1.0],
inf=1.0,
inf_list=[1.0],
nan=1.0,
nan_list=[1.0],
nan_list=[0.0, 1.0],
ninf=1.0,
ninf_list=[1.0],
ninf_list=[0.0, 1.0],
),
)

Expand Down
Loading