DenyTranDFW commited on
Commit
94aa430
·
verified ·
1 Parent(s): 13acdf7

Update setup.cmd with real HF URLs, 7z download+extract, and correct .env variable names

Browse files
Files changed (1) hide show
  1. sec_fsnds_setup.cmd +84 -41
sec_fsnds_setup.cmd CHANGED
@@ -4,12 +4,14 @@ REM sec_fsnds - Local Docker setup
4
  REM ============================================================
5
  REM This script:
6
  REM 1. Asks the user for the values that differ per-host
7
- REM (sa password, port, data dir, container name, memory)
8
  REM 2. Writes a .env file that docker compose will read
9
  REM 3. Downloads Dockerfile + docker-compose.yaml from Hugging Face
10
- REM 4. Downloads the sec_fsnds database files from Hugging Face
 
11
  REM
12
- REM Requires: curl (built in on Windows 10 1803+) and Docker Desktop
 
13
  REM ============================================================
14
 
15
  setlocal EnableDelayedExpansion
@@ -21,29 +23,45 @@ echo ============================================================
21
  echo.
22
 
23
  REM -------------------------------------------------------------
24
- REM Hugging Face URLs -- REPLACE BEFORE SHARING
25
  REM -------------------------------------------------------------
26
- set "HF_REPO=https://huggingface.co/datasets/PLACEHOLDER_USER/PLACEHOLDER_REPO/resolve/main"
27
  set "HF_DOCKERFILE=%HF_REPO%/Dockerfile"
28
  set "HF_COMPOSE=%HF_REPO%/docker-compose.yaml"
29
- set "HF_MDF=%HF_REPO%/sec_fsnds.mdf"
30
- set "HF_LDF=%HF_REPO%/sec_fsnds_log.ldf"
 
 
31
 
32
  REM -------------------------------------------------------------
33
- REM Sanity check: curl must be on PATH
34
  REM -------------------------------------------------------------
35
  where curl >nul 2>nul
36
  if errorlevel 1 (
37
  echo ERROR: curl.exe was not found on PATH.
38
- echo curl ships with Windows 10 1803 and later. Please
39
- echo install curl or update Windows before running this
40
- echo script.
41
  exit /b 1
42
  )
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  REM -------------------------------------------------------------
45
  REM Prompts
46
  REM -------------------------------------------------------------
 
47
  echo You will be asked a few questions. Press Enter to accept the
48
  echo value shown in [brackets].
49
  echo.
@@ -56,17 +74,14 @@ if "!SA_PASSWORD!"=="" (
56
  goto ask_password
57
  )
58
 
59
- set "HOST_PORT=1433"
60
- set /p "HOST_PORT=Host port to expose SQL Server on [1433]: "
61
 
62
  set "CONTAINER_NAME=mssql-sec-fsnds"
63
  set /p "CONTAINER_NAME=Docker container name [mssql-sec-fsnds]: "
64
 
65
- set "DATA_DIR=%CD%\data"
66
- set /p "DATA_DIR=Host directory for database files [%CD%\data]: "
67
-
68
- set "MEM_LIMIT=4g"
69
- set /p "MEM_LIMIT=Memory limit for the container (e.g. 2g, 4g, 8g) [4g]: "
70
 
71
  set "MSSQL_PID=Developer"
72
  set /p "MSSQL_PID=SQL Server edition (Developer/Express/Standard/Enterprise) [Developer]: "
@@ -76,8 +91,7 @@ echo --- Summary ---
76
  echo sa password : (hidden)
77
  echo host port : !HOST_PORT!
78
  echo container : !CONTAINER_NAME!
79
- echo data dir : !DATA_DIR!
80
- echo memory : !MEM_LIMIT!
81
  echo edition : !MSSQL_PID!
82
  echo.
83
 
@@ -95,12 +109,12 @@ echo.
95
  echo --- Writing .env ---
96
  (
97
  echo # Generated by sec_fsnds_setup.cmd - do not commit this file
98
- echo SA_PASSWORD=!SA_PASSWORD!
 
 
99
  echo HOST_PORT=!HOST_PORT!
100
  echo CONTAINER_NAME=!CONTAINER_NAME!
101
- echo DATA_DIR=!DATA_DIR!
102
- echo MEM_LIMIT=!MEM_LIMIT!
103
- echo MSSQL_PID=!MSSQL_PID!
104
  ) > .env
