-
Notifications
You must be signed in to change notification settings - Fork 380
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
[#5889] feat(client-python): Add model management Python API #6009
Open
jerryshao
wants to merge
4
commits into
apache:main
Choose a base branch
from
jerryshao:issue-5889
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,852
−76
Open
Changes from all commits
Commits
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 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 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,74 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from typing import Dict, Optional | ||
from abc import abstractmethod | ||
|
||
from gravitino.api.auditable import Auditable | ||
|
||
|
||
class Model(Auditable): | ||
"""An interface representing an ML model under a schema `Namespace`. A model is a metadata | ||
object that represents the model artifact in ML. Users can register a model object in Gravitino | ||
to manage the model metadata. The typical use case is to manage the model in ML lifecycle with a | ||
unified way in Gravitino, and access the model artifact with a unified identifier. Also, with | ||
the model registered in Gravitino, users can govern the model with Gravitino's unified audit, | ||
tag, and role management. | ||
|
||
The difference of Model and tabular data is that the model is schema-free, and the main | ||
property of the model is the model artifact URL. The difference compared to the fileset is that | ||
the model is versioned, and the model object contains the version information. | ||
""" | ||
|
||
@abstractmethod | ||
def name(self) -> str: | ||
""" | ||
Returns: | ||
Name of the model object. | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def comment(self) -> Optional[str]: | ||
"""The comment of the model object. This is the general description of the model object. | ||
User can still add more detailed information in the model version. | ||
|
||
Returns: | ||
The comment of the model object. None is returned if no comment is set. | ||
""" | ||
pass | ||
|
||
def properties(self) -> Dict[str, str]: | ||
"""The properties of the model object. The properties are key-value pairs that can be used | ||
to store additional information of the model object. The properties are optional. | ||
|
||
Users can still specify the properties in the model version for different information. | ||
|
||
Returns: | ||
The properties of the model object. An empty dictionary is returned if no properties are set. | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def latest_version(self) -> int: | ||
"""The latest version of the model object. The latest version is the version number of the | ||
latest model checkpoint / snapshot that is linked to the registered model. | ||
|
||
Returns: | ||
The latest version of the model object. | ||
""" | ||
pass |
This file contains 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,85 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
|
||
from abc import abstractmethod | ||
from typing import Optional, Dict, List | ||
from gravitino.api.auditable import Auditable | ||
|
||
|
||
class ModelVersion(Auditable): | ||
""" | ||
An interface representing a single model checkpoint under a model `Model`. A model version | ||
is a snapshot at a point of time of a model artifact in ML. Users can link a model version to a | ||
registered model. | ||
""" | ||
|
||
@abstractmethod | ||
def version(self) -> int: | ||
""" | ||
The version of this model object. The version number is an integer number starts from 0. Each | ||
time the model checkpoint / snapshot is linked to the registered, the version number will be | ||
increased by 1. | ||
|
||
Returns: | ||
The version of the model object. | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def comment(self) -> Optional[str]: | ||
""" | ||
The comment of this model version. This comment can be different from the comment of the model | ||
to provide more detailed information about this version. | ||
|
||
Returns: | ||
The comment of the model version. None is returned if no comment is set. | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def aliases(self) -> List[str]: | ||
""" | ||
The aliases of this model version. The aliases are the alternative names of the model version. | ||
The aliases are optional. The aliases are unique for a model version. If the alias is already | ||
set to one model version, it cannot be set to another model version. | ||
|
||
Returns: | ||
The aliases of the model version. | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def uri(self) -> str: | ||
""" | ||
The URI of the model artifact. The URI is the location of the model artifact. The URI can be a | ||
file path or a remote URI. | ||
|
||
Returns: | ||
The URI of the model artifact. | ||
""" | ||
pass | ||
|
||
def properties(self) -> Dict[str, str]: | ||
""" | ||
The properties of the model version. The properties are key-value pairs that can be used to | ||
store additional information of the model version. The properties are optional. | ||
|
||
Returns: | ||
The properties of the model version. An empty dictionary is returned if no properties are set. | ||
""" | ||
pass |
File renamed without changes.
This file contains 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 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 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we want to use string as version number for generic scenarios.
If this means an internal representation, maybe we want to call it something like
revision
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the current design, version is a self-incremented integer version number, in the meantime, we also have "aliases" for the convenience of use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.