-
Notifications
You must be signed in to change notification settings - Fork 7
/
run.bat
115 lines (92 loc) · 3.4 KB
/
run.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
SET PATHFILE=dataset_curation_path.txt
SET UPDATE_ENV=0
echo Use --update on the command line with the run file to update the program!
SET "OTHER_ARGS="
REM Check each argument
FOR %%a IN (%*) DO (
IF "%%a"=="--update" (
SET UPDATE_ENV=1
) ELSE (
SET "OTHER_ARGS=!OTHER_ARGS! %%a"
)
)
echo Check if conda command is available
IF EXIST "%UserProfile%\Miniconda3\Scripts\conda.exe" (
echo Miniconda is already installed.
REM Add Miniconda to the current session's PATH
SET PATH=!UserProfile!\Miniconda3;!UserProfile!\Miniconda3\Scripts;!PATH!
) ELSE (
echo Miniconda is not installed. Installing now...
REM Downloading Miniconda3 for Windows
curl -o miniconda.exe https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe
miniconda.exe /InstallationType=JustMe /RegisterPython=0 /S /D=%UserProfile%\Miniconda3
DEL miniconda.exe
SET PATH=!UserProfile!\Miniconda3;!UserProfile!\Miniconda3\Scripts;!PATH!
)
echo Check if we have a stored path
if exist "%PATHFILE%" (
set /p STORED_PATH=<"%PATHFILE%"
cd /d "%STORED_PATH%"
) else (
echo Check if the current directory is "Dataset-Curation-Tool"
IF "%cd%" NEQ "%cd:\Dataset-Curation-Tool=%" (
echo Already in 'Dataset-Curation-Tool' directory.
) ELSE (
echo Check and clone the GitHub repository if not already cloned
IF NOT EXIST Dataset-Curation-Tool (
git clone https://github.com/x-CK-x/Dataset-Curation-Tool.git
cd Dataset-Curation-Tool
SET UPDATE_ENV=1
) ELSE (
echo Repository already exists. Please move to a different directory to clone again.
cd Dataset-Curation-Tool
)
)
echo Store the current path for future use
echo %cd% > "%PATHFILE%"
)
echo Delete the specified files
DEL /Q /F linux_run.sh mac_run.sh run.bat
echo Fetch the latest changes and tags
git fetch
echo Check the current tag
FOR /F "delims=" %%i IN ('git for-each-ref refs/tags --sort=-creatordate --format "%%(refname:short)" --count=1') DO SET LATEST_TAG=%%i
FOR /F "delims=" %%i IN ('git describe --tags --exact-match 2^>nul') DO SET CURRENT_TAG=%%i
IF NOT "%CURRENT_TAG%"=="%LATEST_TAG%" (
echo Currently on %CURRENT_TAG%.
git reset HEAD linux_run.sh mac_run.sh run.bat
git checkout -- linux_run.sh mac_run.sh run.bat
echo Stash any user changes
git stash
FOR /R . %%i IN (__pycache__) DO IF EXIST "%%i" RD /S /Q "%%i"
FOR /R . %%i IN (*.pyc) DO IF EXIST "%%i" DEL /Q "%%i"
echo checking out to %LATEST_TAG%.
git checkout tags/%LATEST_TAG%
echo Apply stashed user changes
git stash apply
SET UPDATE_ENV=1
) ELSE (
echo Already on tag %LATEST_TAG%.
)
echo Check if the conda environment already exists
call conda info --envs | findstr /C:"data-curation" >nul
if %errorlevel% neq 0 (
call conda env create -f environment.yml
) else (
IF "%UPDATE_ENV%"=="1" (
echo Conda environment 'data-curation' already exists. Checking for updates...
call conda env update -n data-curation -f environment.yml
)
)
echo Activate the conda environment
call activate data-curation
REM Run the python program without --update
python webui.py%OTHER_ARGS%
IF ERRORLEVEL 1 (
echo Error encountered. Press any key to exit.
pause >nul
)
start http://localhost:7860
ENDLOCAL