- Notifications
You must be signed in to change notification settings - Fork 60
ODSC 39392/triton #128
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
ODSC 39392/triton #128
Changes from all commits
Commits
Show all changes
13 commits Select commit Hold shift + click to select a range
e40302d commit the code for triton
e242369 remove the blank
072a048 ODSC-39392: fix the code based on the comments
429d4ea add implementation for predict
350f0ea adding unit test
5985af2 Merge branch 'develop' into ODSC-39392/triton
190509b fix unit test
35fe0d2 Merge branch 'ODSC-39392/triton' of github.com:oracle/accelerated-dat…
2f0758f ODSC-39392: resolve the comments
3c32175 fix based on the comment
708ce2f Merge branch 'develop' of github.com:oracle/accelerated-data-science …
9fdb1ff ODSC-39392: fix the test
b66c02f Merge branch 'develop' into ODSC-39392/triton
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
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 |
|---|---|---|
| | @@ -17,7 +17,6 @@ | |
| from ads.common import auth as authutil | ||
| import pandas as pd | ||
| from ads.model.serde.model_input import JsonModelInputSERDE | ||
| from ads.common import auth, oci_client | ||
| from ads.common.oci_logging import ( | ||
| LOG_INTERVAL, | ||
| LOG_RECORDS_LIMIT, | ||
| | @@ -63,6 +62,7 @@ | |
| | ||
| MODEL_DEPLOYMENT_KIND = "deployment" | ||
| MODEL_DEPLOYMENT_TYPE = "modelDeployment" | ||
| MODEL_DEPLOYMENT_INFERENCE_SERVER_TRITON = "TRITON" | ||
| | ||
| MODEL_DEPLOYMENT_INSTANCE_SHAPE = "VM.Standard.E4.Flex" | ||
| MODEL_DEPLOYMENT_INSTANCE_OCPUS = 1 | ||
| | @@ -828,6 +828,8 @@ def predict( | |
| data: Any = None, | ||
| serializer: "ads.model.ModelInputSerializer" = model_input_serializer, | ||
| auto_serialize_data: bool = False, | ||
| model_name: str = None, | ||
| model_version: str = None, | ||
| **kwargs, | ||
| ) -> dict: | ||
| """Returns prediction of input data run against the model deployment endpoint. | ||
| | @@ -860,6 +862,10 @@ def predict( | |
| If `auto_serialize_data=False`, `data` required to be bytes or json serializable | ||
| and `json_input` required to be json serializable. If `auto_serialize_data` set | ||
| to True, data will be serialized before sending to model deployment endpoint. | ||
| model_name: str | ||
| Defaults to None. When the `Inference_server="triton"`, the name of the model to invoke. | ||
| model_version: str | ||
| Defaults to None. When the `Inference_server="triton"`, the version of the model to invoke. | ||
| kwargs: | ||
| content_type: str | ||
| Used to indicate the media type of the resource. | ||
| | @@ -878,6 +884,7 @@ def predict( | |
| "signer": signer, | ||
| "content_type": kwargs.get("content_type", None), | ||
| } | ||
| header.update(kwargs.pop("headers", {})) | ||
| | ||
| if data is None and json_input is None: | ||
| raise AttributeError( | ||
| | @@ -916,9 +923,13 @@ def predict( | |
| raise TypeError( | ||
| "`data` is not bytes or json serializable. Set `auto_serialize_data` to `True` to serialize the input data." | ||
| ) | ||
| | ||
| if model_name and model_version: | ||
| header['model-name'] = model_name | ||
| header['model-version'] = model_version | ||
| elif bool(model_version) ^ bool(model_name): | ||
| 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. We can rearrange this if/elif - | ||
| raise ValueError("`model_name` and `model_version` have to be provided together.") | ||
| prediction = send_request( | ||
| data=data, endpoint=endpoint, is_json_payload=is_json_payload, header=header | ||
| data=data, endpoint=endpoint, is_json_payload=is_json_payload, header=header, | ||
| ) | ||
| return prediction | ||
| | ||
| | @@ -1390,6 +1401,10 @@ def _update_from_oci_model(self, oci_model_instance) -> "ModelDeployment": | |
| infrastructure.CONST_WEB_CONCURRENCY, | ||
| runtime.env.get("WEB_CONCURRENCY", None), | ||
| ) | ||
| if runtime.env.get("CONTAINER_TYPE", None) == MODEL_DEPLOYMENT_INFERENCE_SERVER_TRITON: | ||
| runtime.set_spec( | ||
| runtime.CONST_INFERENCE_SERVER, MODEL_DEPLOYMENT_INFERENCE_SERVER_TRITON.lower() | ||
| ) | ||
| | ||
| self.set_spec(self.CONST_INFRASTRUCTURE, infrastructure) | ||
| self.set_spec(self.CONST_RUNTIME, runtime) | ||
| | @@ -1566,6 +1581,9 @@ def _build_model_deployment_configuration_details(self) -> Dict: | |
| infrastructure.web_concurrency | ||
| ) | ||
| runtime.set_spec(runtime.CONST_ENV, environment_variables) | ||
| if hasattr(runtime, "inference_server") and runtime.inference_server and runtime.inference_server.upper() == MODEL_DEPLOYMENT_INFERENCE_SERVER_TRITON: | ||
| environment_variables["CONTAINER_TYPE"] = MODEL_DEPLOYMENT_INFERENCE_SERVER_TRITON | ||
| runtime.set_spec(runtime.CONST_ENV, environment_variables) | ||
| environment_configuration_details = { | ||
| runtime.CONST_ENVIRONMENT_CONFIG_TYPE: runtime.environment_config_type, | ||
| runtime.CONST_ENVIRONMENT_VARIABLES: runtime.env, | ||
| | ||
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
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.
Shall we pop
signerfor dry_run as well?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.
done