Skip to content

Commit 008c489

Browse files
committed
feat(BA-4037): Implement ImageV2 GraphQL API
- Add ImageV2 GQL types with structured fields (types.py) - Implement ImageV2 query resolvers (resolver.py) - Add ImageV2 fetcher with pagination support (fetcher.py) - Update GraphQL schema with ImageV2 types - Add news fragment and update BEP-1038 docs
1 parent 79cb0e0 commit 008c489

20 files changed

Lines changed: 1494 additions & 22 deletions

File tree

changes/8396.feature.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Define `ImageV2` GraphQL schema types with structured fields

docs/manager/graphql-reference/supergraph.graphql

Lines changed: 277 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4076,6 +4076,25 @@ type ImageConnection
40764076
count: Int
40774077
}
40784078

4079+
"""
4080+
Added in 26.2.0.
4081+
4082+
Relay-style connection for paginated image queries.
4083+
Includes total count for pagination UI.
4084+
"""
4085+
type ImageConnectionV2
4086+
@join__type(graph: STRAWBERRY)
4087+
{
4088+
"""Pagination data for this connection"""
4089+
pageInfo: PageInfo!
4090+
4091+
"""Contains the nodes in this connection"""
4092+
edges: [ImageV2Edge!]!
4093+
4094+
"""Total count of images matching the query."""
4095+
count: Int!
4096+
}
4097+
40794098
"""Added in 25.3.0. A Relay edge containing a `Image` and its cursor."""
40804099
type ImageEdge
40814100
@join__type(graph: GRAPHENE)
@@ -4087,13 +4106,97 @@ type ImageEdge
40874106
cursor: String!
40884107
}
40894108

4109+
"""
4110+
Added in 26.2.0.
4111+
4112+
Filter options for images based on various criteria such as status,
4113+
name, and architecture.
4114+
4115+
Supports logical operations (AND, OR, NOT) for complex filtering scenarios.
4116+
"""
4117+
input ImageFilterGQL
4118+
@join__type(graph: STRAWBERRY)
4119+
{
4120+
status: [ImageStatus!] = null
4121+
name: StringFilter = null
4122+
architecture: StringFilter = null
4123+
AND: [ImageFilterGQL!] = null
4124+
OR: [ImageFilterGQL!] = null
4125+
NOT: [ImageFilterGQL!] = null
4126+
}
4127+
4128+
"""
4129+
Added in 26.2.0.
4130+
4131+
Identity information for an image.
4132+
Contains the canonical name, namespace, and architecture.
4133+
"""
4134+
type ImageIdentityInfo
4135+
@join__type(graph: STRAWBERRY)
4136+
{
4137+
"""Full canonical name (e.g., 'cr.backend.ai/stable/python:3.9')."""
4138+
canonicalName: String!
4139+
4140+
"""Image namespace/path within the registry (e.g., 'stable/python')."""
4141+
namespace: String!
4142+
4143+
"""CPU architecture (e.g., 'x86_64', 'aarch64')."""
4144+
architecture: String!
4145+
}
4146+
40904147
"""Added in 25.19.0"""
40914148
input ImageInput
40924149
@join__type(graph: STRAWBERRY)
40934150
{
40944151
id: ID!
40954152
}
40964153

4154+
"""
4155+
Added in 26.2.0.
4156+
4157+
A key-value pair representing a Docker label on the image.
4158+
Labels contain metadata about the image such as maintainer, version, etc.
4159+
"""
4160+
type ImageLabelEntry
4161+
@join__type(graph: STRAWBERRY)
4162+
{
4163+
"""The label key (e.g., 'maintainer')."""
4164+
key: String!
4165+
4166+
"""The label value."""
4167+
value: String!
4168+
}
4169+
4170+
"""
4171+
Added in 26.2.0.
4172+
4173+
Metadata information for an image.
4174+
Contains tags, labels, digest, size, status, and creation timestamp.
4175+
"""
4176+
type ImageMetadataInfo
4177+
@join__type(graph: STRAWBERRY)
4178+
{
4179+
"""
4180+
Parsed tag components from the image reference (e.g., python=3.11, cuda=12.1).
4181+
"""
4182+
tags: [ImageTagEntry!]!
4183+
4184+
"""Docker labels."""
4185+
labels: [ImageLabelEntry!]!
4186+
4187+
"""Config digest (image hash) for verification."""
4188+
digest: String
4189+
4190+
"""Image size in bytes."""
4191+
sizeBytes: Int!
4192+
4193+
"""Image status (ALIVE or DELETED)."""
4194+
status: ImageStatus!
4195+
4196+
"""Timestamp when the image was created/registered."""
4197+
createdAt: DateTime
4198+
}
4199+
40974200
type ImageNode implements Node
40984201
@join__implements(graph: GRAPHENE, interface: "Node")
40994202
@join__type(graph: GRAPHENE, key: "id")
@@ -4149,6 +4252,57 @@ type ImageNode implements Node
41494252
type: ImageType @join__field(graph: GRAPHENE)
41504253
}
41514254

