Skip to content

Commit

Permalink
fix: Fix progress display reorder problem (#139)
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <cegao@tensorchord.ai>
  • Loading branch information
gaocegege authored May 12, 2022
1 parent 7ef5c71 commit 62d5049
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,21 @@ jupyter(password="", port=8888)
Then you can run `envd up` and open jupyter notebook at [`http://localhost:8888`](http://localhost:8888), or open vscode remote to attach to the container.

```
[+] ⌚ parse build.envd and download/cache dependencies 0.0s ✅ (finished)
=> 💽 (cached) download oh-my-zsh 0.0s
=> 💽 (cached) download ms-vscode.cpptools-1.7.1 0.0s
=> 💽 (cached) download github.copilot-1.12.5517 0.0s
=> 💽 (cached) download dbaeumer.vscode-eslint-2.2.3 0.0s
[+] 🐋 build envd environment 1.3s (24/25)
=> 💽 (cached) sh -c apt-get update && apt-get install -y --no-instal 0.0s
=> 💽 (cached) apt-get install -y --no-install-recommends gcc 0.0s
=> 💽 (cached) diff (sh -c apt-get update && apt-get install -y --no- 0.0s
=> 💽 (cached) pip install jupyter 0.0s
=> 💽 (cached) diff (sh -c apt-get update && apt-get install -y --no- 0.0s
=> 💽 (cached) copy /usr/bin/envd-ssh /var/envd/bin/envd-ssh 0.0s
[+] ⌚ parse build.envd and download/cache dependencies 23.7s ✅ (finished)
=> download oh-my-zsh 13.5s
=> download ms-vscode.cpptools-1.7.1 2.1s
=> download github.copilot-1.12.5517 1.3s
=> download ms-python.python-2021.12.1559732655 6.7s
[+] 🐋 build envd environment 4.4s (23/24)
=> 💽 (cached) copy /ms-python.python-2021.12.1559732655/extension /root/ 0.0s
=> 💽 (cached) merge (copy /ms-vscode.cpptools-1.7.1/extension /root/.vsc 0.0s
=> 💽 (cached) mkfile /etc/apt/sources.list 0.0s
=> 💽 (cached) merge (docker-image://docker.io/nvidia/cuda:11.6.0-cudnn8- 0.0s
=> 💽 (cached) mkfile /etc/pip.conf 0.0s
=> 💽 (cached) merge (merge (docker-image://docker.io/nvidia/cuda:11.6.0- 0.0s
=> 💽 (cached) sh -c apt-get update && apt-get install -y --no-install-re 0.0s
=> 💽 (cached) pip install tensorflow numpy jupyter 0.0s
=> 💽 (cached) diff (sh -c apt-get update && apt-get install -y --no-inst 0.0s
...
# You are in the docker container for dev
envd >
Expand Down
19 changes: 11 additions & 8 deletions pkg/progress/compileui/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func New(ctx context.Context, out console.File, mode string) (Writer, error) {
doneCh: make(chan bool),
repeatd: false,
result: &Result{
plugins: make(map[string]*PluginInfo),
plugins: make([]*PluginInfo, 0),
},
lineCount: 0,
}
Expand All @@ -81,17 +81,20 @@ func (w *generalWriter) LogVSCodePlugin(p vscode.Plugin, action Action, cached b
switch action {
case ActionStart:
c := time.Now()
w.result.plugins[p.String()] = &PluginInfo{
w.result.plugins = append(w.result.plugins, &PluginInfo{
Plugin: p,
startTime: &c,
cached: cached,
}
})
case ActionEnd:
c := time.Now()
w.result.plugins[p.String()].endTime = &c
w.result.plugins[p.String()].cached = cached
for i, plugin := range w.result.plugins {
if plugin.String() == p.String() {
w.result.plugins[i].endTime = &c
w.result.plugins[i].cached = cached
}
}
}

}

func (w *generalWriter) LogZSH(action Action, cached bool) {
Expand Down Expand Up @@ -163,7 +166,7 @@ func (w *generalWriter) output(finished bool) {
if w.result.ZSHInfo.cached {
template = " => 💽 (cached) download %s"
}
timerStr := fmt.Sprintf(" %.1fs\n", timer)
timerStr := fmt.Sprintf(" %3.1fs\n", timer)
out := fmt.Sprintf(template, w.result.ZSHInfo.OHMYZSH)
out = align(out, timerStr, width)
fmt.Fprint(w.console, out)
Expand All @@ -179,7 +182,7 @@ func (w *generalWriter) output(finished bool) {
if p.endTime != nil {
timer = p.endTime.Sub(*p.startTime).Seconds()
}
timerStr := fmt.Sprintf(" %.1fs\n", timer)
timerStr := fmt.Sprintf(" %3.1fs\n", timer)
template := " => download %s"
if p.cached {
template = " => 💽 (cached) download %s"
Expand Down
2 changes: 1 addition & 1 deletion pkg/progress/compileui/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const (
)

type Result struct {
plugins map[string]*PluginInfo
plugins []*PluginInfo
ZSHInfo *ZSHInfo
}

Expand Down

0 comments on commit 62d5049

Please sign in to comment.