Skip to content

Commit

Permalink
Merge pull request #1013 from AI4Bharat/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ishvindersethi22 authored Apr 27, 2024
2 parents 22f5dcc + fbf52c0 commit fdca950
Show file tree
Hide file tree
Showing 9 changed files with 246 additions and 22 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/build-release-develop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ env:
CI: false
NODE_OPTIONS: "--max_old_space_size=4096"
REACT_APP_APIGW_BASE_URL: ${{ secrets.REACT_APP_APIGW_BASE_URL_DEVELOP }}
AZURE_CREDS: ${{ secrets.SHOONYA_AZURE_CREDS }}
AZURE_STORAGEKEY: ${{ secrets.SHOONYA_AZURE_STORAGEKEY_DEVELOP }}
AZURE_CREDS: ${{ secrets.SHOONYA_AZURE_CREDS_E2E }}
AZURE_STORAGEKEY: ${{ secrets.SHOONYA_AZURE_STORAGEKEY_DEVELOP_E2E }}
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.SHOONYA_AZURE_CONNECTION_STRING_DEVELOP_E2E }}

jobs:
cicd:
Expand Down Expand Up @@ -40,13 +41,13 @@ jobs:
uses: azure/CLI@v1
with:
inlineScript: |
az storage blob upload-batch --account-name shoonyastoragedevelop --account-key ${{ env.AZURE_STORAGEKEY }} -d '$web' -s ./build --overwrite
az storage blob upload-batch --connection-string ${{ env.AZURE_STORAGE_CONNECTION_STRING }} --destination '$web' --source ./build --overwrite
- name: Purge CDN endpoint
uses: azure/CLI@v1
with:
inlineScript: |
az cdn endpoint purge --no-wait --content-paths "/*" --profile-name develop-react-static --name frontend-develop-shoonya --resource-group shoonya
az cdn endpoint purge --no-wait --content-paths "/*" --profile-name shoonya-dev-cdn --name shoonya-dev-cdn-endpoint --resource-group shoonya-dev
- name: Azure logout
run: |
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@ai4bharat/indic-transliterate": "^1.3.0",
"@ai4bharat/indic-transliterate": "^1.3.2",
"@emotion/react": "^11.9.0",
"@emotion/styled": "^11.8.1",
"@heartexlabs/label-studio": "^1.4.0",
Expand Down
6 changes: 6 additions & 0 deletions src/ui/pages/container/Admin/AnnotationDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { snakeToTitleCase } from '../../../../utils/utils.js';
import FetchUserByIdAPI from "../../../../redux/actions/api/UserManagement/FetchUserById";
import DeleteAnnotationAPI from '../../../../redux/actions/api/Annotation/DeleteAnnotation.js';
import GetTaskDetailsAPI from "../../../../redux/actions/api/Tasks/GetTaskDetails.js";
import { Link } from 'react-router-dom';

