Skip to content

0.5.3 release #76

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 2 commits into from
Mar 25, 2025
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
12 changes: 6 additions & 6 deletions {{cookiecutter.repo_name}}/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ build:cpu-image:
script:
- mkdir -p /kaniko/.docker
{%- if cookiecutter.platform == 'onprem' %}
- cat $HARBOR_ROBOT_CREDS_JSON > /kaniko/.docker/config.json
- echo $HARBOR_ROBOT_CREDS_JSON > /kaniko/.docker/config.json
{%- elif cookiecutter.platform == 'gcp' %}
- cat $GCP_SERVICE_ACCOUNT_KEY > /kaniko/.docker/config.json
- echo $GCP_SERVICE_ACCOUNT_KEY > /kaniko/.docker/config.json
{%- endif %}
- >-
/kaniko/executor
Expand Down Expand Up @@ -259,9 +259,9 @@ build:gpu-image:
script:
- mkdir -p /kaniko/.docker
{%- if cookiecutter.platform == 'onprem' %}
- cat $HARBOR_ROBOT_CREDS_JSON > /kaniko/.docker/config.json
- echo $HARBOR_ROBOT_CREDS_JSON > /kaniko/.docker/config.json
{%- elif cookiecutter.platform == 'gcp' %}
- cat $GCP_SERVICE_ACCOUNT_KEY > /kaniko/.docker/config.json
- echo $GCP_SERVICE_ACCOUNT_KEY > /kaniko/.docker/config.json
{%- endif %}
- >-
/kaniko/executor
Expand Down Expand Up @@ -302,11 +302,11 @@ build:retag-images:
{%- endif %}
script:
{%- if cookiecutter.platform == 'onprem' %}
- cat $HARBOR_ROBOT_CREDS_JSON > /root/.docker/config.json
- echo $HARBOR_ROBOT_CREDS_JSON > /root/.docker/config.json
- crane tag {{cookiecutter.registry_project_path}}/cpu:${CI_COMMIT_SHORT_SHA} ${CI_COMMIT_TAG}
- crane tag {{cookiecutter.registry_project_path}}/gpu:${CI_COMMIT_SHORT_SHA} ${CI_COMMIT_TAG}
{%- elif cookiecutter.platform == 'gcp' %}
- cat $GCP_SERVICE_ACCOUNT_KEY > /gcp-sa.json
- echo $GCP_SERVICE_ACCOUNT_KEY > /gcp-sa.json
- gcloud container images add-tag "{{cookiecutter.registry_project_path}}/cpu:${CI_COMMIT_SHORT_SHA}" "{{cookiecutter.registry_project_path}}/data-prep:${CI_COMMIT_TAG}"
- gcloud container images add-tag "{{cookiecutter.registry_project_path}}/gpu:${CI_COMMIT_SHORT_SHA}" "{{cookiecutter.registry_project_path}}/model-training:${CI_COMMIT_TAG}"
{%- endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ so:
```

Using the output from above, copy and paste the following content
into a CI/CD environment variable of type `File`
into a CI/CD environment variable of type `variable`
(under `Settings` -> `CI/CD` -> `Variables` -> `Add variable`):

```json
Expand Down Expand Up @@ -410,9 +410,9 @@ that builds a Docker image:
script:
- mkdir -p /kaniko/.docker
{%- if cookiecutter.platform == 'onprem' %}
- cat $HARBOR_ROBOT_CREDS_JSON > /kaniko/.docker/config.json
- echo $HARBOR_ROBOT_CREDS_JSON > /kaniko/.docker/config.json
{%- elif cookiecutter.platform == 'gcp' %}
- cat $GCP_SERVICE_ACCOUNT_KEY > /kaniko/.docker/config.json
- echo $GCP_SERVICE_ACCOUNT_KEY > /kaniko/.docker/config.json
{%- endif %}
- >-
/kaniko/executor
Expand Down Expand Up @@ -531,11 +531,11 @@ the default branch before this.
{%- endif %}
script:
{%- if cookiecutter.platform == 'onprem' %}
- cat $HARBOR_ROBOT_CREDS_JSON > /root/.docker/config.json
- echo $HARBOR_ROBOT_CREDS_JSON > /root/.docker/config.json
- crane tag {{cookiecutter.registry_project_path}}/cpu:${CI_COMMIT_SHORT_SHA} ${CI_COMMIT_TAG}
- crane tag {{cookiecutter.registry_project_path}}/gpu:${CI_COMMIT_SHORT_SHA} ${CI_COMMIT_TAG}
{%- elif cookiecutter.platform == 'gcp' %}
- cat $GCP_SERVICE_ACCOUNT_KEY > /gcp-sa.json
- echo $GCP_SERVICE_ACCOUNT_KEY > /gcp-sa.json
- gcloud container images add-tag "{{cookiecutter.registry_project_path}}/cpu:${CI_COMMIT_SHORT_SHA}" "{{cookiecutter.registry_project_path}}/cpu:${CI_COMMIT_TAG}"
- gcloud container images add-tag "{{cookiecutter.registry_project_path}}/gpu:${CI_COMMIT_SHORT_SHA}" "{{cookiecutter.registry_project_path}}/gpu:${CI_COMMIT_TAG}"
{%- endif %}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,7 @@ that exists within the repository.

### Running the API Server

Run the FastAPI server using [Gunicorn](https://gunicorn.org)
(for Linux/macOS) or [`uvicorn`][uvicorn] (for Windows):

!!! attention
Gunicorn is only executable on UNIX-based or UNIX-like systems;
this method would not be possible/applicable for Windows machines.
Run the FastAPI server using [`uvicorn`][uvicorn]:

=== "Linux"

Expand All @@ -147,9 +142,8 @@ Run the FastAPI server using [Gunicorn](https://gunicorn.org)
-v ./models:/home/aisg/{{cookiecutter.repo_name}}/models \
-w /home/aisg/{{cookiecutter.repo_name}}/src \
{{cookiecutter.registry_project_path}}/gpu:0.1.0 \
gunicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
-k uvicorn.workers.UvicornWorker \
-b 0.0.0.0:8080 -w 2 -t 90
uvicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
--host 0.0.0.0 --port 8080 --workers 2 --app-dir src
```

=== "macOS"
Expand All @@ -160,9 +154,8 @@ Run the FastAPI server using [Gunicorn](https://gunicorn.org)
-v ./models:/home/aisg/{{cookiecutter.repo_name}}/models \
-w /home/aisg/{{cookiecutter.repo_name}}/src \
{{cookiecutter.registry_project_path}}/gpu:0.1.0 \
gunicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
-k uvicorn.workers.UvicornWorker \
-b 0.0.0.0:8080 -w 2 -t 90
uvicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
--host 0.0.0.0 --port 8080 --workers 2 --app-dir src
```

=== "Windows PowerShell"
Expand All @@ -181,9 +174,8 @@ Run the FastAPI server using [Gunicorn](https://gunicorn.org)
-v .\models:/home/aisg/{{cookiecutter.repo_name}}/models `
-w /home/aisg/{{cookiecutter.repo_name}}/src `
{{cookiecutter.registry_project_path}}/gpu:0.1.0 `
gunicorn {{cookiecutter.src_package_name}}_fastapi.main:APP `
-k uvicorn.workers.UvicornWorker `
-b 0.0.0.0:8080 -w 2 -t 90
uvicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
--host 0.0.0.0 --port 8080 --workers 2 --app-dir src
```

And with that, our document site for our server is viewable through
Expand Down Expand Up @@ -234,7 +226,6 @@ With the returned JSON object, we have successfully submitted a request
to the FastAPI server and it returned predictions as part of the
response.

[reason]: https://fastapi.tiangolo.com/deployment/server-workers/
[uvicorn]: https://www.uvicorn.org/
[rocm-wsl]: https://rocm.docs.amd.com/projects/radeon/en/latest/docs/install/wsl/howto_wsl.html

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,33 +104,22 @@ that exists within the repository.

### Running the API Server

Run the FastAPI server using [Gunicorn](https://gunicorn.org)
(for Linux/macOS) or [`uvicorn`][uvicorn] (for Windows):

!!! attention
Gunicorn is only executable on UNIX-based or UNIX-like systems;
this method would not be possible/applicable for Windows machines.
Run the FastAPI server using [`uvicorn`][uvicorn]:

=== "Linux/macOS"

```bash
conda activate {{cookiecutter.repo_name}}
gunicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
-k uvicorn.workers.UvicornWorker \
-b 0.0.0.0:8080 -w 2 -t 90 --chdir src
uvicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
--host 0.0.0.0 --port 8080 --workers 2 --app-dir src
```

!!! info
See [here][reason] as to why Gunicorn is to be used instead of
just [Uvicorn][uvicorn]. TLDR: Gunicorn is needed to spin up
multiple processes/workers to handle more requests i.e. better
for the sake of production needs.

=== "Windows PowerShell"

```powershell
conda activate {{cookiecutter.repo_name}}
uvicorn {{cookiecutter.src_package_name}}_fastapi.main:APP --app-dir src
uvicorn {{cookiecutter.src_package_name}}_fastapi.main:APP `
--host 0.0.0.0 --port 8080 --workers 2 --app-dir src
```

And with that, our document site for our server is viewable through
Expand Down Expand Up @@ -169,7 +158,6 @@ With the returned JSON object, we have successfully submitted a request
to the FastAPI server and it returned predictions as part of the
response.

[reason]: https://fastapi.tiangolo.com/deployment/server-workers/
[uvicorn]: https://www.uvicorn.org/

### Pydantic Settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,16 @@ that exists within the repository.

### Running the API Server

Run the FastAPI server using [Gunicorn](https://gunicorn.org):
Run the FastAPI server using [`uvicorn`][uvicorn]:

=== "Coder Workspace Terminal"

```bash
# Running in a working `{{cookiecutter.repo_name}}` repository
conda activate {{cookiecutter.repo_name}}
export MODEL_UUID=<MLFLOW_RUN_UUID>
gunicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
-k uvicorn.workers.UvicornWorker \
-b 0.0.0.0:8080 -w 2 -t 90 --chdir src
uvicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
--host 0.0.0.0 --port 8080 --workers 2 --app-dir src
```

And with that, the link to our document site for our server would
Expand All @@ -153,9 +152,8 @@ Run the FastAPI server using [Gunicorn](https://gunicorn.org):
--existing-pvc claimname=<NAME_OF_DATA_SOURCE>,path=/<NAME_OF_DATA_SOURCE> \
--cpu 2 --cpu-limit 2 --memory 4G --memory-limit 4G --backoff-limit 1 \
--service-type external-url,port=8080:8080 \
--command -- gunicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
-k uvicorn.workers.UvicornWorker \
-b 0.0.0.0:8080 -w 2 -t 90
--command -- uvicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
--host 0.0.0.0 --port 8080 --workers 2 --app-dir src
```

And with that, the link to our document site for our server would
Expand Down Expand Up @@ -184,7 +182,6 @@ With the returned JSON object, we have successfully submitted a request
to the FastAPI server and it returned predictions as part of the
response.

[reason]: https://fastapi.tiangolo.com/deployment/server-workers/
[uvicorn]: https://www.uvicorn.org/

### Pydantic Settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,37 +56,37 @@
[beginner tutorials]: https://fastapi.tiangolo.com/tutorial/

### Running the API Server
@@ -145,8 +142,9 @@
@@ -140,8 +137,9 @@
docker run --rm \
-p 8080:8080 \
-v ./models:/home/aisg/{{cookiecutter.repo_name}}/models \
-w /home/aisg/{{cookiecutter.repo_name}}/src \
+ -e PRED_MODEL_PATH="../models/$PRED_MODEL_UUID/model/model.pt" \
{{cookiecutter.registry_project_path}}/gpu:0.1.0 \
gunicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
-k uvicorn.workers.UvicornWorker \
-b 0.0.0.0:8080 -w 2 -t 90
@@ -158,8 +156,9 @@
uvicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
--host 0.0.0.0 --port 8080 --workers 2 --app-dir src
```
@@ -152,8 +150,9 @@
docker run --rm \
-p 8080:8080 \
-v ./models:/home/aisg/{{cookiecutter.repo_name}}/models \
-w /home/aisg/{{cookiecutter.repo_name}}/src \
+ -e PRED_MODEL_PATH="../models/$PRED_MODEL_UUID/model/model.pt" \
{{cookiecutter.registry_project_path}}/gpu:0.1.0 \
gunicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
-k uvicorn.workers.UvicornWorker \
-b 0.0.0.0:8080 -w 2 -t 90
@@ -179,8 +178,9 @@
uvicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
--host 0.0.0.0 --port 8080 --workers 2 --app-dir src
```
@@ -172,8 +171,9 @@
docker run --rm `
-p 8080:8080 `
-v .\models:/home/aisg/{{cookiecutter.repo_name}}/models `
-w /home/aisg/{{cookiecutter.repo_name}}/src `
+ -e PRED_MODEL_PATH="../models/$Env:PRED_MODEL_UUID/model/model.pt" `
{{cookiecutter.registry_project_path}}/gpu:0.1.0 `
gunicorn {{cookiecutter.src_package_name}}_fastapi.main:APP `
-k uvicorn.workers.UvicornWorker `
-b 0.0.0.0:8080 -w 2 -t 90
@@ -196,39 +196,39 @@
uvicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
--host 0.0.0.0 --port 8080 --workers 2 --app-dir src
```
@@ -188,39 +188,39 @@

=== "Linux"

Expand Down Expand Up @@ -136,7 +136,7 @@

With the returned JSON object, we have successfully submitted a request
to the FastAPI server and it returned predictions as part of the
@@ -245,9 +245,10 @@
@@ -236,9 +236,10 @@
data and schema validation, as well as [settings management]. There's a
class called `Settings` under the module
`src/{{cookiecutter.src_package_name}}_fastapi/config.py`. This class
Expand All @@ -148,7 +148,7 @@
`src/{{cookiecutter.src_package_name}}_fastapi/config.py`:
```python
...
@@ -256,9 +257,12 @@
@@ -247,9 +248,12 @@
API_NAME: str = "{{cookiecutter.src_package_name}}_fastapi"
API_V1_STR: str = "/api/v1"
LOGGER_CONFIG_PATH: str = "../conf/logging.yaml"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
[beginner tutorials]: https://fastapi.tiangolo.com/tutorial/

### Running the API Server
@@ -145,25 +160,25 @@
@@ -134,25 +149,25 @@

```bash
curl -X POST \
Expand Down Expand Up @@ -88,7 +88,7 @@

With the returned JSON object, we have successfully submitted a request
to the FastAPI server and it returned predictions as part of the
@@ -179,9 +194,10 @@
@@ -167,9 +182,10 @@
data and schema validation, as well as [settings management]. There's a
class called `Settings` under the module
`src/{{cookiecutter.src_package_name}}_fastapi/config.py`. This class
Expand All @@ -100,7 +100,7 @@
`src/{{cookiecutter.src_package_name}}_fastapi/config.py`:
```python
...
@@ -190,9 +206,12 @@
@@ -178,9 +194,12 @@
API_NAME: str = "{{cookiecutter.src_package_name}}_fastapi"
API_V1_STR: str = "/api/v1"
LOGGER_CONFIG_PATH: str = "../conf/logging.yaml"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
- export MODEL_UUID=<MLFLOW_RUN_UUID>
+ export PRED_MODEL_UUID=<MLFLOW_RUN_UUID>
+ export PRED_MODEL_PATH="<NAME_OF_DATA_SOURCE>/workspaces/<YOUR_HYPENATED_NAME>/models/$PRED_MODEL_UUID/model/model.pt"
gunicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
-k uvicorn.workers.UvicornWorker \
-b 0.0.0.0:8080 -w 2 -t 90 --chdir src
uvicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
--host 0.0.0.0 --port 8080 --workers 2 --app-dir src
```
@@ -144,15 +148,16 @@

@@ -143,15 +147,16 @@

=== "Using Run:ai"

Expand All @@ -77,10 +77,10 @@
--cpu 2 --cpu-limit 2 --memory 4G --memory-limit 4G --backoff-limit 1 \
+ -e PRED_MODEL_PATH=/<NAME_OF_DATA_SOURCE>/workspaces/<YOUR_HYPENATED_NAME>/models/$PRED_MODEL_UUID/model/model.pt \
--service-type external-url,port=8080:8080 \
--command -- gunicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
-k uvicorn.workers.UvicornWorker \
-b 0.0.0.0:8080 -w 2 -t 90
@@ -169,16 +174,16 @@
--command -- uvicorn {{cookiecutter.src_package_name}}_fastapi.main:APP \
--host 0.0.0.0 --port 8080 --workers 2 --app-dir src
```
@@ -167,16 +172,16 @@

```bash
curl -X POST \
Expand All @@ -100,7 +100,7 @@

With the returned JSON object, we have successfully submitted a request
to the FastAPI server and it returned predictions as part of the
@@ -194,9 +199,10 @@
@@ -191,9 +196,10 @@
data and schema validation, as well as [settings management]. There's a
class called `Settings` under the module
`src/{{cookiecutter.src_package_name}}_fastapi/config.py`. This class
Expand All @@ -112,7 +112,7 @@
`src/{{cookiecutter.src_package_name}}_fastapi/config.py`:
```python
...
@@ -205,9 +211,12 @@
@@ -202,9 +208,12 @@
API_NAME: str = "{{cookiecutter.src_package_name}}_fastapi"
API_V1_STR: str = "/api/v1"
LOGGER_CONFIG_PATH: str = "../conf/logging.yaml"
Expand Down
Loading