Skip to content
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

Move vars to dynamic, add metrics #1085

Merged
merged 18 commits into from
May 3, 2024
Merged

Conversation

nsarrazin
Copy link
Collaborator

@nsarrazin nsarrazin commented Apr 29, 2024

This PR moves all env vars to $env/dynamic

We add prometheus metrics

Get rid of Dockerfile.local file

Docker builds

  • chat-ui docker build -t chat-ui .
  • chat-ui-db docker build -t chat-ui-db --build-arg="INCLUDE_DB=true" .
  • hchat docker build -t huggingchat --build-arg="APP_BASE=/chat" --build-arg="PUBLIC_APP_COLOR=yellow" .

@nsarrazin nsarrazin added enhancement New feature or request back This issue is related to the Svelte backend or the DB labels Apr 29, 2024
@@ -0,0 +1,3 @@
export async function GET() {
return new Response("OK", { status: 200 });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be interesting to check the DB connectivity here and other dependencies (if there are)

@@ -0,0 +1,9 @@
import { register } from "$lib/server/metrics";

export async function GET() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we expose this route on another port?
It would be better if we can avoid exposing metrics publicly

@rtrompier rtrompier mentioned this pull request Apr 30, 2024
6 tasks
@XciD
Copy link
Member

XciD commented Apr 30, 2024

Good start for metrics, we should check if we can create some specific ones like:
number of api-inference failures per model for example

nsarrazin and others added 11 commits April 30, 2024 10:44
* Add truncate to task model (#1090)

* retry text area height (#1091)

* Make all the env vars dynamic

* only check for db at runtime

* remove secret from build step

* improve dockerfile

* Wrap db in singleton

* add .env.local to dockerignore

* changes to dockerfile

* lint

* aborted generations

* move collections build check

* Use a single dockerfile

* lint

* fixes

* lint

* don't return db during building

* remove dev

---------

Co-authored-by: Victor Muštar <[email protected]>
@nsarrazin nsarrazin changed the title Add prometheus metrics Move vars to dynamic, add metrics May 3, 2024
@nsarrazin nsarrazin merged commit 98b1c51 into main May 3, 2024
5 checks passed
@nsarrazin nsarrazin deleted the feat/add_prometheus_metrics branch May 3, 2024 11:24
@pocman
Copy link
Contributor

pocman commented May 20, 2024

@nsarrazin since it's not possible to use env var instead of .env files , I'm not sure what should be the format of the MODELS payload as seens in an echo $MODELS command. Do we still need the ` for escaping ?

Comment on lines 10 to 11
!.env.local No newline at end of file
.env.local
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nsarrazin What is the recommended way to use .env.local with Docker?

Context

The readme is currently optimised for local envs and requires changes for Docker envs.

Issue

I stumbled upon the issue that the .env.local was ignored when building the Docker image in CI because of this ignore statement.

Possible Solutions

A temporary solution when using Docker Compose is available in PR #1238, but it doesn't apply to Kubernetes deployments. Reverting this change—i.e., to !.env.local—would work for both Docker Compose and Kubernetes.

Copy link
Collaborator Author

@nsarrazin nsarrazin Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a few examples here but i'll be improving the docs for this. Let me know if that's enough to solve your issue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Furthermore, including .env.local in Dockerfile requires this change also:

+ COPY --chown=1000 .env.local /app/.env.local

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I faced several issues when deploying this to a Kubernetes cluster. I ended up passing somehow the .envlocal into the Docker image.

ice91 pushed a commit to ice91/chat-ui that referenced this pull request Oct 30, 2024
* Add healthcheck route

* Add prom client with basic metrics

* wip: serve metrics on a different port

* exclude server from tsconfig

* latest

* refacto(all): use class & singleton

* refacto(all): use class & singleton

* refacto(all): add request logs

* Make all the env vars dynamic (huggingface#1092)

* Add truncate to task model (huggingface#1090)

* retry text area height (huggingface#1091)

* Make all the env vars dynamic

* only check for db at runtime

* remove secret from build step

* improve dockerfile

* Wrap db in singleton

* add .env.local to dockerignore

* changes to dockerfile

* lint

* aborted generations

* move collections build check

* Use a single dockerfile

* lint

* fixes

* lint

* don't return db during building

* remove dev

---------

Co-authored-by: Victor Muštar <[email protected]>

* refacto(all): update default metrics port

* fix recursion error

* add version check

* revert vite preview

* Move request logs to debug level and add an env var to filter by log level in dev mode

* Set package version if needed

* Set log level for prod and dev

---------

Co-authored-by: rtrompier <[email protected]>
Co-authored-by: Victor Muštar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back This issue is related to the Svelte backend or the DB enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants