Skip to content

Commit

Permalink
Default Version to 0.2-dev (#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhongsun96 authored Nov 4, 2023
1 parent 551705a commit 602f9c4
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 66 deletions.
7 changes: 2 additions & 5 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
3 changes: 1 addition & 2 deletions backend/danswer/__init__.py
Original file line number Diff line number Diff line change
@@ -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"
__version__ = os.environ.get("DANSWER_VERSION", "") or "0.2-dev"
6 changes: 2 additions & 4 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions web/next.config.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qa",
"version": "0.1.0dev",
"version": "0.2-dev",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
64 changes: 33 additions & 31 deletions web/src/app/admin/systeminfo/page.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div>
<div className="border-solid border-gray-600 border-b pb-2 mb-4 flex">
<NotebookIcon size={32} />
<h1 className="text-3xl font-bold pl-2">System Information</h1>
</div>

<div>
<p className="font-bold text-lg my-auto mb-2">Danswer MIT</p>
<div className="flex mb-2">
<p className="my-auto mr-1">Backend Version: </p>
<p className="text-base my-auto text-slate-400 italic">{backend_version}</p>
</div>
<div className="flex mb-2">
<p className="my-auto mr-1">Web Version: </p>
<p className="text-base my-auto text-slate-400 italic">{web_version}</p>
</div>
</div>
return (
<div>
<div className="border-solid border-gray-600 border-b pb-2 mb-4 flex">
<NotebookIcon size={32} />
<h1 className="text-3xl font-bold pl-2">Version</h1>
</div>

<div>
<p className="font-bold text-lg my-auto mb-2">Danswer MIT</p>
<div className="flex mb-2">
<p className="my-auto mr-1">Backend Version: </p>
<p className="text-base my-auto text-slate-400 italic">
{backend_version}
</p>
</div>
<div className="flex mb-2">
<p className="my-auto mr-1">Web Version: </p>
<p className="text-base my-auto text-slate-400 italic">
{web_version}
</p>
</div>
);
</div>
</div>
);
};

export default Page;
5 changes: 2 additions & 3 deletions web/src/app/auth/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 " +
Expand Down Expand Up @@ -94,7 +93,7 @@ const Page = async () => {
</div>
</div>
<div className="fixed bottom-4 right-4 z-50 text-slate-400 p-2">
VERSION w{ web_version } b{ backend_version }
VERSION w{web_version} b{backend_version}
</div>
</div>
</main>
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/admin/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,13 @@ export async function Layout({ children }: { children: React.ReactNode }) {
],
},
{
name: "Info",
name: "System Information",
items: [
{
name: (
<div className="flex">
<NotebookIcon size={18} />
<div className="ml-1">System Information</div>
<div className="ml-1">Version</div>
</div>
),
link: "/admin/systeminfo",
Expand Down
28 changes: 14 additions & 14 deletions web/src/lib/version.ts
Original file line number Diff line number Diff line change
@@ -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<string | 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;
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;
};

1 comment on commit 602f9c4

@vercel
Copy link

@vercel vercel bot commented on 602f9c4 Nov 4, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.