Skip to content

Commit 67de45c

Browse files
committed
wip
1 parent 5b884aa commit 67de45c

3 files changed

Lines changed: 64 additions & 4 deletions

File tree

docs/manager/graphql-reference/supergraph.graphql

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,18 @@ type ArtifactStorage
10041004
storageId: ID!
10051005

10061006
"""The type of the artifact storage"""
1007-
type: String!
1007+
type: ArtifactStorageType!
1008+
}
1009+
1010+
"""
1011+
Added in 26.2.0. The type of artifact storage backend. OBJECT_STORAGE: Object storage (e.g., S3-compatible). VFS_STORAGE: Virtual folder storage. GIT_LFS: Git LFS storage.
1012+
"""
1013+
enum ArtifactStorageType
1014+
@join__type(graph: STRAWBERRY)
1015+
{
1016+
OBJECT_STORAGE @join__enumValue(graph: STRAWBERRY)
1017+
VFS_STORAGE @join__enumValue(graph: STRAWBERRY)
1018+
GIT_LFS @join__enumValue(graph: STRAWBERRY)
10081019
}
10091020

10101021
enum ArtifactType

docs/manager/graphql-reference/v2-schema.graphql

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,16 @@ type ArtifactStorage {
715715
storageId: ID!
716716

717717
"""The type of the artifact storage"""
718-
type: String!
718+
type: ArtifactStorageType!
719+
}
720+
721+
"""
722+
Added in 26.2.0. The type of artifact storage backend. OBJECT_STORAGE: Object storage (e.g., S3-compatible). VFS_STORAGE: Virtual folder storage. GIT_LFS: Git LFS storage.
723+
"""
724+
enum ArtifactStorageType {
725+
OBJECT_STORAGE
726+
VFS_STORAGE
727+
GIT_LFS
719728
}
720729

721730
enum ArtifactType {

src/ai/backend/manager/api/gql/artifact_storage.py

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from __future__ import annotations
22

33
import uuid
4+
from enum import StrEnum
45
from typing import Self
56

67
import strawberry
78
from strawberry import ID, UNSET, Info
89

10+
from ai.backend.common.data.storage.types import ArtifactStorageType
911
from ai.backend.manager.data.artifact_storages.types import (
1012
ArtifactStorageData,
1113
ArtifactStorageUpdaterSpec,
@@ -20,22 +22,60 @@
2022
from .types import StrawberryGQLContext
2123

2224

25+
@strawberry.enum(
26+
name="ArtifactStorageType",
27+
description=(
28+
"Added in 26.2.0. The type of artifact storage backend. "
29+
"OBJECT_STORAGE: Object storage (e.g., S3-compatible). "
30+
"VFS_STORAGE: Virtual folder storage. "
31+
"GIT_LFS: Git LFS storage."
32+
),
33+
)
34+
class ArtifactStorageTypeGQL(StrEnum):
35+
"""Artifact storage type enum."""
36+
37+
OBJECT_STORAGE = "object_storage"
38+
VFS_STORAGE = "vfs_storage"
39+
GIT_LFS = "git_lfs"
40+
41+
@classmethod
42+
def from_internal(cls, internal_type: ArtifactStorageType) -> ArtifactStorageTypeGQL:
43+
"""Convert internal ArtifactStorageType to GraphQL enum."""
44+
match internal_type:
45+
case ArtifactStorageType.OBJECT_STORAGE:
46+
return cls.OBJECT_STORAGE
47+
case ArtifactStorageType.VFS_STORAGE:
48+
return cls.VFS_STORAGE
49+
case ArtifactStorageType.GIT_LFS:
50+
return cls.GIT_LFS
51+
52+
def to_internal(self) -> ArtifactStorageType:
53+
"""Convert GraphQL enum to internal ArtifactStorageType."""
54+
match self:
55+
case ArtifactStorageTypeGQL.OBJECT_STORAGE:
56+
return ArtifactStorageType.OBJECT_STORAGE
57+
case ArtifactStorageTypeGQL.VFS_STORAGE:
58+
return ArtifactStorageType.VFS_STORAGE
59+
case ArtifactStorageTypeGQL.GIT_LFS:
60+
return ArtifactStorageType.GIT_LFS
61+
62+
2363
@strawberry.type(description="Added in 26.2.0. Artifact storage metadata")
2464
class ArtifactStorage:
2565
id: ID = strawberry.field(description="The ID of the artifact storage")
2666
name: str = strawberry.field(description="The name of the artifact storage")
2767
storage_id: ID = strawberry.field(
2868
description="The ID of the underlying storage (ObjectStorage or VFSStorage)"
2969
)
30-
type: str = strawberry.field(description="The type of the artifact storage")
70+
type: ArtifactStorageTypeGQL = strawberry.field(description="The type of the artifact storage")
3171

3272
@classmethod
3373
def from_dataclass(cls, data: ArtifactStorageData) -> Self:
3474
return cls(
3575
id=ID(str(data.id)),
3676
name=data.name,
3777
storage_id=ID(str(data.storage_id)),
38-
type=data.type.value,
78+
type=ArtifactStorageTypeGQL.from_internal(data.type),
3979
)
4080

4181

0 commit comments

Comments
 (0)