Skip to content

Commit 1c26cd8

Browse files
authored
Merge pull request #1985 from DrAcula27/dev-env-variable-checks-1976
add support for DEV environment variables
2 parents f748116 + 0241c83 commit 1c26cd8

4 files changed

Lines changed: 36 additions & 24 deletions

File tree

.example.env

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
VITE_MAPBOX_TOKEN=REDACTED
2-
MAPBOX_STREETS_URL=https://api.mapbox.com/styles/v1/mapbox/streets-v11/tiles/{z}/{x}/{y}
1+
HUGGINGFACE_LOGIN_TOKEN=REDACTED
32
MAPBOX_SATELLITE_URL=https://api.mapbox.com/styles/v1/mapbox/satellite-streets-v11/tiles/{z}/{x}/{y}
3+
MAPBOX_STREETS_URL=https://api.mapbox.com/styles/v1/mapbox/streets-v11/tiles/{z}/{x}/{y}
4+
VITE_ENV=DEV
5+
VITE_CONTACT_FORM=REDACTED
46
VITE_CONTENTFUL_SPACE=REDACTED
57
VITE_CONTENTFUL_TOKEN=REDACTED
6-
HUGGINGFACE_LOGIN_TOKEN=REDACTED
8+
VITE_MAPBOX_TOKEN=REDACTED

components/contact/ContactForm.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function ContactForm() {
2424
<div className={classes.formContainer}>
2525
{/* Embed the Google Form */}
2626
<iframe
27-
src="https://docs.google.com/forms/d/e/1FAIpQLScrhJY9ezqlKcpYermIImgGKYZ4bP2k1BRAOpuEay-tVXfvdQ/viewform?embedded=true"
27+
src={import.meta.env.VITE_CONTACT_FORM}
2828
className={classes.iframe}
2929
title="Contact Form"
3030
>

components/db/DbProvider.jsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ import Worker from 'web-worker';
1010
import DbContext from '@db/DbContext';
1111
import moment from 'moment';
1212

13+
const hf_account = import.meta.env.VITE_ENV === 'DEV' ? '311-Data-Dev' : '311-data';
14+
1315
// List of remote dataset locations used by db.registerFileURL
1416
const datasets = {
1517
parquet: {
1618
// huggingface
17-
//* Quick fix - update url when 2025 data available
1819
hfYtd2025:
19-
'https://huggingface.co/datasets/311-data/2024/resolve/main/2024.parquet', // 2025 year-to-date
20+
`https://huggingface.co/datasets/${hf_account}/2025/resolve/main/2025.parquet`, // 2025 year-to-date
2021
hfYtd2024:
21-
'https://huggingface.co/datasets/311-data/2024/resolve/main/2024.parquet', // 2024 year-to-date
22+
`https://huggingface.co/datasets/${hf_account}/2024/resolve/main/2024.parquet`, // 2024 entire year
2223
hfYtd2023:
23-
'https://huggingface.co/datasets/311-data/2023/resolve/main/2023.parquet', // 2023 entire year
24+
`https://huggingface.co/datasets/${hf_account}/2023/resolve/main/2023.parquet`, // 2023 entire year
2425
hfYtd2022:
25-
'https://huggingface.co/datasets/311-data/2022/resolve/main/2022.parquet', // 2022 entire year
26+
`https://huggingface.co/datasets/${hf_account}/2022/resolve/main/2022.parquet`, // 2022 entire year
2627
hfYtd2021:
27-
'https://huggingface.co/datasets/311-data/2021/resolve/main/2021.parquet', // 2021 entire year
28+
`https://huggingface.co/datasets/${hf_account}/2021/resolve/main/2021.parquet`, // 2021 entire year
2829
hfYtd2020:
29-
'https://huggingface.co/datasets/311-data/2020/resolve/main/2020.parquet', // 2020 entire year
30+
`https://huggingface.co/datasets/${hf_account}/2020/resolve/main/2020.parquet`, // 2020 entire year
3031
},
3132
};
32-
3333
function DbProvider({ children, startDate }) {
3434
const [db, setDb] = useState(null);
3535
const [conn, setConn] = useState(null);
@@ -69,7 +69,7 @@ function DbProvider({ children, startDate }) {
6969
await newDb.registerFileURL(
7070
'requests2025.parquet',
7171
//* Quick fix - change hfYtd2024 to hfYtd2025 when 2025 data available
72-
datasets.parquet.hfYtd2024,
72+
datasets.parquet.hfYtd2025,
7373
4, // HTTP = 4. For more options: https://tinyurl.com/DuckDBDataProtocol
7474
);
7575

scripts/updateHfDataset.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,24 @@
77
from dotenv import load_dotenv
88
load_dotenv()
99

10+
# set environment as 'dev' or 'prod'
11+
ENV = os.getenv('VITE_ENV').upper()
12+
13+
if ENV == 'DEV':
14+
HF_USERNAME = '311-Data-Dev'
15+
elif ENV == 'PROD':
16+
HF_USERNAME = '311-data'
17+
else:
18+
# exit out of the program with an error message
19+
print('Incorrect environment variable set for VITE_ENV.')
20+
exit(1)
1021

1122
def dlData():
1223
'''
13-
Download the dataset from data.lacity.org
24+
Download the current year's dataset from data.lacity.org
1425
'''
15-
url = "https://data.lacity.org/api/views/b7dx-7gc3/rows.csv?accessType=DOWNLOAD"
16-
outfile = "2024.csv"
26+
url = "https://data.lacity.org/api/views/h73f-gn57/rows.csv?accessType=DOWNLOAD"
27+
outfile = "2025.csv"
1728

1829
response = requests.get(url, stream=True)
1930

@@ -27,9 +38,9 @@ def hfClean():
2738
'''
2839
Clean the dataset by removing problematic string combinations and update timestamp to ISO format
2940
'''
30-
infile = "2024.csv"
31-
fixed_filename = "2024-fixed.csv"
32-
clean_filename = "2024-clean.parquet"
41+
infile = "2025.csv"
42+
fixed_filename = "2025-fixed.csv"
43+
clean_filename = "2025-clean.parquet"
3344

3445
# List of problmenatic strings to be replaced with ""
3546
replace_strings = ["VE, 0"]
@@ -58,13 +69,12 @@ def hfUpload():
5869
'''
5970
Upload the clean dataset to huggingface.co
6071
'''
61-
local_filename = '2024-clean.parquet'
62-
dest_filename = '2024.parquet'
63-
username = '311-data'
64-
repo_name = '2024'
72+
local_filename = '2025-clean.parquet'
73+
dest_filename = '2025.parquet'
74+
repo_name = '2025'
6575
repo_type = 'dataset'
6676

67-
repo_id = f"{username}/{repo_name}"
77+
repo_id = f"{HF_USERNAME}/{repo_name}"
6878
TOKEN = os.getenv('HUGGINGFACE_LOGIN_TOKEN')
6979

7080
login(TOKEN)

0 commit comments

Comments
 (0)