Skip to content

Commit da83cd8

Browse files
Merge pull request #472 from CedricProfessionnel/ImproveCheckInterfaceAndSampleType
Indepedent check of interface and sample + Check if Time data (Aws Feature Part)
2 parents 4c29738 + 12dedd8 commit da83cd8

File tree

3 files changed

+160
-56
lines changed

3 files changed

+160
-56
lines changed
Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
11
import isEmpty from "lodash/isEmpty"
2-
export default (typeAuthorize, file) => {
3-
const interfaceFileType = (type) => {
4-
if (
5-
type === "image_classification" ||
6-
type === "image_segmentation" ||
7-
type === "composite"
8-
)
9-
return "Image"
10-
if (type === "video_segmentation") return "Video"
11-
if (type === "audio_transcription") return "Audio"
12-
if (type === "data_entry") return "PDF"
13-
if (type === "text_entity_recognition" || type === "text_classification")
14-
return "Text"
15-
if (isEmpty(type)) return "Empty"
16-
return "File"
17-
}
18-
19-
const typeAssetsFromSample = (assets) => {
20-
if (isEmpty(assets) || isEmpty(assets[0])) return "Empty"
21-
if (!isEmpty(assets[0].imageUrl)) return "Image"
22-
if (!isEmpty(assets[0].videoUrl)) return "Video"
23-
if (!isEmpty(assets[0].audioUrl)) return "Audio"
24-
if (!isEmpty(assets[0].pdfUrl)) return "PDF"
25-
if (!isEmpty(assets[0].document)) return "Text"
26-
return "File"
27-
}
2+
const interfaceFileType = (type) => {
3+
if (
4+
type === "image_classification" ||
5+
type === "image_segmentation" ||
6+
type === "composite"
7+
)
8+
return "Image"
9+
if (type === "video_segmentation") return "Video"
10+
if (type === "audio_transcription") return "Audio"
11+
if (type === "data_entry") return "PDF"
12+
if (type === "text_entity_recognition" || type === "text_classification")
13+
return "Text"
14+
if (type === "time_series") return "Time"
15+
if (isEmpty(type)) return "Empty"
16+
return "File"
17+
}
2818

19+
const typeAssetsFromSample = (assets) => {
20+
if (isEmpty(assets) || isEmpty(assets[0])) return "Empty"
21+
if (!isEmpty(assets[0].imageUrl)) return "Image"
22+
if (!isEmpty(assets[0].videoUrl)) return "Video"
23+
if (!isEmpty(assets[0].audioUrl)) return "Audio"
24+
if (!isEmpty(assets[0].pdfUrl)) return "PDF"
25+
if (!isEmpty(assets[0].document)) return "Text"
26+
if (!isEmpty(assets[0].timeData)) return "Time"
27+
return "File"
28+
}
29+
export default (typeAuthorizeInterface, typeAuthorizeAssets, file) => {
2930
var result = [null, null]
3031
if (isEmpty(file)) return false
3132
result[0] = interfaceFileType(file.interface.type)
3233
result[1] = typeAssetsFromSample(file.samples)
33-
if (typeAuthorize.includes(result[0]) && typeAuthorize.includes(result[1]))
34+
if (
35+
typeAuthorizeInterface.includes(result[0]) &&
36+
typeAuthorizeAssets.includes(result[1])
37+
)
3438
return true
3539
return false
3640
}

src/components/ImportFromCognitoS3Dialog/init-config-import.js

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,75 @@ import checkInterfaceAndsamples from "./check-interface-and-sample-type"
22
export default (dataset) => {
33
return {
44
annotationToKeep: "both",
5-
typeOfFileToLoad: checkInterfaceAndsamples(["Image", "Empty"], dataset)
5+
typeOfFileToLoad: checkInterfaceAndsamples(["Empty"], ["Empty"], dataset)
6+
? "None"
7+
: checkInterfaceAndsamples(
8+
["Image", "Empty"],
9+
["Image", "Empty"],
10+
dataset
11+
)
612
? "Image"
7-
: checkInterfaceAndsamples(["Video", "Empty"], dataset)
13+
: checkInterfaceAndsamples(
14+
["Video", "Empty"],
15+
["Video", "Empty"],
16+
dataset
17+
)
818
? "Video"
9-
: checkInterfaceAndsamples(["Audio", "Empty"], dataset)
19+
: checkInterfaceAndsamples(
20+
["Audio", "Empty"],
21+
["Audio", "Empty"],
22+
dataset
23+
)
1024
? "Audio"
11-
: checkInterfaceAndsamples(["PDF", "Empty"], dataset)
25+
: checkInterfaceAndsamples(["PDF", "Empty"], ["PDF", "Empty"], dataset)
1226
? "PDF"
13-
: checkInterfaceAndsamples(["Text", "Empty"], dataset)
27+
: checkInterfaceAndsamples(["Text", "Empty"], ["Text", "Empty"], dataset)
1428
? "Text"
29+
: checkInterfaceAndsamples(
30+
["Time", "Empty"],
31+
["Time", "Empty", "Audio"],
32+
dataset
33+
)
34+
? "Time"
1535
: "None",
1636
typeOfFileToDisable: {
17-
Image: !checkInterfaceAndsamples(["Image", "Empty"], dataset),
18-
Video: !checkInterfaceAndsamples(["Video", "Empty"], dataset),
19-
Audio: !checkInterfaceAndsamples(["Audio", "Empty"], dataset),
20-
PDF: !checkInterfaceAndsamples(["PDF", "Empty"], dataset),
21-
Text: !checkInterfaceAndsamples(["Text", "Empty"], dataset),
37+
Image: !checkInterfaceAndsamples(
38+
["Image", "Empty"],
39+
["Image", "Empty"],
40+
dataset
41+
),
42+
Video: !checkInterfaceAndsamples(
43+
["Video", "Empty"],
44+
["Video", "Empty"],
45+
dataset
46+
),
47+
Audio: !(
48+
checkInterfaceAndsamples(
49+
["Time", "Empty"],
50+
["Time", "Audio", "Empty"],
51+
dataset
52+
) ||
53+
checkInterfaceAndsamples(
54+
["Audio", "Empty"],
55+
["Audio", "Empty"],
56+
dataset
57+
)
58+
),
59+
PDF: !checkInterfaceAndsamples(
60+
["PDF", "Empty"],
61+
["PDF", "Empty"],
62+
dataset
63+
),
64+
Text: !checkInterfaceAndsamples(
65+
["Text", "Empty"],
66+
["Text", "Empty"],
67+
dataset
68+
),
69+
Time: !checkInterfaceAndsamples(
70+
["Time", "Empty"],
71+
["Time", "Empty", "Audio"],
72+
dataset
73+
),
2274
},
2375
loadAssetsIsSelected: true,
2476
contentDialogBoxIsSetting: false,
Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,84 @@
11
import isEmpty from "lodash/isEmpty"
2-
import checkInterfaceAndAssets from "./check-interface-and-sample-type"
2+
import checkInterfaceAndsamples from "./check-interface-and-sample-type"
33
export default (configImport, dataset) => {
44
return {
55
...configImport,
66
typeOfFileToLoad:
77
!isEmpty(configImport) &&
88
!isEmpty(configImport.typeOfFileToLoad) &&
9-
checkInterfaceAndAssets([configImport.typeOfFileToLoad, "Empty"], dataset)
10-
? configImport.typeOfFileToLoad
11-
: checkInterfaceAndAssets(["Image", "Empty"], dataset)
9+
checkInterfaceAndsamples(["Empty"], ["Empty"], dataset)
10+
? "None"
11+
: checkInterfaceAndsamples(
12+
["Image", "Empty"],
13+
["Image", "Empty"],
14+
dataset
15+
)
1216
? "Image"
13-
: checkInterfaceAndAssets(["Video", "Empty"], dataset)
17+
: checkInterfaceAndsamples(
18+
["Video", "Empty"],
19+
["Video", "Empty"],
20+
dataset
21+
)
1422
? "Video"
15-
: checkInterfaceAndAssets(["Audio", "Empty"], dataset)
23+
: checkInterfaceAndsamples(
24+
["Audio", "Empty"],
25+
["Audio", "Empty"],
26+
dataset
27+
)
1628
? "Audio"
17-
: checkInterfaceAndAssets(["PDF", "Empty"], dataset)
29+
: checkInterfaceAndsamples(["PDF", "Empty"], ["PDF", "Empty"], dataset)
1830
? "PDF"
19-
: checkInterfaceAndAssets(["Text", "Empty"], dataset)
31+
: checkInterfaceAndsamples(
32+
["Text", "Empty"],
33+
["Text", "Empty"],
34+
dataset
35+
)
2036
? "Text"
37+
: checkInterfaceAndsamples(
38+
["Time", "Empty"],
39+
["Time", "Empty", "Audio"],
40+
dataset
41+
)
42+
? "Time"
2143
: "None",
2244
typeOfFileToDisable: {
23-
Image: checkInterfaceAndAssets(["Image", "Empty"], dataset)
24-
? false
25-
: true,
26-
Video: checkInterfaceAndAssets(["Video", "Empty"], dataset)
27-
? false
28-
: true,
29-
Audio: checkInterfaceAndAssets(["Audio", "Empty"], dataset)
30-
? false
31-
: true,
32-
PDF: checkInterfaceAndAssets(["PDF", "Empty"], dataset) ? false : true,
33-
Text: checkInterfaceAndAssets(["Text", "Empty"], dataset) ? false : true,
45+
Image: !checkInterfaceAndsamples(
46+
["Image", "Empty"],
47+
["Image", "Empty"],
48+
dataset
49+
),
50+
Video: !checkInterfaceAndsamples(
51+
["Video", "Empty"],
52+
["Video", "Empty"],
53+
dataset
54+
),
55+
Audio: !(
56+
checkInterfaceAndsamples(
57+
["Time", "Empty"],
58+
["Time", "Audio", "Empty"],
59+
dataset
60+
) ||
61+
checkInterfaceAndsamples(
62+
["Audio", "Empty"],
63+
["Audio", "Empty"],
64+
dataset
65+
)
66+
),
67+
PDF: !checkInterfaceAndsamples(
68+
["PDF", "Empty"],
69+
["PDF", "Empty"],
70+
dataset
71+
),
72+
Text: !checkInterfaceAndsamples(
73+
["Text", "Empty"],
74+
["Text", "Empty"],
75+
dataset
76+
),
77+
Time: !checkInterfaceAndsamples(
78+
["Time", "Empty"],
79+
["Time", "Empty", "Audio"],
80+
dataset
81+
),
3482
},
3583
}
3684
}

0 commit comments

Comments
 (0)