105
  if errorlevel 1 (
106
  echo ERROR: could not write .env
@@ -111,11 +125,11 @@ echo Wrote .env
111
  REM -------------------------------------------------------------
112
  REM Create data directory
113
  REM -------------------------------------------------------------
114
- if not exist "!DATA_DIR!" (
115
- echo --- Creating data directory !DATA_DIR! ---
116
- mkdir "!DATA_DIR!"
117
  if errorlevel 1 (
118
- echo ERROR: could not create !DATA_DIR!
119
  exit /b 1
120
  )
121
  )
@@ -140,25 +154,47 @@ if errorlevel 1 (
140
  )
141
 
142
  REM -------------------------------------------------------------
143
- REM Download database files (large - use -C - to resume)
 
144
  REM -------------------------------------------------------------
145
  echo.
146
- echo --- Downloading sec_fsnds.mdf (this is large - may take a while) ---
147
- curl -L --fail --retry 5 -C - -o "!DATA_DIR!\sec_fsnds.mdf" "%HF_MDF%"
148
- if errorlevel 1 (
149
- echo ERROR: sec_fsnds.mdf download failed.
150
- echo Re-run this script to resume the download.
151
- exit /b 1
 
 
 
 
 
 
 
152
  )
153
 
 
 
 
154
  echo.
155
- echo --- Downloading sec_fsnds_log.ldf ---
156
- curl -L --fail --retry 5 -C - -o "!DATA_DIR!\sec_fsnds_log.ldf" "%HF_LDF%"
157
  if errorlevel 1 (
158
- echo ERROR: sec_fsnds_log.ldf download failed.
159
- echo Re-run this script to resume the download.
160
  exit /b 1
161
  )
 
 
 
 
 
 
 
 
 
 
 
 
162
 
163
  echo.
164
  echo ============================================================
@@ -167,8 +203,8 @@ echo ============================================================
167
  echo.
168
  echo Next steps:
169
  echo.
170
- echo 1. Start the container:
171
- echo docker compose up -d
172
  echo.
173
  echo 2. Watch the logs until "SQL Server is now ready":
174
  echo docker compose logs -f
@@ -179,8 +215,15 @@ echo User : sa
179
  echo Password : (what you entered)
180
  echo Database : sec_fsnds
181
  echo.
 
 
 
 
182
  echo Your .env file holds the values above. Keep it out of source
183
  echo control -- it contains the sa password in plaintext.
184
  echo.
 
 
 
185
 
186
  endlocal
 
4
  REM ============================================================
5
  REM This script:
6
  REM 1. Asks the user for the values that differ per-host
7
+ REM (sa password, port, data dir, container name, edition)
8
  REM 2. Writes a .env file that docker compose will read
9
  REM 3. Downloads Dockerfile + docker-compose.yaml from Hugging Face
10
+ REM 4. Downloads the 4-part 7z archive (~40 GB total) from HF
11
+ REM 5. Extracts sec_fsnds.mdf + sec_fsnds_log.ldf into the data dir
12
  REM
13
+ REM Requires: curl (built in on Windows 10 1803+), Docker Desktop,
14
+ REM and 7-Zip (7z.exe) on PATH or at the default install path
15
  REM ============================================================
16
 
17
  setlocal EnableDelayedExpansion
 
23
  echo.
24
 
25
  REM -------------------------------------------------------------
26
+ REM Hugging Face URLs
27
  REM -------------------------------------------------------------
28
+ set "HF_REPO=https://huggingface.co/datasets/DenyTranDFW/SEC-Financial-Statements-And-Notes-Dataset/resolve/main"
29
  set "HF_DOCKERFILE=%HF_REPO%/Dockerfile"
30
  set "HF_COMPOSE=%HF_REPO%/docker-compose.yaml"
31
+ set "HF_VOL1=%HF_REPO%/archive/sec_fsnds_db_4vol.7z.001"
32
+ set "HF_VOL2=%HF_REPO%/archive/sec_fsnds_db_4vol.7z.002"
33
+ set "HF_VOL3=%HF_REPO%/archive/sec_fsnds_db_4vol.7z.003"
34
+ set "HF_VOL4=%HF_REPO%/archive/sec_fsnds_db_4vol.7z.004"
35
 
36
  REM -------------------------------------------------------------
37
+ REM Sanity checks: curl and 7z must be available
38
  REM -------------------------------------------------------------
39
  where curl >nul 2>nul
40
  if errorlevel 1 (
41
  echo ERROR: curl.exe was not found on PATH.
42
+ echo curl ships with Windows 10 1803 and later.
 
 
43
  exit /b 1
44
  )
45
 
46
+ set "SEVENZIP="
47
+ where 7z >nul 2>nul
48
+ if not errorlevel 1 (
49
+ set "SEVENZIP=7z"
50
+ ) else if exist "C:\Program Files\7-Zip\7z.exe" (
51
+ set "SEVENZIP=C:\Program Files\7-Zip\7z.exe"
52
+ ) else (
53
+ echo ERROR: 7-Zip (7z.exe) was not found on PATH or at
54
+ echo C:\Program Files\7-Zip\7z.exe
55
+ echo Download from https://www.7-zip.org and install before
56
+ echo running this script.
57
+ exit /b 1
58
+ )
59
+ echo Found 7-Zip: !SEVENZIP!
60
+
61
  REM -------------------------------------------------------------
62
  REM Prompts
63
  REM -------------------------------------------------------------
64
+ echo.
65
  echo You will be asked a few questions. Press Enter to accept the
66
  echo value shown in [brackets].
67
  echo.
 
74
  goto ask_password
75
  )
76
 
77
+ set "HOST_PORT=1434"
78
+ set /p "HOST_PORT=Host port to expose SQL Server on [1434]: "
79
 
80
  set "CONTAINER_NAME=mssql-sec-fsnds"
