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

Updates for SFA forecasting UI datasets #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions viz/.env.us-states
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# US states
VITE_URL_PATH_BASE=/forecasts-ncov-us-states/
VITE_DATA_PREFIX=us_states/us_

VITE_DATA_BASE_URL=https://covidforecasting.brotmanbaty.org/data
5 changes: 5 additions & 0 deletions viz/.env.wa-state
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# WA state
VITE_URL_PATH_BASE=/forecasts-ncov-wa/
VITE_DATA_PREFIX=wa/wa_

VITE_DATA_BASE_URL=https://covidforecasting.brotmanbaty.org/data
4 changes: 2 additions & 2 deletions viz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"build": "vite build --mode=${MODE=us-states}",
"preview": "vite preview --mode=${MODE=us-states}",
"start:local": "bash ./scripts/run-local.sh production",
"start:local:dev": "bash ./scripts/run-local.sh"
},
Expand Down
11 changes: 6 additions & 5 deletions viz/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { PanelDisplay, useModelData } from '@nextstrain/evofr-viz';
import '@nextstrain/evofr-viz/dist/index.css';

const customAddress = !!import.meta.env.VITE_DATA_HOST;
const customAddress = !!import.meta.env.VITE_DATA_BASE_URL;

const mlrCladesConfig = {
modelName: "mlr_clades",
modelUrl: customAddress ?
`${import.meta.env.VITE_DATA_HOST}/${import.meta.env.VITE_CLADES_PATH}` :
`https://nextstrain-data.s3.amazonaws.com/files/workflows/forecasts-ncov/gisaid/nextstrain_clades/global/mlr/latest_results.json`,
`${import.meta.env.VITE_DATA_BASE_URL}/${import.meta.env.VITE_DATA_PREFIX}nextstrain_clades.json`
: `https://nextstrain-data.s3.amazonaws.com/files/workflows/forecasts-ncov/gisaid/nextstrain_clades/global/mlr/latest_results.json`,
}
const mlrLineagesConfig = {
modelName: "mlr_lineages",
modelUrl: customAddress ?
`${import.meta.env.VITE_DATA_HOST}/${import.meta.env.VITE_LINEAGES_PATH}` :
`https://nextstrain-data.s3.amazonaws.com/files/workflows/forecasts-ncov/gisaid/pango_lineages/global/mlr/latest_results.json`,
`${import.meta.env.VITE_DATA_BASE_URL}/${import.meta.env.VITE_DATA_PREFIX}pango_lineages.json`
: `https://nextstrain-data.s3.amazonaws.com/files/workflows/forecasts-ncov/gisaid/pango_lineages/global/mlr/latest_results.json`,
}

function App() {
Expand Down
16 changes: 10 additions & 6 deletions viz/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { defineConfig } from 'vite'
import {defineConfig, loadEnv} from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
// The base must match repo name since we are deploying the site to https://nextstrain.github.io/forecasts-ncov/
// See vite docs on deploying to GH pages: https://vitejs.dev/guide/static-deploy.html#github-pages
base: "/forecasts-ncov/",
plugins: [react()],
export default defineConfig(({mode}) => {
const env = loadEnv(mode, process.cwd(), '')
return {
// The base is specific to each vite MODE environment, since we are deploying to:
// https://covidforecasting.brotmanbaty.org/forecasts-ncov-wa/index.html and
// https://covidforecasting.brotmanbaty.org/forecasts-ncov-us-states/index.html
base: env.VITE_URL_PATH_BASE,
plugins: [react()],
}
})