-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-env.sh
executable file
·68 lines (62 loc) · 1.62 KB
/
setup-env.sh
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
#!/bin/bash
if [ ! -z $1 ]; then
if [ $1 = "--no-docker" ]; then
build_docker=false
else
build_docker=true
fi
else
build_docker=true
fi
if [ ! -f ".env" ]; then
echo "Refer to sample.env to make .env file as per your project"
echo "See README for more details"
exit 2
fi
if [ -f "lock.env" ]; then
source "lock.env"
if [ "$build_docker" = true ]; then
docker rmi copynet-tf/bash:latest
docker rmi copynet-tf/nb:latest
fi
rm -rf $PYTHON_VENV_PATH
rm ./data
rm "lock.env"
fi
source ".env"
if [ -z "$DATA_DIR" ]; then
echo ".env should set DATA_DIR"
exit 1
fi
if [ -z "$PYTHON_VENV_PATH" ]; then
echo ".env should set PYTHON_VENV_PATH"
exit 1
fi
if [ "$build_docker" = true ]; then
if [ -z "$JUPYTER_PASSWD" ]; then
echo ".env should set JUPYTER_PASSWD"
exit 1
fi
fi
ln -s $DATA_DIR ./data
if [ "$build_docker" = true ]; then
docker build --build-arg JUPYTER_PASSWD --target bash -t copynet-tf/bash:latest .
docker build --build-arg JUPYTER_PASSWD --target nb -t copynet-tf/nb:latest .
fi
python3 -m venv $PYTHON_VENV_PATH
source $PYTHON_VENV_PATH/bin/activate\
&& pip install --upgrade pip setuptools\
&& pip install --no-cache-dir -r requirements.txt\
&& python -m spacy download en_core_web_sm
cp ".env" "lock.env"
echo "***Environment is ready***"
if [ "$build_docker" = true ]; then
echo ""
echo "-- Docker images prepared --"
echo "copynet-tf/bash:latest"
echo "copynet-tf/nb:latest"
echo ""
echo "-- Run commands --"
echo "./start-env.sh bash"
echo "./start-env.sh nb"
fi