Skip to content

Commit

Permalink
Merge pull request #58 from truefoundry/audit-raja
Browse files Browse the repository at this point in the history
adding deploy for customer-churn and readme changes
  • Loading branch information
nikp1172 authored Nov 26, 2024
2 parents 0fbb0f6 + eff3d60 commit a77e99c
Show file tree
Hide file tree
Showing 15 changed files with 250 additions and 645 deletions.
51 changes: 51 additions & 0 deletions customer-churn/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# getting-started-examples
Examples to get started with using TrueFoundry

Deployment of Job
---
This example runs a Customer-churn for inferring using a classifier.
Mainly this example shows how to deploy to TrueFoundry using a Pythonfile and TrueFoundry Python SDK.

## Setup

> For setup, please refer to the following documentation:
> - [Create a ML Repo ](https://docs.truefoundry.com/docs/key-concepts#creating-an-ml-repo)
> - [Grant Editor access to ML Repo](https://docs.truefoundry.com/docs/key-concepts#grant-access-of-ml-repo-to-workspace)
## Run Locally

1. Install requirements

```shell
python -m pip install -r requirements.txt
```

2. Start the Customer-churn

```shell
python main.py --n_neighbors {{n_neighbors}} --weights {{weights}} --ml_repo {{ml_repo}}
```

## Deploy with TrueFoundry

1. Install `truefoundry`

```shell
python -m pip install -U "truefoundry>=0.4.1,<0.5.0"
```

2. Login

```shell
tfy login --host "<Host name of TrueFoundry UI. e.g. https://company.truefoundry.cloud>"
```

3. Deploy!

> Please refer to following docs
> - [Getting workspace FQN](https://docs.truefoundry.com/docs/key-concepts#getting-workspace-fqn)
```shell
python deploy.py --workspace-fqn <Workspace FQN>
```

Binary file added customer-churn/classifier.joblib
Binary file not shown.
49 changes: 49 additions & 0 deletions customer-churn/deploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import logging
import argparse

from truefoundry.deploy import Build, PythonBuild, LocalSource, Param, Resources, Job

logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(name)s] %(levelname)-8s %(message)s")

parser = argparse.ArgumentParser()
parser.add_argument("--workspace_fqn", required=True, type=str)
args = parser.parse_args()

job = Job(
name="churn-prediction-job",
image=Build(
build_source=LocalSource(local_build=False),
build_spec=PythonBuild(
python_version="3.11",
command="python main.py --n_neighbors {{n_neighbors}} --weights {{weights}} --ml_repo {{ml_repo}}",
requirements_path="requirements.txt",
),
),
params=[
Param(
name="n_neighbors",
default=5,
description="Number of neighbors to use by default",
),
Param(
name="weights",
default="uniform",
description="Weight function used in prediction. Possible values: uniform, distance",
),
Param(
name="ml_repo",
param_type="ml_repo",
description="ML Repo to log metrics and model to",
),
],
resources=Resources(
memory_limit=500,
memory_request=500,
ephemeral_storage_limit=600,
ephemeral_storage_request=600,
cpu_limit=0.3,
cpu_request=0.3,
),
)

deployment = job.deploy(workspace_fqn=args.workspace_fqn, wait=False)
44 changes: 44 additions & 0 deletions deploy-ml-model/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,46 @@
# getting-started-examples
Examples to get started with using TrueFoundry

Deployment
---
This example runs a simple iris app for inferring using a iris classifier.
Mainly this example shows how to deploy to TrueFoundry using a Pythonfile and TrueFoundry Python SDK.

## Run Locally

1. Install requirements

```shell
python -m pip install -r requirements.txt
```

2. Start the iris app

```shell
python app.py
```

## Deploy with TrueFoundry

1. Install `truefoundry`

```shell
python -m pip install -U "truefoundry>=0.4.1,<0.5.0"
```

2. Login

```shell
tfy login --host "<Host name of TrueFoundry UI. e.g. https://company.truefoundry.cloud>"
```

3. Deploy!

> Please refer to following docs
> - [Getting workspace FQN](https://docs.truefoundry.com/docs/key-concepts#getting-workspace-fqn)
> - [Get host and path for deploying applications](https://docs.truefoundry.com/docs/define-ports-and-domains#identifying-available-domains)
```shell
python deploy.py --name iris --workspace-fqn <Workspace FQN> --host <Ingress Host for the cluster> --path <optional path>
```

5 changes: 2 additions & 3 deletions docker-deploy/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Dockerfiled based Deployment
---
This example runs a simple Gradio app for inferring using a iris classifier.

Mainly this example shows how to deploy to TrueFoundry using a Dockerfile and TrueFoundry Python SDK.

## Run Locally
Expand Down Expand Up @@ -32,7 +31,7 @@ python -m pip install -U "truefoundry>=0.4.1,<0.5.0"
tfy login --host "<Host name of TrueFoundry UI. e.g. https://company.truefoundry.cloud>"
```

4. Deploy!
3. Deploy!

> Please refer to following docs
> - [Getting workspace FQN](https://docs.truefoundry.com/docs/key-concepts#getting-workspace-fqn)
Expand All @@ -42,5 +41,5 @@ tfy login --host "<Host name of TrueFoundry UI. e.g. https://company.truefoundry
python deploy.py --name iris-gradio --workspace-fqn <Workspace FQN> --host <Ingress Host for the cluster> --path <optional path>
```

5. Trigger the deployed Job using the UI or Python SDK
4. Trigger the deployed Job using the UI or Python SDK
https://docs.truefoundry.com/docs/triggering-a-job#trigger-a-job
153 changes: 0 additions & 153 deletions locust-llm-benchmark/benchmark.py

This file was deleted.

49 changes: 0 additions & 49 deletions locust-llm-benchmark/deploy.py

This file was deleted.

1 change: 0 additions & 1 deletion locust-llm-benchmark/requirements.txt

This file was deleted.

Loading

0 comments on commit a77e99c

Please sign in to comment.