Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated config and audit for create model card£ #1466

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/src/connectors/audit/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export abstract class BaseAuditConnector {
abstract onUpdateModel(req: Request, model: ModelDoc)
abstract onSearchModel(req: Request, models: ModelSearchResult[])

abstract onCreateModelCard(req: Request, modelId: string, modelCard: ModelCardInterface)
abstract onCreateModelCard(req: Request, model: ModelDoc, modelCard: ModelCardInterface)
abstract onViewModelCard(req: Request, modelId: string, modelCard: ModelCardInterface)
abstract onUpdateModelCard(req: Request, modelId: string, modelCard: ModelCardInterface)
abstract onViewModelCardRevisions(req: Request, modelId: string, modelCards: ModelCardInterface[])
Expand Down
2 changes: 1 addition & 1 deletion backend/src/connectors/audit/silly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class SillyAuditConnector extends BaseAuditConnector {
onViewModel(_req: Request, _model: ModelDoc) {}
onUpdateModel(_req: Request, _model: ModelDoc) {}
onSearchModel(_req: Request, _models: ModelSearchResult[]) {}
onCreateModelCard(_req: Request, _modelId: string, _modelCard: ModelCardInterface) {}
onCreateModelCard(_req: Request, _model: ModelDoc, _modelCard: ModelCardInterface) {}
onViewModelCard(_req: Request, _modelId: string, _modelCard: ModelCardInterface) {}
onUpdateModelCard(_req: Request, _modelId: string, _modelCard: ModelCardInterface) {}
onViewModelCardRevisions(_req: Request, _modelId: string, _modelCards: ModelCardInterface[]) {}
Expand Down
4 changes: 2 additions & 2 deletions backend/src/connectors/audit/stdout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export class StdoutAuditConnector extends BaseAuditConnector {
req.log.info(event, req.audit.description)
}

onCreateModelCard(req: Request, modelId: string, modelCard: ModelCardInterface) {
onCreateModelCard(req: Request, model: ModelDoc, modelCard: ModelCardInterface) {
this.checkEventType(AuditInfo.CreateModelCard, req)
const event = this.generateEvent(req, { modelId, version: modelCard.version })
const event = this.generateEvent(req, { model, version: modelCard.version })
req.log.info(event, req.audit.description)
}

Expand Down
5 changes: 3 additions & 2 deletions backend/src/routes/v2/model/modelcard/postFromSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { z } from 'zod'
import { AuditInfo } from '../../../../connectors/audit/Base.js'
import audit from '../../../../connectors/audit/index.js'
import { ModelCardRevisionInterface } from '../../../../models/ModelCardRevision.js'
import { createModelCardFromSchema } from '../../../../services/model.js'
import { createModelCardFromSchema, getModelById } from '../../../../services/model.js'
import { modelCardRevisionInterfaceSchema, registerPath } from '../../../../services/specification.js'
import { parse } from '../../../../utils/validate.js'

Expand Down Expand Up @@ -56,8 +56,9 @@ export const postFromSchema = [
} = parse(req, postFromSchemaSchema)

const modelCard = await createModelCardFromSchema(req.user, modelId, schemaId)
const model = await getModelById(req.user, modelId)

await audit.onCreateModelCard(req, modelId, modelCard)
await audit.onCreateModelCard(req, model, modelCard)

return res.json({
card: modelCard,
Expand Down
5 changes: 3 additions & 2 deletions backend/src/routes/v2/model/modelcard/postFromTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { z } from 'zod'
import { AuditInfo } from '../../../../connectors/audit/Base.js'
import audit from '../../../../connectors/audit/index.js'
import { ModelCardRevisionInterface } from '../../../../models/ModelCardRevision.js'
import { createModelCardFromTemplate } from '../../../../services/model.js'
import { createModelCardFromTemplate, getModelById } from '../../../../services/model.js'
import { modelCardRevisionInterfaceSchema, registerPath } from '../../../../services/specification.js'
import { parse } from '../../../../utils/validate.js'

Expand Down Expand Up @@ -56,8 +56,9 @@ export const postFromTemplate = [
} = parse(req, postFromTemplateSchema)

const modelCard = await createModelCardFromTemplate(req.user, modelId, templateId)
const model = await getModelById(req.user, modelId)

await audit.onCreateModelCard(req, modelId, modelCard)
await audit.onCreateModelCard(req, model, modelCard)

return res.json({
card: modelCard,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ exports[`routes > model > postModel > schema > 400 > no description 1`] = `
}
`;

exports[`routes > model > postModel > schema > audit > expected call 1`] = `"example"`;
exports[`routes > model > postModel > schema > audit > expected call 1`] = `
{
"settings": {
"mirror": {
"sourceModelId": "",
},
},
}
`;

exports[`routes > model > postModel > schema > audit > expected call 2`] = `
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ exports[`routes > model > postModel > template > 400 > no model template ID prov
}
`;

exports[`routes > model > postModel > template > audit > expected call 1`] = `"example"`;
exports[`routes > model > postModel > template > audit > expected call 1`] = `
{
"settings": {
"mirror": {
"sourceModelId": "",
},
},
}
`;

exports[`routes > model > postModel > template > audit > expected call 2`] = `
{
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions backend/test/routes/model/modelcard/postFromSchema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ vi.mock('../../../../src/services/model.js', async () => {
return {
...actual,
createModelCardFromSchema: vi.fn(() => ({ _id: 'test' })),
getModelById: vi.fn(() => ({ settings: { mirror: { sourceModelId: '' } } })),
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ vi.mock('../../../../src/services/model.js', async () => {
return {
...actual,
createModelCardFromTemplate: vi.fn(() => ({ _id: 'test' })),
getModelById: vi.fn(() => ({ settings: { mirror: { sourceModelId: '' } } })),
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ data:
// Show announcement banner at the bottom of the screen
announcement: {
enabled: {{ .Values.config.ui.announcement.enabled }},
text: {{ .Values.config.ui.announcement.text }},
startTimestamp: {{ .Values.config.ui.announcement.startTimestamp }}
text: '{{ .Values.config.ui.announcement.text }}',
startTimestamp: '{{ .Values.config.ui.announcement.startTimestamp }}',
},

// Contact details for the support team
Expand Down
Loading