-
Notifications
You must be signed in to change notification settings - Fork 164
feat(BA-2677): Implement artifact_verifier type plugin in storage-proxy
#6258
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0c5a355
draft
jopemachine fdbe262
feat: Inject model path
jopemachine 26d0825
WIP
jopemachine 88c997a
WIP
jopemachine 49ca446
fix: Reflect feedback
jopemachine 31cd7c7
fix: Broken CI
jopemachine 374d715
fix: Add missing `NotImplementedError` raise
jopemachine f87c22e
fix: Add missing generic type
jopemachine 308bdfe
docs: Rename
jopemachine d68a67d
refactor: Remove duplicated codes
jopemachine 70ac936
feat: Send ModelVerifyingEvent event when entering VerifyStep
jopemachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Implement `artifact_verifier` type plugin in storage-proxy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| from abc import ABC, abstractmethod | ||
| from dataclasses import dataclass | ||
| from typing import Any | ||
|
|
||
| from ai.backend.common.data.storage.registries.types import ModelTarget | ||
| from ai.backend.common.data.storage.types import ArtifactStorageImportStep | ||
| from ai.backend.common.types import StreamReader | ||
|
|
||
|
|
||
| class AbstractStorage(ABC): | ||
| @abstractmethod | ||
| async def stream_upload( | ||
| self, | ||
| filepath: str, | ||
| data_stream: StreamReader, | ||
| ) -> None: | ||
| raise NotImplementedError | ||
|
|
||
| @abstractmethod | ||
| async def stream_download(self, filepath: str) -> StreamReader: | ||
| raise NotImplementedError | ||
|
|
||
| @abstractmethod | ||
| async def delete_file(self, filepath: str) -> None: | ||
| raise NotImplementedError | ||
|
|
||
| @abstractmethod | ||
| # TODO: Remove Any and define a proper return type | ||
| async def get_file_info(self, filepath: str) -> Any: | ||
| raise NotImplementedError | ||
|
|
||
|
|
||
| class AbstractStoragePool(ABC): | ||
| """Abstract base class for storage pool interface""" | ||
|
|
||
| @abstractmethod | ||
| def get_storage(self, name: str) -> AbstractStorage: | ||
| """Get storage by name""" | ||
| raise NotImplementedError | ||
|
|
||
| @abstractmethod | ||
| def add_storage(self, name: str, storage: AbstractStorage) -> None: | ||
| """Add a storage to the pool""" | ||
| raise NotImplementedError | ||
|
|
||
| @abstractmethod | ||
| def remove_storage(self, name: str) -> None: | ||
| """Remove a storage from the pool""" | ||
| raise NotImplementedError | ||
|
|
||
| @abstractmethod | ||
| def list_storages(self) -> list[str]: | ||
| """List all storage names in the pool""" | ||
| raise NotImplementedError | ||
|
|
||
| @abstractmethod | ||
| def has_storage(self, name: str) -> bool: | ||
| """Check if storage exists in the pool""" | ||
| raise NotImplementedError | ||
|
|
||
|
|
||
| @dataclass | ||
| class ImportStepContext: | ||
| """Context shared across import steps""" | ||
|
|
||
| model: ModelTarget | ||
| registry_name: str | ||
| storage_pool: AbstractStoragePool | ||
| storage_step_mappings: dict[ArtifactStorageImportStep, str] | ||
| step_metadata: dict[str, Any] # For passing data between steps | ||
jopemachine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| from ai.backend.storage.plugin import AbstractArtifactVerifierPlugin | ||
|
|
||
|
|
||
| class ArtifactVerifierContext: | ||
| _verifiers: dict[str, AbstractArtifactVerifierPlugin] | ||
|
|
||
| def __init__(self) -> None: | ||
| self._verifiers = {} | ||
|
|
||
| def load_verifiers(self, verifiers: dict[str, AbstractArtifactVerifierPlugin]) -> None: | ||
| self._verifiers.update(verifiers) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -456,3 +456,29 @@ def error_code(cls) -> ErrorCode: | |
| operation=ErrorOperation.GENERIC, | ||
| error_detail=ErrorDetail.BAD_REQUEST, | ||
| ) | ||
|
|
||
|
|
||
| class ArtifactVerifyStorageTypeInvalid(BackendAIError, web.HTTPBadRequest): | ||
| error_type = "https://api.backend.ai/probs/storage/artifact/verify/storage-type/invalid" | ||
| error_title = "Artifact Verify Storage Type Invalid" | ||
|
|
||
| @classmethod | ||
| def error_code(cls) -> ErrorCode: | ||
| return ErrorCode( | ||
| domain=ErrorDomain.STORAGE_PROXY, | ||
| operation=ErrorOperation.GENERIC, | ||
| error_detail=ErrorDetail.BAD_REQUEST, | ||
| ) | ||
|
|
||
|
|
||
| class ArtifactVerificationFailedError(BackendAIError, web.HTTPBadRequest): | ||
| error_type = "https://api.backend.ai/probs/storage/artifact/verification/failed" | ||
| error_title = "Artifact Verification Failed" | ||
|
|
||
| @classmethod | ||
| def error_code(cls) -> ErrorCode: | ||
| return ErrorCode( | ||
| domain=ErrorDomain.STORAGE_PROXY, | ||
| operation=ErrorOperation.GENERIC, | ||
| error_detail=ErrorDetail.BAD_REQUEST, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if it's correct to set the status code for this error to 400. |
||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.