4255+
"""
4256+
Added in 26.2.0.
4257+
4258+
Specifies the field and direction for ordering images in queries.
4259+
"""
4260+
input ImageOrderByGQL
4261+
@join__type(graph: STRAWBERRY)
4262+
{
4263+
field: ImageOrderField!
4264+
direction: OrderDirection! = ASC
4265+
}
4266+
4267+
"""
4268+
Added in 26.2.0.
4269+
4270+
Fields available for ordering image queries.
4271+
"""
4272+
enum ImageOrderField
4273+
@join__type(graph: STRAWBERRY)
4274+
{
4275+
NAME @join__enumValue(graph: STRAWBERRY)
4276+
CREATED_AT @join__enumValue(graph: STRAWBERRY)
4277+
}
4278+
4279+
"""
4280+
Added in 26.2.0.
4281+
4282+
Permission types for image operations.
4283+
"""
4284+
enum ImagePermission
4285+
@join__type(graph: STRAWBERRY)
4286+
{
4287+
READ_ATTRIBUTE @join__enumValue(graph: STRAWBERRY)
4288+
UPDATE_ATTRIBUTE @join__enumValue(graph: STRAWBERRY)
4289+
CREATE_CONTAINER @join__enumValue(graph: STRAWBERRY)
4290+
FORGET_IMAGE @join__enumValue(graph: STRAWBERRY)
4291+
}
4292+
4293+
"""
4294+
Added in 26.2.0.
4295+
4296+
Permission information for an image.
4297+
Contains the list of permissions the current user has on this image.
4298+
"""
4299+
type ImagePermissionInfo
4300+
@join__type(graph: STRAWBERRY)
4301+
{
4302+
"""List of permissions the user has on this image."""
4303+
permissions: [ImagePermission!]!
4304+
}
4305+
41524306
"""
41534307
Added in 25.3.0. One of ['read_attribute', 'update_attribute', 'create_container', 'forget_image'].
41544308
"""
@@ -4163,12 +4317,64 @@ input ImageRefType
41634317
architecture: String
41644318
}
41654319

4320+
"""
4321+
Added in 26.2.0.
4322+
4323+
Runtime requirements information for an image.
4324+
Contains resource limits and supported accelerators.
4325+
"""
4326+
type ImageRequirementsInfo
4327+
@join__type(graph: STRAWBERRY)
4328+
{
4329+
"""Resource slot limits (cpu, memory, accelerators, etc.)."""
4330+
resourceLimits: [ImageResourceLimit!]!
4331+
4332+
"""List of supported accelerator types (e.g., 'cuda', 'rocm')."""
4333+
supportedAccelerators: [String!]!
4334+
}
4335+
4336+
"""
4337+
Added in 26.2.0.
4338+
4339+
Resource limit specification for an image.
4340+
Defines minimum and maximum values for a resource slot.
4341+
"""
4342+
type ImageResourceLimit
4343+
@join__type(graph: STRAWBERRY)
4344+
{
4345+
"""Resource slot name (e.g., 'cpu', 'mem', 'cuda.shares')."""
4346+
key: String!
4347+
4348+
"""Minimum required amount."""
4349+
min: String!
4350+
4351+
"""Maximum allowed amount."""
4352+
max: String!
4353+
}
4354+
41664355
"""Added in 25.4.0."""
41674356
enum ImageStatus
41684357
@join__type(graph: GRAPHENE)
4358+
@join__type(graph: STRAWBERRY)
4359+
{
4360+
ALIVE @join__enumValue(graph: GRAPHENE) @join__enumValue(graph: STRAWBERRY)
4361+
DELETED @join__enumValue(graph: GRAPHENE) @join__enumValue(graph: STRAWBERRY)
4362+
}
4363+
4364+
"""
4365+
Added in 26.2.0.
4366+
4367+
A key-value pair representing a parsed tag component.
4368+
Tags are extracted from the image reference (e.g., py311, cuda12.1).
4369+
"""
4370+
type ImageTagEntry
4371+
@join__type(graph: STRAWBERRY)
41694372
{
4170-
ALIVE @join__enumValue(graph: GRAPHENE)
4171-
DELETED @join__enumValue(graph: GRAPHENE)
4373+
"""The tag key (e.g., 'python', 'cuda')."""
4374+
key: String!
4375+
4376+
"""The tag value (e.g., '3.11', '12.1')."""
4377+
value: String!
41724378
}
41734379

