Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
`
44 changes: 31 additions & 13 deletions centml/cli/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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(
Expand All @@ -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")
Expand All @@ -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,
Expand Down Expand Up @@ -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(
[
Expand Down
17 changes: 17 additions & 0 deletions centml/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 11 additions & 2 deletions centml/sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import platform_api_python_client
from platform_api_python_client import (
DeploymentType,
DeploymentStatus,
CreateInferenceDeploymentRequest,
CreateComputeDeploymentRequest,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Loading