diff --git a/README.md b/README.md index 9612118..98ad196 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,13 @@ Alternatively to build from source, clone this repo then inside the project's ba pip install . ``` +### Un-installation + +To uninstall `centml`, simply do: +```bash +pip uninstall centml +``` + ### CLI Once installed, use the centml CLI tool with the following command: ```bash @@ -85,3 +92,30 @@ To run all the tests, use: ```bash pytest ``` + +### Common Issues + +- **`SSL` certificate on `MacOS`** + + Sometimes, you will see issues when using command like `centml cluster [CMD]`, where the output might look like: + + ```logs + + File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/util/retry.py", line 519, in increment + + raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] + + urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.centml.com', port=443): + + Max retries exceeded with url: /deployments + + (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)'))) + ``` + + **Solution**: + To fix this issue, navigate to your `python` installation directory and run the `Install Certificates.command` file located there. + + For example, if you are using `python3.10`, the file path would be: + ` + /Applications/Python 3.10/Install Certificates.command + ` diff --git a/centml/cli/cluster.py b/centml/cli/cluster.py index f6f88f8..b5d143c 100644 --- a/centml/cli/cluster.py +++ b/centml/cli/cluster.py @@ -7,12 +7,22 @@ from centml.sdk.api import get_centml_client +depl_type_to_name_map = { + DeploymentType.INFERENCE: 'inference', + DeploymentType.COMPUTE: 'compute', + DeploymentType.COMPILATION: 'compilation', + DeploymentType.INFERENCE_V2: 'inference', + DeploymentType.COMPUTE_V2: 'compute', + DeploymentType.CSERVE: 'cserve', + DeploymentType.CSERVE_V2: 'cserve', + DeploymentType.RAG: 'rag', +} depl_name_to_type_map = { - "inference": DeploymentType.INFERENCE_V2, - "compute": DeploymentType.COMPUTE_V2, - "cserve": DeploymentType.CSERVE, + 'inference': DeploymentType.INFERENCE_V2, + 'cserve': DeploymentType.CSERVE_V2, + 'compute': DeploymentType.COMPUTE_V2, + 'rag': DeploymentType.RAG, } -depl_type_to_name_map = {v: k for k, v in depl_name_to_type_map.items()} def handle_exception(func): @@ -21,7 +31,7 @@ def wrapper(*args, **kwargs): try: return func(*args, **kwargs) except ApiException as e: - click.echo(f"Error: {e.reason}") + click.echo(f"Error: {e.body or e.reason}") return None return wrapper @@ -43,7 +53,7 @@ def _get_hw_to_id_map(cclient, cluster_id): def _format_ssh_key(ssh_key): if not ssh_key: return "No SSH Key Found" - return ssh_key[:10] + '...' + return ssh_key[:32] + "..." def _get_ready_status(cclient, deployment): @@ -80,10 +90,18 @@ def ls(type): with get_centml_client() as cclient: depl_type = depl_name_to_type_map[type] if type in depl_name_to_type_map else None deployments = cclient.get(depl_type) - rows = [ - [d.id, d.name, depl_type_to_name_map[d.type], d.status.value, d.created_at.strftime("%Y-%m-%d %H:%M:%S")] - for d in deployments - ] + rows = [] + for d in deployments: + if d.type in depl_type_to_name_map: + rows.append( + [ + d.id, + d.name, + depl_type_to_name_map[d.type], + d.status.value, + d.created_at.strftime("%Y-%m-%d %H:%M:%S"), + ] + ) click.echo( tabulate( @@ -107,7 +125,7 @@ def get(type, id): deployment = cclient.get_inference(id) elif depl_type == DeploymentType.COMPUTE_V2: deployment = cclient.get_compute(id) - elif depl_type == DeploymentType.CSERVE: + elif depl_type == DeploymentType.CSERVE_V2: deployment = cclient.get_cserve(id) else: sys.exit("Please enter correct deployment type") @@ -124,7 +142,7 @@ def get(type, id): ("Endpoint", deployment.endpoint_url), ("Created at", deployment.created_at.strftime("%Y-%m-%d %H:%M:%S")), ("Hardware", f"{hw.name} ({hw.num_gpu}x {hw.gpu_type})"), - ("Cost", f"{hw.cost_per_hr/100} credits/hr"), + ("Cost", f"{hw.cost_per_hr / 100} credits/hr"), ], tablefmt="rounded_outline", disable_numparse=True, @@ -155,7 +173,7 @@ def get(type, id): disable_numparse=True, ) ) - elif depl_type == DeploymentType.CSERVE: + elif depl_type == DeploymentType.CSERVE_V2: click.echo( tabulate( [ diff --git a/centml/cli/main.py b/centml/cli/main.py index 64dfa64..b1ecc73 100644 --- a/centml/cli/main.py +++ b/centml/cli/main.py @@ -5,6 +5,23 @@ @click.group() +# this is the version and prog name set in setup.py +@click.version_option( + prog_name="CentML CLI", + message=""" + ______ __ __ ___ __ + / ____/___ ____ / /_ / |/ // / + / / / _ \\ / __ \\ / __// /|_/ // / + / /___ / __// / / // /_ / / / // /___ + \\____/ \\___//_/ /_/ \\__//_/ /_//_____/ + + 🚀 Welcome to %(prog)s v%(version)s 🚀 + + ✨ AI Deployment Made Simple ✨ +📚 Documentation: https://docs.centml.ai/ +🛠 Need help? Reach out to support@centml.ai +""", +) def cli(): pass diff --git a/centml/sdk/api.py b/centml/sdk/api.py index f83dfd4..3a637c6 100644 --- a/centml/sdk/api.py +++ b/centml/sdk/api.py @@ -2,6 +2,7 @@ import platform_api_python_client from platform_api_python_client import ( + DeploymentType, DeploymentStatus, CreateInferenceDeploymentRequest, CreateComputeDeploymentRequest, @@ -58,8 +59,16 @@ def resume(self, id): def get_clusters(self): return self._api.get_clusters_clusters_get() - def get_hardware_instances(self, cluster_id): - return self._api.get_hardware_instances_hardware_instances_get(cluster_id).results + def get_hardware_instances(self, cluster_id=None): + return self._api.get_hardware_instances_hardware_instances_get( + cluster_id=cluster_id if cluster_id else None + ).results + + def get_prebuilt_images(self, depl_type: DeploymentType): + return self._api.get_prebuilt_images_prebuilt_images_get(type=depl_type) + + def get_cserve_recipe(self): + return self._api.get_cserve_recipe_deployments_cserve_recipes_get().results @contextmanager diff --git a/requirements.txt b/requirements.txt index a2aa22f..ff87c33 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,4 +9,4 @@ cryptography==44.0.1 prometheus-client>=0.20.0 scipy>=1.6.0 scikit-learn>=1.5.1 -platform-api-python-client==0.3.1 +platform-api-python-client==3.2.4 diff --git a/setup.py b/setup.py index 8c3c36e..cbae9e8 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setup( name='centml', - version='0.3.0', + version='0.3.1', packages=find_packages(), python_requires=">=3.10", long_description=open('README.md').read(),