"torchvision/git@developer.sourcefind.cn:OpenDAS/vision.git" did not exist on "7de62659332effc3d1848d8b84dbeb6b8cb4ea21"
Commit ad841384 authored by Bruce MacDonald's avatar Bruce MacDonald
Browse files

do not pull when local is available

parent a88576e5
...@@ -35,8 +35,6 @@ func RunRun(cmd *cobra.Command, args []string) error { ...@@ -35,8 +35,6 @@ func RunRun(cmd *cobra.Command, args []string) error {
if err := pull(args[0]); err != nil { if err := pull(args[0]); err != nil {
return err return err
} }
fmt.Println("Up to date.")
case err != nil: case err != nil:
return err return err
} }
...@@ -45,20 +43,27 @@ func RunRun(cmd *cobra.Command, args []string) error { ...@@ -45,20 +43,27 @@ func RunRun(cmd *cobra.Command, args []string) error {
} }
func pull(model string) error { func pull(model string) error {
client := api.NewClient() // TODO: check if the local model is up to date with remote
_, err := os.Stat(cacheDir() + "/models/" + model + ".bin")
var bar *progressbar.ProgressBar switch {
return client.Pull( case errors.Is(err, os.ErrNotExist):
context.Background(), client := api.NewClient()
&api.PullRequest{Model: model}, var bar *progressbar.ProgressBar
func(progress api.PullProgress) error { return client.Pull(
if bar == nil { context.Background(),
bar = progressbar.DefaultBytes(progress.Total) &api.PullRequest{Model: model},
} func(progress api.PullProgress) error {
if bar == nil {
return bar.Set64(progress.Completed) bar = progressbar.DefaultBytes(progress.Total)
}, }
)
return bar.Set64(progress.Completed)
},
)
case err != nil:
return err
}
return nil
} }
func RunGenerate(_ *cobra.Command, args []string) error { func RunGenerate(_ *cobra.Command, args []string) error {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment