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

Add inferencing routes #1097

Merged
merged 11 commits into from
Mar 4, 2024
Merged

Add inferencing routes #1097

merged 11 commits into from
Mar 4, 2024

Conversation

GB27247
Copy link
Member

@GB27247 GB27247 commented Feb 15, 2024

No description provided.

@GB27247 GB27247 requested review from a3957273 and JR40159 February 15, 2024 17:13
throw error
}

const auth = await authorisation.model(user, model, ModelAction.Update)
Copy link
Member

@JR40159 JR40159 Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good idea to move this check as high up as possible to avoid any unnecessary computation should the user not be authorised. At the very least, it should definitely be above the saving of the mongo document.

export const getInferenceSchema = z.object({
params: z.object({
modelId: z.string({
required_error: 'Must specify model id as param',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've started to move away from custom required errors here and just use the standard zod error

@@ -131,6 +137,11 @@ export abstract class BaseAuditConnector {
abstract onDeleteSchema(req: Request, schemaId: string)
abstract onUpdateSchema(req: Request, schema: SchemaDoc)

abstract onCreateInference(req: Request, inference: InferenceDoc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When auditing it would be useful to include enough information so that the resource (in this case the inference settings) are identifiable and retrievable. Judging by your get inference route, I'm guessing this would also require auditing the model ID?

}

const updatedInference = await Inference.findOneAndUpdate(
{ modelId: inference.modelId, image: inference.image, tag: inference.tag },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen here if you tried to update the inference to be the same as an existing one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, should you allow the user to update the model ID on the inference setting? You've only checked their permissions on the existing model and the route is specific for the existing model ID. I would assume that they would have to delete the existing one and make another request to create an inference service on another model.

export const postInferenceSchema = z.object({
params: z.object({
modelId: z.string({
required_error: 'Must specify model id as param',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove custom Zod error

throw NotFound(`The requested inferencing service was not found.`, { modelId, image, tag })
}

const auth = await authorisation.model(user, model, ModelAction.View)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This technically isn't requires because when you getModelById() this authorisation check takes place already. The method getInferenceByModel() seems to already to do this and rely on the authorisation check in getModelById(). I think you could make a case for keeping the identical authorisation check in this service as it adds clarity but be consistent with which option you decide.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some missing test cases here, use the vitest coverage report to help add the missing tests

@GB27247 GB27247 merged commit b1f1f3c into main Mar 4, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants