Initial public release
GeoIntel release gates / Compile, test, contracts and builds (push) Successful in 1m49s
GeoIntel release gates / Python and npm vulnerability policy (push) Successful in 21s
GeoIntel release gates / Production AI image, SBOM and container scan (push) Successful in 5m39s
GeoIntel release gates / Deploy exact gated revision to Unraid (push) Failing after 58m43s
GeoIntel release gates / Compile, test, contracts and builds (push) Successful in 1m49s
GeoIntel release gates / Python and npm vulnerability policy (push) Successful in 21s
GeoIntel release gates / Production AI image, SBOM and container scan (push) Successful in 5m39s
GeoIntel release gates / Deploy exact gated revision to Unraid (push) Failing after 58m43s
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
import { useState } from 'react'
|
||||
import { demoApi } from '../services/api'
|
||||
import type { DatasetCreateResponse, QualityCheckRead } from '../types'
|
||||
import { formatError } from '../lib/formatError'
|
||||
|
||||
interface DemoWorkflowOptions {
|
||||
restrictedMode?: boolean
|
||||
loadProjects: (preferredProjectId?: string | null) => Promise<void>
|
||||
loadProjectData: (projectId: string) => Promise<{ datasets: DatasetCreateResponse[] } | null>
|
||||
loadDatasetDetails: (projectId: string, dataset: DatasetCreateResponse) => Promise<void>
|
||||
loadDetectionRuns: (projectId?: string | null) => Promise<void>
|
||||
loadSegmentationRuns: (projectId?: string | null) => Promise<void>
|
||||
loadQualityChecks: (projectId?: string | null) => Promise<QualityCheckRead[] | void>
|
||||
loadExports: (projectId?: string | null) => Promise<void>
|
||||
setSelectedProjectId: (projectId: string) => void
|
||||
setSelectedDatasetId: (datasetId: string | null) => void
|
||||
setSelectedMapAreaId: (areaId: string) => void
|
||||
setQaCandidateDatasetId: (datasetId: string) => void
|
||||
setQaReferenceDatasetId: (datasetId: string) => void
|
||||
setQaAreaId: (areaId: string) => void
|
||||
setSelectedDetectionDatasetId: (datasetId: string) => void
|
||||
setDetectionReferenceDatasetId: (datasetId: string) => void
|
||||
setSelectedSegmentationDatasetId: (datasetId: string) => void
|
||||
setSegmentationReferenceDatasetId: (datasetId: string) => void
|
||||
setErrorMessage: (message: string | null) => void
|
||||
}
|
||||
|
||||
export function useDemoWorkflow({
|
||||
restrictedMode = false,
|
||||
loadProjects,
|
||||
loadProjectData,
|
||||
loadDatasetDetails,
|
||||
loadDetectionRuns,
|
||||
loadSegmentationRuns,
|
||||
loadQualityChecks,
|
||||
loadExports,
|
||||
setSelectedProjectId,
|
||||
setSelectedDatasetId,
|
||||
setSelectedMapAreaId,
|
||||
setQaCandidateDatasetId,
|
||||
setQaReferenceDatasetId,
|
||||
setQaAreaId,
|
||||
setSelectedDetectionDatasetId,
|
||||
setDetectionReferenceDatasetId,
|
||||
setSelectedSegmentationDatasetId,
|
||||
setSegmentationReferenceDatasetId,
|
||||
setErrorMessage,
|
||||
}: DemoWorkflowOptions) {
|
||||
const [loadingDemoWorkflow, setLoadingDemoWorkflow] = useState(false)
|
||||
const [demoWorkflowMessage, setDemoWorkflowMessage] = useState<string | null>(null)
|
||||
|
||||
const loadDemoWorkflow = async (): Promise<boolean> => {
|
||||
setLoadingDemoWorkflow(true)
|
||||
setDemoWorkflowMessage(null)
|
||||
setErrorMessage(null)
|
||||
try {
|
||||
const result = await demoApi.seedWorkflow()
|
||||
setSelectedProjectId(result.project_id)
|
||||
setSelectedDatasetId(result.candidate_dataset_id)
|
||||
setSelectedMapAreaId(result.area_id)
|
||||
setQaCandidateDatasetId(result.candidate_dataset_id)
|
||||
setQaReferenceDatasetId(result.reference_dataset_id)
|
||||
setQaAreaId(result.area_id)
|
||||
setSelectedDetectionDatasetId(result.raster_dataset_id ?? '')
|
||||
setDetectionReferenceDatasetId(result.reference_dataset_id)
|
||||
setSelectedSegmentationDatasetId(result.raster_dataset_id ?? '')
|
||||
setSegmentationReferenceDatasetId(result.reference_dataset_id)
|
||||
setDemoWorkflowMessage(result.message)
|
||||
await loadProjects(result.project_id)
|
||||
const analysisLoads = Promise.all([
|
||||
loadDetectionRuns(result.project_id),
|
||||
loadSegmentationRuns(result.project_id),
|
||||
loadExports(result.project_id),
|
||||
]).then(() => undefined)
|
||||
const [projectData] = await Promise.all([
|
||||
loadProjectData(result.project_id),
|
||||
loadQualityChecks(result.project_id),
|
||||
analysisLoads,
|
||||
])
|
||||
const candidateDataset = projectData?.datasets?.find((dataset) => dataset.id === result.candidate_dataset_id)
|
||||
const rasterDataset = projectData?.datasets?.find((dataset) => dataset.id === result.raster_dataset_id)
|
||||
if (candidateDataset) {
|
||||
await loadDatasetDetails(result.project_id, candidateDataset)
|
||||
} else if (rasterDataset) {
|
||||
await loadDatasetDetails(result.project_id, rasterDataset)
|
||||
}
|
||||
return true
|
||||
} catch (error) {
|
||||
setErrorMessage(formatError(error, 'De demowerkruimte kon niet worden geladen.'))
|
||||
return false
|
||||
} finally {
|
||||
setLoadingDemoWorkflow(false)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
loadingDemoWorkflow,
|
||||
demoWorkflowMessage,
|
||||
loadDemoWorkflow,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user