Skip to content

Commit

Permalink
Merge pull request #45 from code-kern-ai/release-v-1-17-0
Browse files Browse the repository at this point in the history
v1.17.0
  • Loading branch information
JWittmeyer authored Oct 23, 2024
2 parents e53e2df + 7e53045 commit 18ee0f6
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export default function HeuristicsHeader(props: HeuristicsHeaderProps) {
const [currentWeakSupervisionRun, setCurrentWeakSupervisionRun] = useState(null);
const [loadingIconWS, setLoadingIconWS] = useState(false);


useEffect(() => {
if (!heuristics) return;
setAreHeuristicsSelected(checkSelectedHeuristics(heuristics, false));
Expand Down Expand Up @@ -201,7 +200,8 @@ export default function HeuristicsHeader(props: HeuristicsHeaderProps) {
{areValidHeuristicsSelected ? (
<Tooltip content={TOOLTIPS_DICT.HEURISTICS.WEAK_SUPERVISION} color="invert" placement="top">
<button onClick={startWeakSupervision}
className="bg-indigo-700 flex items-center text-white text-xs font-semibold mr-3 px-4 py-2 rounded-md border hover:bg-indigo-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
disabled={props.tokenizationProgress < 1}
className="bg-indigo-700 flex items-center text-white text-xs font-semibold mr-3 px-4 py-2 rounded-md border hover:bg-indigo-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed">
Weak supervision
</button>
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import { useWebsocket } from "@/submodules/react-components/hooks/web-socket/use
import { getAllComments } from "@/src/services/base/comment";
import { getAttributes } from "@/src/services/base/attribute";
import { getInformationSourcesOverviewData } from "@/src/services/base/heuristic";
import { getLabelingTasksByProjectId } from "@/src/services/base/project";
import { getLabelingTasksByProjectId, getProjectTokenization } from "@/src/services/base/project";
import { getEmbeddings } from "@/src/services/base/embedding";
import { Application, CurrentPage } from "@/submodules/react-components/hooks/web-socket/constants";
import { timer } from "rxjs";

export function HeuristicsOverview() {
const dispatch = useDispatch();
Expand All @@ -33,12 +34,15 @@ export function HeuristicsOverview() {
const attributes = useSelector(selectUsableNonTextAttributes);
const allUsers = useSelector(selectAllUsers);
const [filteredList, setFilteredList] = useState([]);
const [tokenizationProgress, setTokenizationProgress] = useState(null);


useEffect(() => {
if (!projectId || !embeddings || !attributes) return;
refetchLabelingTasksAndProcess();
refetchHeuristicsAndProcess();
refetchEmbeddingsAndProcess();
checkProjectTokenization();
if (attributes.length == 0) {
getAttributes(projectId, ['ALL'], (res) => {
dispatch(setAllAttributes(res.data['attributesByProjectId']));
Expand Down Expand Up @@ -91,6 +95,12 @@ export function HeuristicsOverview() {
});
}

function checkProjectTokenization() {
getProjectTokenization(projectId, (res) => {
setTokenizationProgress(res.data['projectTokenization']?.progress);
});
}

const handleWebsocketNotification = useCallback((msgParts: string[]) => {
if (['labeling_task_updated', 'labeling_task_created'].includes(msgParts[1])) {
refetchLabelingTasksAndProcess();
Expand All @@ -102,14 +112,25 @@ export function HeuristicsOverview() {
} else if (msgParts[1] == 'embedding_deleted' || (msgParts[1] == 'embedding' && msgParts[3] == 'state')) {
refetchEmbeddingsAndProcess();
}

if (msgParts[1] == 'tokenization') {
if (msgParts[3] == 'progress') {
setTokenizationProgress(Number(msgParts[4]));
} else if (msgParts[3] == 'state') {
if (msgParts[4] == 'IN_PROGRESS') setTokenizationProgress(0);
else if (msgParts[4] == 'FINISHED') {
timer(5000).subscribe(() => checkProjectTokenization());
}
}
}
}, [projectId]);

const orgId = useSelector(selectOrganizationId);
useWebsocket(orgId, Application.REFINERY, CurrentPage.HEURISTICS, handleWebsocketNotification, projectId);

return (projectId && <div className="p-4 bg-gray-100 h-full flex-1 flex flex-col">
<div className="w-full h-full -mr-4">
<HeuristicsHeader refetch={refetchHeuristicsAndProcess}
<HeuristicsHeader refetch={refetchHeuristicsAndProcess} tokenizationProgress={tokenizationProgress}
filterList={(labelingTask: LabelingTask) => setFilteredList(labelingTask != null ? heuristics.filter((heuristic) => heuristic.labelingTaskId === labelingTask.id) : heuristics)} />

{heuristics && heuristics.length == 0 ? (
Expand Down
30 changes: 1 addition & 29 deletions src/components/shared/bricks-integrator/PageSearch.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { selectBricksIntegrator, setBricksIntegrator } from "@/src/reduxStore/states/general";
import { IntegratorPage, PageSearchProps } from "@/src/types/shared/bricks-integrator";
import { IconAlertCircle, IconBrandGithub, IconChevronsDown, IconLoader, IconSearch } from "@tabler/icons-react";
import { IconAlertCircle, IconBrandGithub, IconChevronsDown, IconSearch } from "@tabler/icons-react";
import { useDispatch, useSelector } from "react-redux"
import LoadingIcon from "../loading/LoadingIcon";
import { useState } from "react";
import style from '@/src/styles/shared/bricks-integrator.module.css';
import { jsonCopy } from "@/submodules/javascript-functions/general";
import * as TablerIcons from '@tabler/icons-react';
import { getIconName } from "@/src/util/shared/bricks-integrator-helper";

export default function PageSearch(props: PageSearchProps) {
const dispatch = useDispatch();

Expand Down Expand Up @@ -72,7 +69,6 @@ export default function PageSearch(props: PageSearchProps) {
{config.search.results.map((result: any, i: number) => (
<li key={result.id} onClick={() => props.selectSearchResult(result.id)}
className={`text-left group flex flex-row items-center cursor-pointer select-none rounded-xl p-3 hover:bg-gray-100 relative ${!result.searchVisible || !result.groupVisible ? 'hidden' : ''}`} id="option-1" role="option">
<SVGIcon icon={result.attributes.tablerIcon} size={24} strokeWidth={2} color={"black"} />
<div className="ml-2 flex-auto">
<p className="text-sm font-semibold text-gray-700">{result.attributes.name}</p>
<p className="text-sm text-gray-500">{result.attributes.description}</p>
Expand All @@ -83,27 +79,3 @@ export default function PageSearch(props: PageSearchProps) {
</div>}
</>)
}

function SVGIcon({ icon, size, strokeWidth, color }) {
const Icon = TablerIcons['Icon' + icon];
if (Icon) {
return (
<Icon
size={size}
strokeWidth={strokeWidth}
color={color}
/>
)
} else {
const Icon = TablerIcons['Icon' + getIconName(icon)];
if (Icon) {
return (
<Icon
size={size}
strokeWidth={strokeWidth}
color={color}
/>
)
}
}
}
4 changes: 2 additions & 2 deletions src/components/shared/export/ExportRecordsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ export default function ExportRecordsModal(props: ExportProps) {
let keyToSend = key;
if (!keyToSend) keyToSend = null;
prepareRecordExport(projectId, { exportOptions: jsonString, key: keyToSend }, (res) => {
if (res.data['prepareRecordExport'] != "") {
if (!res.data) {
ExportHelper.error.push("Something went wrong in the backend:");
ExportHelper.error.push(res.data['prepareRecordExport']);
ExportHelper.error.push(res.error);
setPrepareErrors(ExportHelper.error);
}
setDownloadState(DownloadState.DOWNLOAD);
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export default function Sidebar() {
<Tooltip placement="right" trigger="hover" color="invert" content={TOOLTIPS_DICT.SIDEBAR.VERSION_OVERVIEW}>
<div onClick={requestVersionOverview} id="refineryVersion"
className="z-50 tooltip tooltip-right cursor-pointer select-none text-white flex items-center mr-1">
v1.16.0
v1.17.0
{hasUpdates && <Tooltip placement="right" trigger="hover" color="invert" content={TOOLTIPS_DICT.SIDEBAR.NEWER_VERSION_AVAILABLE} >
<IconAlertCircle className="h-5 w-5 text-yellow-700" />
</Tooltip>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export type Color = {
export type HeuristicsHeaderProps = {
filterList: (labelingTask: LabelingTask) => void;
refetch: () => void;
tokenizationProgress: number;
}

export type CurrentWeakSupervision = {
Expand Down

0 comments on commit 18ee0f6

Please sign in to comment.