mirror of
https://gitlab.rlp.net/mobitar/ReCo.jl.git
synced 2024-12-21 00:51:21 +00:00
Add watcher for plotting during RL
This commit is contained in:
parent
657a7820f6
commit
c93cf3c21d
1 changed files with 37 additions and 0 deletions
37
scripts/plot_watch.jl
Normal file
37
scripts/plot_watch.jl
Normal file
|
@ -0,0 +1,37 @@
|
|||
using Pkg: Pkg
|
||||
using Revise: Revise
|
||||
|
||||
Pkg.activate("visualization")
|
||||
Revise.includet("../visualization/Animation.jl")
|
||||
using .Animation: Animation
|
||||
|
||||
function get_last_done_dir(main_dir::String)
|
||||
paths = readdir(main_dir; join=true)
|
||||
skipped_last_dir = false
|
||||
|
||||
for path_ind in length(paths):-1:1
|
||||
path = paths[path_ind]
|
||||
if isdir(path)
|
||||
if !skipped_last_dir
|
||||
skipped_last_dir = true
|
||||
continue
|
||||
end
|
||||
|
||||
return path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function plot_watch(main_dir::String)
|
||||
last_plotted_dir = ""
|
||||
|
||||
Revise.entr([main_dir]; pause=1.0) do
|
||||
dir = get_last_done_dir(main_dir)
|
||||
if !(dir == last_plotted_dir)
|
||||
last_plotted_dir = dir
|
||||
Animation.animate(dir)
|
||||
end
|
||||
end
|
||||
|
||||
return nothing
|
||||
end
|
Loading…
Reference in a new issue