From 10d625142304f0edfb2ea05bd54be91db9789a04 Mon Sep 17 00:00:00 2001 From: araddcc002 Date: Wed, 18 Dec 2024 14:49:28 +0000 Subject: [PATCH] restructured the model mirror page and added a backend check for existing model card before allowing export --- backend/config/default.cjs | 2 +- backend/src/services/mirroredModel.ts | 3 + .../mirroredModels/ExportModelAgreement.tsx | 44 +++++++------ .../model/mirroredModels/ExportSettings.tsx | 63 +++++++++---------- 4 files changed, 56 insertions(+), 56 deletions(-) diff --git a/backend/config/default.cjs b/backend/config/default.cjs index aab5979cb..bbae1d2ac 100644 --- a/backend/config/default.cjs +++ b/backend/config/default.cjs @@ -191,7 +191,7 @@ module.exports = { enabled: false, }, export: { - enabled: false, + enabled: true, disclaimer: '## Example Agreement \n I agree that this model is suitable for exporting', }, }, diff --git a/backend/src/services/mirroredModel.ts b/backend/src/services/mirroredModel.ts index edf1f801c..f3fe485a1 100644 --- a/backend/src/services/mirroredModel.ts +++ b/backend/src/services/mirroredModel.ts @@ -46,6 +46,9 @@ export async function exportModel( if (!model.settings.mirror.destinationModelId) { throw BadReq(`The 'Destination Model ID' has not been set on this model.`) } + if (!model.card || !model.card.schemaId) { + throw BadReq('You must select a schema for your model before you can start the export process.') + } const mirroredModelId = model.settings.mirror.destinationModelId const auth = await authorisation.model(user, model, ModelAction.Update) if (!auth.success) { diff --git a/frontend/src/entry/model/mirroredModels/ExportModelAgreement.tsx b/frontend/src/entry/model/mirroredModels/ExportModelAgreement.tsx index 70078cb87..989245704 100644 --- a/frontend/src/entry/model/mirroredModels/ExportModelAgreement.tsx +++ b/frontend/src/entry/model/mirroredModels/ExportModelAgreement.tsx @@ -1,5 +1,5 @@ import { LoadingButton } from '@mui/lab' -import { Box, Button, Card, Checkbox, Container, FormControlLabel, Stack, Typography } from '@mui/material' +import { Box, Button, Checkbox, FormControlLabel, Stack, Typography } from '@mui/material' import { postModelExportToS3 } from 'actions/model' import { ChangeEvent, FormEvent, useState } from 'react' import Restricted from 'src/common/Restricted' @@ -46,27 +46,25 @@ export default function ExportModelAgreement({ modelId }: ExportModelAgreementPr } return ( - - - - Model Export Agreement - - - - - } - label='I agree to the terms and conditions of this model export agreement' - /> - Submit}> - - Submit - - - - - - - + <> + + Model Export Agreement + + + + + } + label='I agree to the terms and conditions of this model export agreement' + /> + Submit}> + + Submit + + + + + + ) } diff --git a/frontend/src/entry/model/mirroredModels/ExportSettings.tsx b/frontend/src/entry/model/mirroredModels/ExportSettings.tsx index 62f2839fc..a069d7d8c 100644 --- a/frontend/src/entry/model/mirroredModels/ExportSettings.tsx +++ b/frontend/src/entry/model/mirroredModels/ExportSettings.tsx @@ -1,6 +1,5 @@ -import ExpandMoreIcon from '@mui/icons-material/ExpandMore' import { LoadingButton } from '@mui/lab' -import { Accordion, AccordionDetails, AccordionSummary, Box, Stack, TextField, Typography } from '@mui/material' +import { Box, Card, Container, Divider, Stack, TextField, Typography } from '@mui/material' import { patchModel } from 'actions/model' import { ChangeEvent, FormEvent, useState } from 'react' import LabelledInput from 'src/common/LabelledInput' @@ -55,25 +54,23 @@ export default function ExportSettings({ model }: ExportSettingsProps) { return ( <> - - - }> - - Export Settings - - - + + - - - - - {/*TODO - Add the ability to filter releases needed for export (This functionality is not available on the backend) + }> + <> + + Model Export Settings + + + + + {/*TODO - Add the ability to filter releases needed for export (This functionality is not available on the backend) */} - - Save - - + + Save + + + + - - + + ) }