function AnnotationDetails() {
const [annotationId, setAnnotationId] = useState('');
Expand Down Expand Up @@ -142,6 +143,11 @@ function AnnotationDetails() {
valueRenderer={(raw) => <span>{typeof raw === "string" && raw.match(/^"(.*)"$/) ? raw.slice(1, -1) : raw}</span>}
theme={theme}
/>
{annotationDetails &&(
<Link to ={`/projects/${annotationDetails.project_id}`}>
<Button variant="contained">Project Page</Button>
</Link>
)}
</Grid>
}
</Grid>
Expand Down
91 changes: 84 additions & 7 deletions src/ui/pages/container/Label-Studio/LSF.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,63 @@ const LabelStudioWrapper = ({
}
};

const clearAllChildren = () => {
if (lsfRef.current?.store?.annotationStore?.selected&&
taskData.task_status.toLowerCase() !== "labeled") {
if (taskData?.annotation_status !== "freezed") {
let annotation = lsfRef.current.store.annotationStore.selected;
let temp;
for (let i = 0; i < annotations.length; i++) {
if (
!annotations[i].result?.length ||
annotation.serializeAnnotation()[0].id ===
annotations[i].result[0].id
) {
temp = annotation.serializeAnnotation();
if (annotations[i].annotation_type !== 1) continue;
for (let i = 0; i < temp.length; i++) {
if (temp[i].parentID !== undefined){
delete temp[i].parentID;
}
if(temp[i].type === "relation"){
continue;
}else if (temp[i].value.text) {
temp[i].value.text = [temp[i].value.text[0]];
}
}
patchAnnotation(
taskId,
temp,
annotations[i].id,
load_time.current,
annotations[i].lead_time,
annotations[i].annotation_status,
JSON.stringify(annotationNotesRef.current.getEditor().getContents()),
true,
selectedLanguages,
ocrDomain
).then((res) => {
if (res.status !== 200) {
setSnackbarInfo({
open: true,
message: "Error in clearing children bboxes",
variant: "error",
});
}else{
window.location.reload();
}
});
}
}
}else
setSnackbarInfo({
open: true,
message: "Task is frozen",
variant: "error",
});
}
};

let hidden, visibilityChange;
if (typeof document.hidden !== "undefined") {
hidden = "hidden";
Expand Down Expand Up @@ -934,8 +991,8 @@ const LabelStudioWrapper = ({
if(Array.isArray(taskData?.data?.language)){
taskData?.data?.language?.map((lang)=>{
selectedLanguages.current?.push(lang);
const newLanguages = [...selectedL, ...taskData?.data?.language];
setSelectedL(newLanguages);
const newLanguages = new Set([...selectedL, ...taskData?.data?.language]);
setSelectedL(Array.from(newLanguages));
});
}
if(typeof taskData?.data?.language === 'string' && taskData?.data?.ocr_domain !== ""){
Expand Down Expand Up @@ -969,7 +1026,7 @@ const LabelStudioWrapper = ({
className="lsf-controls"
>
<div />
<Grid container spacing={0}>
<Grid container justifyContent="space-between">
<Grid item>
<LightTooltip title={assignedUsers ? assignedUsers : ""}>
<Button
Expand All @@ -990,9 +1047,7 @@ const LabelStudioWrapper = ({
/>
</Button>
</LightTooltip>
</Grid>
{/* <Grid container spacing={0} sx={{ justifyContent: "end" }}> */}
<Grid item>
{taskData?.annotation_users?.some(
(user) => user === userData.id
) &&
Expand All @@ -1016,8 +1071,6 @@ const LabelStudioWrapper = ({
</Button>
</Tooltip>
)}
</Grid>
<Grid item>
{/* {localStorage.getItem("labelAll") === "true" ? ( */}
<Tooltip title="Go to next task">
<Button
Expand All @@ -1041,6 +1094,30 @@ const LabelStudioWrapper = ({
<div style={{ minWidth: "160px" }} />
)} */}
</Grid>
{ProjectDetails?.project_type?.includes("OCR") &&
<>
<Grid item >
<Tooltip title="Clear all children bboxes">
<Button
type="default"
onClick={() => {clearAllChildren()}}
style={{
minWidth: "160px",
border: "1px solid #e6e6e6",
color: "#09f",
pt: 3,
pb: 3,
borderBottom: "None",
color: "#f00",
}}
className="lsf-button"
>
Clear All Mergings
</Button>
</Tooltip>
</Grid>
</>
}
</Grid>
</div>
)}
Expand Down
74 changes: 72 additions & 2 deletions src/ui/pages/container/Label-Studio/ReviewLSF.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,56 @@ useEffect(() => {
}
};

const clearAllChildren = () => {
if (lsfRef.current?.store?.annotationStore?.selected && taskData.task_status.toLowerCase() !== "accepted" && taskData.task_status.toLowerCase() !== "accepted_with_minor_changes" && taskData.task_status.toLowerCase() !== "accepted_with_major_changes") {
if (taskData?.annotation_status !== "freezed") {
let annotation = lsfRef.current.store.annotationStore.selected;
let temp = annotation.serializeAnnotation();
for (let i = 0; i < temp.length; i++) {
if (temp[i].parentID !== undefined){
delete temp[i].parentID;
}
if(temp[i].type === "relation"){
continue;
}else if (temp[i].value.text) {
temp[i].value.text = [temp[i].value.text[0]];
}
}
let review = annotations.filter(
(annotation) => annotation.annotation_type === 2
)[0];
patchReview(
taskId,
review.id,
load_time.current,
review.lead_time,
review.annotation_status,
temp,
review.parent_annotation,
JSON.stringify(reviewNotesRef.current.getEditor().getContents()),
true,
selectedLanguages,
ocrDomain
).then((res) => {
if (res.status !== 200) {
setSnackbarInfo({
open: true,
message: "Error in clearing children bboxes",
variant: "error",
});
}else{
window.location.reload();
}
});
} else
setSnackbarInfo({
open: true,
message: "Task is frozen",
variant: "error",
});
}
};

let hidden, visibilityChange;
if (typeof document.hidden !== 'undefined') {
hidden = 'hidden';
Expand Down Expand Up @@ -1149,8 +1199,8 @@ useEffect(() => {
if(Array.isArray(taskData?.data?.language)){
taskData?.data?.language?.map((lang)=>{
selectedLanguages.current?.push(lang);
const newLanguages = [...selectedL, ...taskData?.data?.language];
setSelectedL(newLanguages);
const newLanguages = new Set([...selectedL, ...taskData?.data?.language]);
setSelectedL(Array.from(newLanguages));
});
}
if(typeof taskData?.data?.language === 'string' && taskData?.data?.ocr_domain !== ""){
Expand Down Expand Up @@ -1282,6 +1332,26 @@ useEffect(() => {
</Button>
</Tooltip>
)}
{ProjectDetails?.project_type?.includes("OCR") &&
<Tooltip title="Clear all children bboxes">
<Button
type="default"
onClick={() => {clearAllChildren()}}
style={{
minWidth: "160px",
border: "1px solid #e6e6e6",
color: "#09f",
pt: 3,
pb: 3,
borderBottom: "None",
color: "#f00",
}}
className="lsf-button"
>
Clear All Mergings
</Button>
</Tooltip>
}
<StyledMenu
id="accept-menu"
MenuListProps={{
Expand Down
Loading

0 comments on commit fdca950

Please sign in to comment.