From 602f9c4a0ac377008616fbf41203aafaa6f26eeb Mon Sep 17 00:00:00 2001 From: Yuhong Sun Date: Fri, 3 Nov 2023 18:37:01 -0700 Subject: [PATCH] Default Version to 0.2-dev (#690) --- backend/Dockerfile | 7 +-- backend/danswer/__init__.py | 3 +- web/Dockerfile | 6 +-- web/next.config.js | 4 +- web/package-lock.json | 4 +- web/package.json | 2 +- web/src/app/admin/systeminfo/page.tsx | 64 ++++++++++++++------------- web/src/app/auth/login/page.tsx | 5 +-- web/src/components/admin/Layout.tsx | 4 +- web/src/lib/version.ts | 28 ++++++------ 10 files changed, 61 insertions(+), 66 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 4f6730b7a79..a85f76e6ef6 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,12 +1,9 @@ FROM python:3.11.4-slim-bookworm -# Default DANSWER_VERSION build argument set here. -# This can be overridden by passing in a build arg, typically from GitHub Actions. -ARG DANSWER_VERSION=0.1.0 -# Then passed to the container environment. +# Default DANSWER_VERSION, typically overriden during builds by GitHub Actions. +ARG DANSWER_VERSION=0.2-dev ENV DANSWER_VERSION=${DANSWER_VERSION} - # Install system dependencies RUN apt-get update && \ apt-get install -y git cmake pkg-config libprotobuf-c-dev protobuf-compiler \ diff --git a/backend/danswer/__init__.py b/backend/danswer/__init__.py index 7c68536b5e6..b72281154e3 100644 --- a/backend/danswer/__init__.py +++ b/backend/danswer/__init__.py @@ -1,4 +1,3 @@ import os -# Pulls the version from the environment variable DANSWER_VERSION, or defaults to 0.1.0dev. -__version__ = os.environ.get("DANSWER_VERSION", "") or "0.1.0dev" \ No newline at end of file +__version__ = os.environ.get("DANSWER_VERSION", "") or "0.2-dev" diff --git a/web/Dockerfile b/web/Dockerfile index 316b8da77e7..9688844de06 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -1,9 +1,7 @@ FROM node:20-alpine AS base -# Default DANSWER_VERSION build argument set here. -# This can be overridden by passing in a build arg, typically from GitHub Actions. -ARG DANSWER_VERSION=0.1.0 -# Then passed to the container environment. +# Default DANSWER_VERSION, typically overriden during builds by GitHub Actions. +ARG DANSWER_VERSION=0.2-dev ENV DANSWER_VERSION=${DANSWER_VERSION} # Step 1. Install dependencies only when needed diff --git a/web/next.config.js b/web/next.config.js index 96ed9bf6aad..1730d1ef5de 100644 --- a/web/next.config.js +++ b/web/next.config.js @@ -1,8 +1,8 @@ // Get Danswer Web Version -const { version: package_version } = require('./package.json'); // version from package.json +const { version: package_version } = require("./package.json"); // version from package.json const env_version = process.env.DANSWER_VERSION; // version from env variable // Use env version if set & valid, otherwise default to package version -const version = env_version || package_version; +const version = env_version || package_version; /** @type {import('next').NextConfig} */ const nextConfig = { diff --git a/web/package-lock.json b/web/package-lock.json index 89e408caf7f..68ea6b15650 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "qa", - "version": "0.1.0dev", + "version": "0.2-dev", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "qa", - "version": "0.1.0dev", + "version": "0.2-dev", "dependencies": { "@phosphor-icons/react": "^2.0.8", "@tremor/react": "^3.9.2", diff --git a/web/package.json b/web/package.json index eafa73f1cd5..b7abc790055 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "qa", - "version": "0.1.0dev", + "version": "0.2-dev", "private": true, "scripts": { "dev": "next dev", diff --git a/web/src/app/admin/systeminfo/page.tsx b/web/src/app/admin/systeminfo/page.tsx index 7f1b946e080..3ee5fc0c34b 100644 --- a/web/src/app/admin/systeminfo/page.tsx +++ b/web/src/app/admin/systeminfo/page.tsx @@ -1,40 +1,42 @@ import { NotebookIcon } from "@/components/icons/icons"; -import { getWebVersion, getBackendVersion } from "@/lib/version" +import { getWebVersion, getBackendVersion } from "@/lib/version"; const Page = async () => { + let web_version: string | null = null; + let backend_version: string | null = null; + try { + [web_version, backend_version] = await Promise.all([ + getWebVersion(), + getBackendVersion(), + ]); + } catch (e) { + console.log(`Version info fetch failed for system info page - ${e}`); + } - let web_version: string | null = null; - let backend_version: string | null = null; - try { - [web_version, backend_version] = await Promise.all([ - getWebVersion(), - getBackendVersion(), - ]); - } catch (e) { - console.log(`Version info fetch failed for system info page - ${e}`); - } - - return ( -
-
- -

System Information

-
- -
-

Danswer MIT

-
-

Backend Version:

-

{backend_version}

-
-
-

Web Version:

-

{web_version}

-
-
+ return ( +
+
+ +

Version

+
+
+

Danswer MIT

+
+

Backend Version:

+

+ {backend_version} +

+
+
+

Web Version:

+

+ {web_version} +

- ); +
+
+ ); }; export default Page; diff --git a/web/src/app/auth/login/page.tsx b/web/src/app/auth/login/page.tsx index 52cad640c30..da9baf018e7 100644 --- a/web/src/app/auth/login/page.tsx +++ b/web/src/app/auth/login/page.tsx @@ -3,8 +3,7 @@ import { AuthType, OAUTH_NAME } from "@/lib/constants"; import { User } from "@/lib/types"; import { getCurrentUserSS, getAuthUrlSS, getAuthTypeSS } from "@/lib/userSS"; import { redirect } from "next/navigation"; -import { getWebVersion, getBackendVersion } from "@/lib/version" - +import { getWebVersion, getBackendVersion } from "@/lib/version"; const BUTTON_STYLE = "group relative w-64 flex justify-center " + @@ -94,7 +93,7 @@ const Page = async () => {
- VERSION w{ web_version } b{ backend_version } + VERSION w{web_version} b{backend_version}
diff --git a/web/src/components/admin/Layout.tsx b/web/src/components/admin/Layout.tsx index c0c8e9cf1b5..7000ede1cce 100644 --- a/web/src/components/admin/Layout.tsx +++ b/web/src/components/admin/Layout.tsx @@ -318,13 +318,13 @@ export async function Layout({ children }: { children: React.ReactNode }) { ], }, { - name: "Info", + name: "System Information", items: [ { name: (
-
System Information
+
Version
), link: "/admin/systeminfo", diff --git a/web/src/lib/version.ts b/web/src/lib/version.ts index cb2a00a428b..abf892b844c 100644 --- a/web/src/lib/version.ts +++ b/web/src/lib/version.ts @@ -1,27 +1,27 @@ import { buildUrl } from "./utilsSS"; -import getConfig from 'next/config'; +import getConfig from "next/config"; const { publicRuntimeConfig } = getConfig(); const version = publicRuntimeConfig?.version; // Maybe improve type-safety by creating a 'VersionType' instead of generic string export const getBackendVersion = async (): Promise => { - try { - const res = await fetch(buildUrl("/version")); - if (!res.ok) { - //throw new Error("Failed to fetch data"); - return null; - } - - const data: { backend_version: string } = await res.json(); - return data.backend_version as string; - } catch (e) { - console.log(`Error fetching backend version info: ${e}`); - return null; + try { + const res = await fetch(buildUrl("/version")); + if (!res.ok) { + //throw new Error("Failed to fetch data"); + return null; } + + const data: { backend_version: string } = await res.json(); + return data.backend_version as string; + } catch (e) { + console.log(`Error fetching backend version info: ${e}`); + return null; + } }; // Frontend? export const getWebVersion = (): string | null => { - return version; + return version; };