-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from aixplain/project-node-3
Project node 3
- Loading branch information
Showing
12 changed files
with
310 additions
and
50 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## [v0.0.2] - 2024-07-25 | ||
|
||
### Added | ||
- Added support for script nodes. | ||
### Changed | ||
|
||
### Fixed |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
__title__ = "model-interfaces" | ||
__description__ = "model-interfaces is the interface to host your models on aiXplain" | ||
__url__ = "https://github.com/aixplain/aixplain-models/tree/main/docs" | ||
__version__ = "0.0.2rc2" | ||
__version__ = "0.0.2rc3" | ||
__author__ = "Duraikrishna Selvaraju and Michael Lam" | ||
__author_email__ = "[email protected]" | ||
__license__ = "http://www.apache.org/licenses/LICENSE-2.0" | ||
|
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,45 @@ | ||
__author__='aiXplain' | ||
|
||
from abc import abstractmethod | ||
from kserve.model import Model | ||
from typing import Dict, List, Any | ||
from pydantic import validate_call | ||
|
||
from aixplain.model_interfaces.schemas.script.script_input import ScriptInput | ||
from aixplain.model_interfaces.schemas.script.script_output import ScriptOutput | ||
|
||
class ProjectNode(Model): | ||
def __init__(self, name, *args, **kwargs): | ||
super().__init__(name) | ||
self.name = name | ||
self.ready = False | ||
ready = self.load() | ||
print(f"Readiness: {ready}") | ||
assert ready | ||
|
||
@validate_call | ||
def predict(self, request: Dict[str, List[ScriptInput]], headers: Dict[str, str] = None) -> Dict[str, List[ScriptOutput]]: | ||
instances = request["instances"] | ||
results = [] | ||
for instance in instances: | ||
result = self.run_script(instance) | ||
results.append(result) | ||
predictions = { | ||
"predictions": results | ||
} | ||
return predictions | ||
|
||
@validate_call | ||
def run_script(self, input: Any) -> Any: | ||
raise NotImplementedError | ||
|
||
def load(self) -> bool: | ||
"""Load handler can be overridden to load the metric from storage | ||
``self.ready`` flag is used for metric health check | ||
:return: | ||
True if metric is ready, False otherwise | ||
:rtype: | ||
Bool | ||
""" | ||
self.ready = True | ||
return self.ready |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
__author__ = "aiXplain" | ||
|
||
from pydantic import BaseModel | ||
from typing import Dict | ||
|
||
class ScriptInput(BaseModel): | ||
"""The standardized schema of the aiXplain's Script API input. | ||
:param inputs: | ||
Input values to script. | ||
""" | ||
inputs: Dict |
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,12 @@ | ||
__author__ = "aiXplain" | ||
|
||
from pydantic import BaseModel | ||
from typing import Dict | ||
|
||
class ScriptOutput(BaseModel): | ||
"""The standardized schema of the aiXplain's Script API input. | ||
:param inputs: | ||
Input values to script. | ||
""" | ||
outputs: Dict |
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.