forked from arviz-devs/arviz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
container.ps1
86 lines (77 loc) · 2.61 KB
/
container.ps1
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
if (!(Test-Path env:SRC_DIR)) {
$SRC_DIR=$pwd.Path
}
$build = $false
$clearCache = $false
$docs = $false
$lab = $false
$notebook = $false
$shell = $false
$test = $false
foreach ($arg in $args) {
if ($arg -eq "--build") {
$build = $true
}
elseif ($arg -eq "--clear-cache") {
$clearCache = $true
}
elseif ($arg -eq "--docs") {
$docs = $true
}
elseif ($arg -eq "--lab") {
$lab = $true
}
elseif ($arg -eq "--notebook") {
$notebook = $true
}
elseif ($arg -eq "--shell") {
$shell = $true
}
elseif ($arg -eq "--test") {
$test = $true
}
}
if ($build) {
echo "Building Docker Image"
# Build container for use of testing or notebook
docker build `
-t arviz `
-f $SRC_DIR/scripts/Dockerfile `
--build-arg SRC_DIR=. $SRC_DIR `
--build-arg PYTHON_VERSION=${PYTHON_VERSION} `
--build-arg PYSTAN_VERSION=${PYSTAN_VERSION} `
--build-arg PYRO_VERSION=${PYRO_VERSION} `
--build-arg PYTORCH_VERSION=${PYTORCH_VERSION} `
--build-arg EMCEE_VERSION=${EMCEE_VERSION} `
--build-arg TF_VERSION=${TF_VERSION} `
--build-arg PYMC3_VERSION=${PYMC3_VERSION}
}
if ($clearCache) {
echo "Removing cached files and models"
Get-ChildItem -Path $SRC_DIR -Recurse -Force -Include "__pycache__" | Remove-Item -Force -Recurse
Get-ChildItem -Path ($SRC_DIR + "\arviz\tests\saved_models") -Recurse -Force -Include "*.pkl" | Remove-Item -Force -Recurse
}
if ($test) {
echo "Testing Arviz"
docker run --mount type=bind,source=$SRC_DIR,target=/opt/arviz/ --rm arviz:latest bash -c `
"NUMBA_DISABLE_JIT=1 pytest -v arviz/tests/ --cov=arviz/"
}
if ($docs) {
echo "Build docs with sphinx"
docker run --mount type=bind,source=$SRC_DIR,target=/opt/arviz --name arviz_sphinx --rm arviz:latest bash -c `
"if [ -d ./doc/build ]; then python -msphinx -M clean doc doc/build; fi && sphinx-build doc doc/build -b html"
}
if ($shell) {
echo "Starting Arviz Container Shell"
docker run -it --mount type=bind,source=$SRC_DIR,target=/opt/arviz --name arviz_shell --rm arviz:latest /bin/bash
}
if ($notebook) {
echo "Starting Arviz Container Jupyter server"
docker run --mount type=bind,source=$SRC_DIR,target=/opt/arviz/ --name jupyter-dock -it -d -p 8888:8888 arviz
docker exec -it jupyter-dock bash -c "jupyter notebook --ip 0.0.0.0 --no-browser --allow-root"
}
if ($lab) {
echo "Starting Arviz Container Jupyter server with Jupyter Lab interface"
docker run --mount type=bind,source=$SRC_DIR,target=/opt/arviz/ --name jupyter-dock -it -d -p 8888:8888 arviz
docker exec -it jupyter-dock bash -c "jupyter lab --ip 0.0.0.0 --no-browser --allow-root"
}