-
Notifications
You must be signed in to change notification settings - Fork 40
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
ODSC 29065/Model Deployment opctl for local dev #134
Conversation
Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application. When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated. If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public. |
ads/opctl/backend/local.py
Outdated
f"Conda pack {conda_pack_path} not found. Please run `ads opctl conda create` or `ads opctl conda install`." | ||
) | ||
if install: | ||
logger.info(f"Downloading the conda pack {slug} to this conda pack {conda_pack_folder}. If this conda pack is already installed locally in a different location, pass in `conda_pack_folder` to avoid downloading it again.") |
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?
Downloading a `{slug}` to the `{conda_pack_folder}`. If this conda pack is already installed locally in a different location, pass in `conda_pack_folder` to avoid downloading it again.
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.
yup. fixed.
ads/opctl/backend/base.py
Outdated
self.config = config | ||
self.oci_auth = get_signer( | ||
self.oci_auth = create_signer( | ||
config["execution"].get("auth"), |
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.
This is a good change :)
ads/opctl/backend/base.py
Outdated
|
||
def predict(self) -> None: | ||
""" | ||
Deactivate a remote service. |
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.
Wrong description?
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.
fixed
@@ -170,3 +172,11 @@ def watch(self) -> None: | |||
model_deployment.watch( | |||
log_type=log_type, interval=interval, log_filter=log_filter | |||
) | |||
|
|||
def predict(self) -> None: |
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.
Could you add a description for this method?
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.
fixed.
ads/opctl/backend/local.py
Outdated
from ads.common.decorator.runtime_dependency import (OptionalDependency, | ||
runtime_dependency) | ||
from ads.common.oci_client import OCIClientFactory | ||
from ads.model.datascience_model import DataScienceModel |
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.
NIT: Unused?
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.
removed
ads/opctl/backend/local.py
Outdated
@@ -54,6 +58,17 @@ def __init__(self, config: Dict) -> None: | |||
dictionary of configurations | |||
""" | |||
self.config = config | |||
self.auth_type = config["execution"].get("auth") |
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.
We are doing the same and the same steps in every backend, maybe lines 61->71 can be moved to the base class?
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.
actually, i realized I should not add it to localbackend since it will affect local pipeline backend and etc. So I moved it to only LocalModeDeploymentBackend.
ads/opctl/backend/local.py
Outdated
if not compartment_id or not project_id: | ||
raise ValueError("`compartment_id` and `project_id` must be provided.") | ||
|
||
extra_cmd = "/opt/ds/model/deployed_model/ " + data + " " + compartment_id + " " + project_id |
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.
Looks like the /opt/ds/model/deployed_model/ is used in many places. I would suggest to move it to the constants.
extra_cmd = f"/opt/ds/model/deployed_model/ {data} {compartment_id} {project_id}"
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
ads/opctl/backend/local.py
Outdated
custom_metadata = ModelCustomMetadata._from_oci_metadata(response.data.custom_metadata_list) | ||
conda_slug, conda_path = None, None | ||
if "CondaEnvironmentPath" in custom_metadata: | ||
conda_path = custom_metadata['CondaEnvironmentPath'].value |
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.
NIT: MetadataCustomKeys.CONDA_ENVIRONMENT_PATH
?
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.
fixed as "CondaEnvironmentPath" in custom_metadata.keys
@@ -499,7 +502,26 @@ def deactivate(**kwargs): | |||
suppress_traceback(kwargs["debug"])(deactivate_cmd)(**kwargs) | |||
|
|||
|
|||
@commands.command() |
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.
Looks like this file needs to be formatted? Please check the other files as well. I have added a pre-commit config in this PR, but till it will be merged the manual formatting needs to be done.
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.
run black manually
ads/opctl/cli.py
Outdated
@click.option("--region", nargs=1, required=False, help="The destination Object Storage bucket region. By default the value will be extracted from the `OCI_REGION_METADATA` environment variables. This is only used when the model id is passed.") | ||
@click.option("--timeout", nargs=1, required=False, help="The connection timeout in seconds for the client. This is only used when the model id is passed.") | ||
@click.option("--artifact-directory", nargs=1, required=False, default=None, help="The artifact directory where stores your models, score.py and etc. This is used when you have a model artifact locally and have not saved it to the model catalog yet. In this case, you dont need to pass in model ") | ||
@click.option("--payload", nargs=1, help="The payload sent to the model for prediction.") |
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.
Should be added some details about the format of the payload?
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
ads/opctl/cmds.py
Outdated
|
||
|
||
class DataScienceResource(str, metaclass=ExtendedEnumMeta): | ||
JOB = "datasciencejob" | ||
DATAFLOW = "dataflowapplication" | ||
PIPELINE = "datasciencepipeline" | ||
MODEL_DEPLOYMENT = "datasciencemodeldeployment" | ||
MODEL = "datascience" |
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 it would be better to use datasciencemodel
instead?
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.
fixed
…into ODSC-29065/md_opctl
No success to gather report. 😿 📌 Overall coverage: No success to gather report. 😿 |
No success to gather report. 😿 📌 Overall coverage: No success to gather report. 😿 |
…ata-science into ODSC-29065/md_opctl
📌 Cov diff with develop: No success to gather report. 😿 📌 Overall coverage: No success to gather report. 😿 |
Description
Download Model
ads opctl model download ocid1.datasciencemodel.oc1.*** -f --bucket-uri oci://ads_test@ociodscdev/model
Auto Detect and Install Conda
ads opctl predict --ocid ocid1.datasciencemodel.oc1.iad.*** --payload '[[-1.68671955,2.25814541,1.48317577,1.51661083,-0.20669947,-0.4260807,-1.02519643,-0.5068027,0.25248417,0.62665134,0.23441123,-0.27358368,0.82731396,-0.14530245,0.80733585]]' --bucket-uri oci://ads_test@ociodscdev/model --conda-pack-folder ~/.ads_ops/conda2
![image](https://user-images.githubusercontent.com/25996703/235410155-d2a66b25-79fd-4876-a9d4-5e812bffd95e.png)
Small artifacts
ads opctl predict --ocid ocid1.datasciencemodel.oc1.iad.*** --payload '[[-1.68671955,2.25814541,1.48317577,1.51661083,-0.20669947,-0.4260807,-1.02519643,-0.5068027,0.25248417,0.62665134,0.23441123,-0.27358368,0.82731396,-0.14530245,0.80733585]]' --conda-slug onnx110_p38_cpu_v2
![image](https://user-images.githubusercontent.com/25996703/235408455-f47a9565-aad2-4f2f-b96d-0a444c4c5018.png)
Artifacts Dir
ads opctl predict --artifact-directory ~/.ads_ops/models/ocid1.datasciencemodel.oc1.iad.*** --payload '[[-1.68671955,2.25814541,1.48317577,1.51661083,-0.20669947,-0.4260807,-1.02519643,-0.5068027,0.25248417,0.62665134,0.23441123,-0.27358368,0.82731396,-0.14530245,0.80733585]]' --conda-slug onnx110_p38_cpu_v2
![image](https://user-images.githubusercontent.com/25996703/235408554-3856721a-9048-4340-b353-3cc5f15e5a19.png)
Large Artifacts
ads opctl predict --ocid ocid1.datasciencemodel.oc1.iad.*** --payload '[[-1.68671955,2.25814541,1.48317577,1.51661083,-0.20669947,-0.4260807,-1.02519643,-0.5068027,0.25248417,0.62665134,0.23441123,-0.27358368,0.82731396,-0.14530245,0.80733585]]' --conda-slug onnx110_p38_cpu_v2 --bucket-uri oci://ads_test@ociodscdev/model