Skip to content

Commit

Permalink
fixed merge conflicts with main
Browse files Browse the repository at this point in the history
  • Loading branch information
ARADDCC002 authored and ARADDCC002 committed Sep 21, 2022
2 parents 9839a76 + 9c6aa1c commit 13ba2e9
Show file tree
Hide file tree
Showing 15 changed files with 260 additions and 111 deletions.
3 changes: 2 additions & 1 deletion __tests__/example_models/minimal_model/minimal_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"manager": "user"
},
"buildOptions": {
"exportRawModel": true
"exportRawModel": true,
"uploadType": "Code and binaries"
}
}
5 changes: 5 additions & 0 deletions __tests__/selenium_tests/test_upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ describe('End to end test', () => {
await driver.wait(until.urlContains('/model/'))
const modelUrl = await driver.getCurrentUrl()
const mName = modelUrl.match('/.*/model/(?<name>[^/]*)')!.groups!.name

logger.info(`model name is ${mName}`)

modelInfo.url = modelUrl
modelInfo.name = mName

Expand Down Expand Up @@ -263,6 +266,8 @@ describe('End to end test', () => {
{ silentErrors: true }
)

logger.info({ modelInfo }, 'the model info')

logger.info('pulling container')
await runCommand(`docker pull ${imageName}`, logger.debug.bind(logger), logger.error.bind(logger), {
silentErrors: true,
Expand Down
67 changes: 58 additions & 9 deletions pages/deployment/[uuid].tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ObjectId } from 'mongoose'
import Info from '@mui/icons-material/Info'
import DownArrow from '@mui/icons-material/KeyboardArrowDownTwoTone'
import UpArrow from '@mui/icons-material/KeyboardArrowUpTwoTone'
import RestartAlt from '@mui/icons-material/RestartAltTwoTone'
import Alert from '@mui/material/Alert'
import Button from '@mui/material/Button'
import Dialog from '@mui/material/Dialog'
import DialogContent from '@mui/material/DialogContent'
Expand All @@ -24,7 +26,7 @@ import Box from '@mui/system/Box'
import dynamic from 'next/dynamic'
import Link from 'next/link'
import { useRouter } from 'next/router'
import React, { MouseEvent, useEffect, useState } from 'react'
import React, { MouseEvent, useEffect, useMemo, useState } from 'react'
import { Elements } from 'react-flow-renderer'
import { useGetDeployment } from '../../data/deployment'
import { useGetUiConfig } from '../../data/uiConfig'
Expand All @@ -40,6 +42,8 @@ import { createDeploymentComplianceFlow } from '../../utils/complianceFlow'
import { postEndpoint } from '../../data/api'
import RawModelExportList from '../../src/RawModelExportList'
import DisabledElementTooltip from '../../src/common/DisabledElementTooltip'
import { VersionDoc } from '../../server/models/Version'
import { ModelUploadType } from '../../types/interfaces'

const ComplianceFlow = dynamic(() => import('../../src/ComplianceFlow'))

Expand Down Expand Up @@ -85,6 +89,9 @@ function CodeLine({ line }) {
)
}

const isVersionDoc = (value: unknown): value is VersionDoc =>
!!value && (value as VersionDoc)._id && (value as VersionDoc).version

export default function Deployment() {
const router = useRouter()
const { uuid, tab }: { uuid?: string; tab?: TabOptions } = router.query
Expand All @@ -102,10 +109,24 @@ export default function Deployment() {

const theme: any = useTheme() || lightTheme

const initialVersionRequested = useMemo(() => {
if (!deployment) return undefined
const initialVersion = deployment.versions.find(
(version) =>
isVersionDoc(version) && version.version === deployment.metadata.highLevelDetails.initialVersionRequested
)
return isVersionDoc(initialVersion) ? initialVersion : undefined
}, [deployment])

const hasUploadType = useMemo(
() => initialVersionRequested !== undefined && !!initialVersionRequested.metadata.buildOptions.uploadType,
[initialVersionRequested]
)

useEffect(() => {
if (deployment?.metadata?.highLevelDetails !== undefined) {
const { modelID, initialVersionRequested } = deployment.metadata.highLevelDetails
setTag(`${modelID}:${initialVersionRequested}`)
const { modelID, versionRequested } = deployment.metadata.highLevelDetails
setTag(`${modelID}:${versionRequested}`)
}
}, [deployment])

Expand Down Expand Up @@ -166,11 +187,32 @@ export default function Deployment() {
return (
<>
<Wrapper title={`Deployment: ${deployment.metadata.highLevelDetails.name}`} page='deployment'>
<Box sx={{ textAlign: 'right', pb: 3 }}>
<Button variant='outlined' color='primary' startIcon={<Info />} onClick={handleClickOpen}>
Show download commands
</Button>
</Box>
{hasUploadType ||
(initialVersionRequested?.metadata.buildOptions.uploadType !== ModelUploadType.ModelCard && (
<Box sx={{ textAlign: 'right', pb: 3 }}>
<Button variant='outlined' color='primary' startIcon={<Info />} onClick={handleClickOpen}>
Show download commands
</Button>
</Box>
))}
{hasUploadType && initialVersionRequested?.metadata.buildOptions.uploadType === ModelUploadType.ModelCard && (
<Box sx={{ pb: 2 }}>
<Alert
severity='info'
sx={{
width: 'fit-content',
m: 'auto',
backgroundColor: '#0288d1',
color: '#fff',
'& .MuiAlert-icon': {
color: '#fff',
},
}}
>
This model version was uploaded as just a model card
</Alert>
</Box>
)}
<Paper sx={{ p: 3 }}>
<Stack direction='row' spacing={2}>
<ApprovalsChip
Expand Down Expand Up @@ -218,7 +260,14 @@ export default function Deployment() {
>
<Tab label='Overview' value='overview' />
<Tab label='Compliance' value='compliance' />
<Tab label='Build Logs' value='build' />
<Tab
label='Build Logs'
value='build'
disabled={
hasUploadType &&
initialVersionRequested?.metadata.buildOptions.uploadType === ModelUploadType.ModelCard
}
/>
<Tab label='Settings' value='settings' />
<Tab
style={{ pointerEvents: 'auto' }}
Expand Down
19 changes: 16 additions & 3 deletions pages/model/[uuid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { Types } from 'mongoose'
import dynamic from 'next/dynamic'
import Link from 'next/link'
import { useRouter } from 'next/router'
import React, { MouseEvent, useEffect, useState } from 'react'
import React, { MouseEvent, useEffect, useMemo, useState } from 'react'
import { Elements } from 'react-flow-renderer'
import UserAvatar from 'src/common/UserAvatar'
import ModelOverview from 'src/ModelOverview'
Expand All @@ -49,7 +49,7 @@ import ApprovalsChip from '../../src/common/ApprovalsChip'
import EmptyBlob from '../../src/common/EmptyBlob'
import MultipleErrorWrapper from '../../src/errors/MultipleErrorWrapper'
import { lightTheme } from '../../src/theme'
import { Deployment, User, Version } from '../../types/interfaces'
import { Deployment, User, Version, ModelUploadType } from '../../types/interfaces'
import DisabledElementTooltip from '../../src/common/DisabledElementTooltip'

const ComplianceFlow = dynamic(() => import('../../src/ComplianceFlow'))
Expand Down Expand Up @@ -84,6 +84,8 @@ function Model() {
const { version, isVersionLoading, isVersionError, mutateVersion } = useGetModelVersion(uuid, selectedVersion)
const { deployments, isDeploymentsLoading, isDeploymentsError } = useGetModelDeployments(uuid)

const hasUploadType = useMemo(() => version !== undefined && !!version.metadata.buildOptions.uploadType, [version])

const onVersionChange = setTargetValue(setSelectedVersion)
const theme: any = useTheme() || lightTheme

Expand Down Expand Up @@ -172,6 +174,13 @@ function Model() {

return (
<Wrapper title={`Model: ${version.metadata.highLevelDetails.name}`} page='model'>
{hasUploadType && version.metadata.buildOptions.uploadType === ModelUploadType.ModelCard && (
<Box sx={{ pb: 2 }}>
<Alert severity='info' sx={{ width: 'fit-content', m: 'auto' }}>
This model version was uploaded as just a model card
</Alert>
</Box>
)}
<Paper sx={{ p: 3 }}>
<Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
<Grid container justifyContent='space-between' alignItems='center'>
Expand Down Expand Up @@ -318,7 +327,11 @@ function Model() {
>
<Tab label='Overview' value='overview' />
<Tab label='Compliance' value='compliance' />
<Tab label='Build Logs' value='build' />
<Tab
label='Build Logs'
value='build'
disabled={hasUploadType && version.metadata.buildOptions.uploadType === ModelUploadType.ModelCard}
/>
<Tab label='Deployments' value='deployments' />
<Tab label='Settings' value='settings' />
</Tabs>
Expand Down
5 changes: 3 additions & 2 deletions pages/model/[uuid]/new-version.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useGetSchema } from '../../../data/schema'
import LoadingBar from '../../../src/common/LoadingBar'
import MultipleErrorWrapper from '../../../src/errors/MultipleErrorWrapper'
import Form from '../../../src/Form/Form'
import RenderFileTab, { RenderBasicFileTab, FileTabComplete } from '../../../src/Form/RenderFileTab'
import RenderFileTab, { RenderBasicFileTab, fileTabComplete } from '../../../src/Form/RenderFileTab'
import ModelExportAndSubmission from '../../../src/Form/ModelExportAndSubmission'
import { RenderButtonsInterface } from '../../../src/Form/RenderButtons'
import SubmissionError from '../../../src/Form/SubmissionError'
Expand Down Expand Up @@ -66,6 +66,7 @@ function Upload() {
state: {
binary: undefined,
code: undefined,
steps,
},
schemaRef: cModel.schemaRef,

Expand All @@ -75,7 +76,7 @@ function Upload() {

render: RenderFileTab,
renderBasic: RenderBasicFileTab,
isComplete: FileTabComplete,
isComplete: fileTabComplete,
})
)

Expand Down
11 changes: 6 additions & 5 deletions pages/upload.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import axios from 'axios'
import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'
import { useGetDefaultSchema, useGetSchemas } from '@/data/schema'
import { useGetCurrentUser } from '@/data/user'
import LoadingBar from '@/src/common/LoadingBar'
Expand All @@ -6,7 +9,7 @@ import MultipleErrorWrapper from '@/src/errors/MultipleErrorWrapper'
import Form from '@/src/Form/Form'
import ModelExportAndSubmission from '@/src/Form/ModelExportAndSubmission'
import { RenderButtonsInterface } from '@/src/Form/RenderButtons'
import RenderFileTab, { FileTabComplete, RenderBasicFileTab } from '@/src/Form/RenderFileTab'
import RenderFileTab, { fileTabComplete, RenderBasicFileTab } from '@/src/Form/RenderFileTab'
import SchemaSelector from '@/src/Form/SchemaSelector'
import SubmissionError from '@/src/Form/SubmissionError'
import Wrapper from '@/src/Wrapper'
Expand All @@ -15,9 +18,6 @@ import { createStep, getStepsData, getStepsFromSchema } from '@/utils/formUtils'
import Box from '@mui/material/Box'
import Grid from '@mui/material/Grid'
import Paper from '@mui/material/Paper'
import axios from 'axios'
import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'

function renderSubmissionTab({
splitSchema,
Expand Down Expand Up @@ -84,6 +84,7 @@ function Upload() {
state: {
binary: undefined,
code: undefined,
steps,
},
schemaRef: reference,

Expand All @@ -93,7 +94,7 @@ function Upload() {

render: RenderFileTab,
renderBasic: RenderBasicFileTab,
isComplete: FileTabComplete,
isComplete: fileTabComplete,
})
)

Expand Down
5 changes: 0 additions & 5 deletions server/models/Version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ import { LogStatement } from './Deployment'
import { approvalStateOptions, ApprovalStates } from '../../types/interfaces'
import { ModelDoc } from './Model'

interface FilePaths {
rawBinaryPath: string
rawCodePath: string
}

export interface Version {
model: ModelDoc | Types.ObjectId
version: string
Expand Down
Loading

0 comments on commit 13ba2e9

Please sign in to comment.