41744380
"""Added in 25.12.0."""
@@ -4180,6 +4386,52 @@ enum ImageType
41804386
SERVICE @join__enumValue(graph: GRAPHENE)
41814387
}
41824388

4389+
"""
4390+
Added in 26.2.0.
4391+
4392+
Represents a container image in Backend.AI.
4393+
4394+
Images are container specifications that define the runtime environment
4395+
for compute sessions. Each image has identity information, metadata,
4396+
resource requirements, and permission settings.
4397+
4398+
This is the V2 implementation using Strawberry GraphQL with Relay-style
4399+
connections as part of BEP-1010 migration.
4400+
"""
4401+
type ImageV2 implements Node
4402+
@join__implements(graph: STRAWBERRY, interface: "Node")
4403+
@join__type(graph: STRAWBERRY)
4404+
{
4405+
"""The Globally Unique ID of this object"""
4406+
id: ID!
4407+
4408+
"""Image identity information (name, architecture)."""
4409+
identity: ImageIdentityInfo!
4410+
4411+
"""Image metadata (labels, digest, size, status, created_at)."""
4412+
metadata: ImageMetadataInfo!
4413+
4414+
"""Runtime requirements (supported_accelerators)."""
4415+
requirements: ImageRequirementsInfo!
4416+
4417+
"""Permission info for the current user. May be null."""
4418+
permission: ImagePermissionInfo
4419+
4420+
"""UUID of the container registry where this image is stored."""
4421+
registryId: UUID!
4422+
}
4423+
4424+
"""An edge in a connection."""
4425+
type ImageV2Edge
4426+
@join__type(graph: STRAWBERRY)
4427+
{
4428+
"""A cursor for use in pagination"""
4429+
cursor: String!
4430+
4431+
"""The item at the end of the edge"""
4432+
node: ImageV2!
4433+
}
4434+
41834435
"""
41844436
Added in 25.14.0.
41854437
@@ -7502,6 +7754,29 @@ type Query
75027754

75037755
"""List route history (superadmin only)"""
75047756
routeHistories(filter: RouteHistoryFilter = null, orderBy: [RouteHistoryOrderBy!] = null, before: String = null, after: String = null, first: Int = null, last: Int = null, limit: Int = null, offset: Int = null): RouteHistoryConnection! @join__field(graph: STRAWBERRY) @deprecated(reason: "Use admin_route_histories instead. This API will be removed after v26.3.0. See BEP-1041 for migration guide.")
7757+
7758+
"""
7759+
Added in 26.2.0.
7760+
7761+
Retrieve a specific image by its ID.
7762+
7763+
Returns detailed information about the image including its identity,
7764+
metadata, resource requirements, and permission settings.
7765+
"""
7766+
imageV2(id: ID!): ImageV2 @join__field(graph: STRAWBERRY)
7767+
7768+
"""
7769+
Added in 26.2.0.
7770+
7771+
Query images with optional filtering, ordering, and pagination.
7772+
7773+
Returns container images available in the system. Images are container
7774+
specifications that define runtime environments for compute sessions.
7775+
7776+
Use filters to narrow down results by status, name, or architecture.
7777+
Supports both cursor-based and offset-based pagination.
7778+
"""
7779+
imagesV2(filter: ImageFilterGQL = null, orderBy: [ImageOrderByGQL!] = null, before: String = null, after: String = null, first: Int = null, last: Int = null, limit: Int = null, offset: Int = null): ImageConnectionV2! @join__field(graph: STRAWBERRY)
75057780
}
75067781

75077782
type QuotaDetails

0 commit comments

Comments
 (0)