forked from equinor/team-dogleg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.ps1
57 lines (51 loc) · 2.04 KB
/
run.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
# A powershell script to easier run Dockerized container
param (
# Flag switches
[switch]$build = $false,
[switch]$b = $false,
[switch]$run = $false,
[switch]$r = $false,
[switch]$auto = $false,
[switch]$a = $false,
# Arguments for python script
$action = $args[0],
$name = $args[1],
$algorithm = $args[2],
$timesteps = $args[3],
$new_save_name = $args[4]
)
$global:container_name = "auto_well_path"
$global:container_running_name = "auto_well_path_run"
$global:python_filename = "main.py"
function build_container {
docker build -t $container_name . ; if ($?) {Write-Output "Success!"} else {Write-Output "Error!"}
}
# A bad attempt at ignoring the return output form the delete command
function run_container {
# We run with detached mode to avoid python image blocking
try{
delete_running($container_running_name)
}
catch{
docker run -dit --mount type=bind,source="$(pwd)",target=/usr/src/app -p 0.0.0.0:6006:6006 -p 0.0.0.0:8988:8988 --name $container_running_name $container_name
}
docker run -dit --mount type=bind,source="$(pwd)",target=/usr/src/app -p 0.0.0.0:6006:6006 -p 0.0.0.0:8988:8988 --name $container_running_name $container_name
}
function run_python_script($filename,$action,$name,$algorithm,$timesteps,$new_save_name){
docker exec -it $container_running_name python $filename $action $name $algorithm $timesteps $new_save_name
}
function run_tensorboard {
docker exec -dit $container_running_name tensorboard --logdir /usr/src/app/tensorboard_logs --host 0.0.0.0 --port 6006 ; if ($?) {Write-Output "Tensorboard running at port 6006"}
}
function delete_running($name) {
docker rm -f $name
}
function run {
run_container ; if($?) {run_tensorboard} ; if ($?) {run_python_script $python_filename $action $name $algorithm $timesteps $new_save_name}
}
if ($build -or $b) {build_container}
elseif ($run -or $r) {run}
elseif ($auto -or $a) {build_container ; if ($?) {run}}
else {
Write-Output("You must specify an action!")
}