lablup / lablup/backend.ai

Implement `ImageV2` strawberry GQL mutations

Open
#8,416 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
17h 7m
Merged PRs (30d)
358

Description

## Motivation

The [http://Backend.AI](http://Backend.AI) project is migrating from Graphene to Strawberry for GraphQL implementation (BEP-1010). As part of this migration, image-related mutations need to be ported to
the new Strawberry schema to provide a consistent API experience. The existing Graphene mutations use reference-based lookups (canonical + architecture), which are being
modernized to use explicit ImageID-based operations for better clarity and performance.

## Required Features

- **ForgetImageById**: Mark an image as deleted (soft delete) by its UUID
- **PurgeImageById**: Permanently remove an image from the database, with optional registry untag support (HarborV2)
- **AliasImageById**: Create an alias for an image using its UUID instead of canonical reference
- **DealiasImage**: Remove an existing alias from an image
- **ClearImageResourceLimitById**: Clear custom resource limits for an image using its UUID

All mutations should:

- Use Strawberry input types following the established pattern
- Return appropriate result types with the affected image data
- Include proper GraphQL descriptions for schema documentation
- Follow the ID-based approach consistent with ImageV2 query endpoints

## Impact

- src/ai/backend/manager/api/gql/image/mutations.py - New file containing mutation definitions
- src/ai/backend/manager/api/gql/image/**init**.py - Export new mutations
- src/ai/backend/manager/api/gql/schema.py - Register mutations in the Mutation class
- GraphQL schema documentation (v2-schema.graphql, supergraph.graphql) - Schema dump updates

## Testing Scenarios

1. **ForgetImageById**
- Verify image status changes to DELETED after mutation
- Verify the returned image data reflects the new status
1. **PurgeImageById**
- Verify image is completely removed from database
- Verify remove_from_registry option triggers untag action for HarborV2 registries
- Verify appropriate error handling for non-HarborV2 registries
1. **AliasImageById**
- Verify alias is created and associated with the correct image
- Verify duplicate alias creation returns appropriate error
1. **DealiasImage**
- Verify alias is removed successfully
- Verify non-existent alias returns appropriate error
1. **ClearImageResourceLimitById**
- Verify custom resource limits are cleared
- Verify image reverts to default label-based limits

JIRA Issue: BA-4141

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.