81
  set /p "CONTAINER_NAME=Docker container name [mssql-sec-fsnds]: "
82
 
83
+ set "HOST_DATA_DIR=%CD%\data"
84
+ set /p "HOST_DATA_DIR=Host directory for database files [%CD%\data]: "
 
 
 
85
 
86
  set "MSSQL_PID=Developer"
87
  set /p "MSSQL_PID=SQL Server edition (Developer/Express/Standard/Enterprise) [Developer]: "
 
91
  echo sa password : (hidden)
92
  echo host port : !HOST_PORT!
93
  echo container : !CONTAINER_NAME!
94
+ echo data dir : !HOST_DATA_DIR!
 
95
  echo edition : !MSSQL_PID!
96
  echo.
97
 
 
109
  echo --- Writing .env ---
110
  (
111
  echo # Generated by sec_fsnds_setup.cmd - do not commit this file
112
+ echo ACCEPT_EULA=Y
113
+ echo MSSQL_SA_PASSWORD=!SA_PASSWORD!
114
+ echo MSSQL_PID=!MSSQL_PID!
115
  echo HOST_PORT=!HOST_PORT!
116
  echo CONTAINER_NAME=!CONTAINER_NAME!
117
+ echo HOST_DATA_DIR=!HOST_DATA_DIR!
 
 
118
  ) > .env
119
  if errorlevel 1 (
120
  echo ERROR: could not write .env
 
125
  REM -------------------------------------------------------------
126
  REM Create data directory
127
  REM -------------------------------------------------------------
128
+ if not exist "!HOST_DATA_DIR!" (
129
+ echo --- Creating data directory !HOST_DATA_DIR! ---
130
+ mkdir "!HOST_DATA_DIR!"
131
  if errorlevel 1 (
132
+ echo ERROR: could not create !HOST_DATA_DIR!
133
  exit /b 1
134
  )
135
  )
 
154
  )
155
 
156
  REM -------------------------------------------------------------
157
+ REM Download database archive volumes (~10 GB each, ~40 GB total)
158
+ REM curl -C - enables resume if a download is interrupted.
159
  REM -------------------------------------------------------------
160
  echo.
161
+ echo --- Downloading database archive (4 volumes, ~40 GB total) ---
162
+ echo This will take a while. If interrupted, re-run the script
163
+ echo and curl will resume where it left off.
164
+ echo.
165
+
166
+ for %%V in (001 002 003 004) do (
167
+ echo --- Downloading sec_fsnds_db_4vol.7z.%%V ---
168
+ curl -L --fail --retry 5 -C - -o "!HOST_DATA_DIR!\sec_fsnds_db_4vol.7z.%%V" "!HF_REPO!/archive/sec_fsnds_db_4vol.7z.%%V"
169
+ if errorlevel 1 (
170
+ echo ERROR: sec_fsnds_db_4vol.7z.%%V download failed.
171
+ echo Re-run this script to resume.
172
+ exit /b 1
173
+ )
174
  )
175
 
176
+ REM -------------------------------------------------------------
177
+ REM Extract the archive
178
+ REM -------------------------------------------------------------
179
  echo.
180
+ echo --- Extracting database files (293 GB, may take 10-20 min) ---
181
+ "!SEVENZIP!" x -o"!HOST_DATA_DIR!" "!HOST_DATA_DIR!\sec_fsnds_db_4vol.7z.001" -y
182
  if errorlevel 1 (
183
+ echo ERROR: 7z extraction failed.
 
184
  exit /b 1
185
  )
186
+ echo Extraction complete.
187
+
188
+ REM Verify the extracted files exist
189
+ if not exist "!HOST_DATA_DIR!\sec_fsnds.mdf" (
190
+ echo ERROR: sec_fsnds.mdf not found after extraction.
191
+ exit /b 1
192
+ )
193
+ if not exist "!HOST_DATA_DIR!\sec_fsnds_log.ldf" (
194
+ echo ERROR: sec_fsnds_log.ldf not found after extraction.
195
+ exit /b 1
196
+ )
197
+ echo Verified: sec_fsnds.mdf and sec_fsnds_log.ldf present.
198
 
199
  echo.
200
  echo ============================================================
 
203
  echo.
204
  echo Next steps:
205
  echo.
206
+ echo 1. Build and start the container:
207
+ echo docker compose up -d --build
208
  echo.
209
  echo 2. Watch the logs until "SQL Server is now ready":
210
  echo docker compose logs -f
 
215
  echo Password : (what you entered)
216
  echo Database : sec_fsnds
217
  echo.
218
+ echo 4. (Optional) Install stored procedures:
219
+ echo Download the sql/ folder from the Hugging Face repo
220
+ echo and run each .sql file with sqlcmd -i
221
+ echo.
222
  echo Your .env file holds the values above. Keep it out of source
223
  echo control -- it contains the sa password in plaintext.
224
  echo.
225
+ echo You can safely delete the .7z archive volumes from !HOST_DATA_DIR!
226
+ echo after verifying the database starts correctly.
227
+ echo.
228
 
229
  endlocal