Skip to content

Commit

Permalink
fix: clean runtime path (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly authored Aug 19, 2024
1 parent e769713 commit d848aa9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 9 additions & 3 deletions internal/core/runner/python/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package python
import (
_ "embed"
"fmt"
"github.com/langgenius/dify-sandbox/internal/static"
"os"
"os/exec"
"path"
"regexp"
"strings"

"github.com/langgenius/dify-sandbox/internal/static"

"github.com/langgenius/dify-sandbox/internal/core/runner"
python_dependencies "github.com/langgenius/dify-sandbox/internal/core/runner/python/dependencies"
"github.com/langgenius/dify-sandbox/internal/core/runner/types"
Expand All @@ -30,8 +31,13 @@ func init() {

func releaseLibBinary() {
log.Info("initializing python runner environment...")
os.RemoveAll(LIB_PATH)
os.Remove(LIB_PATH)
// remove the old lib
if _, err := os.Stat(path.Join(LIB_PATH, LIB_NAME)); err == nil {
err := os.Remove(path.Join(LIB_PATH, LIB_NAME))
if err != nil {
log.Panic(fmt.Sprintf("failed to remove %s", path.Join(LIB_PATH, LIB_NAME)))
}
}

err := os.MkdirAll(LIB_PATH, 0755)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ func initDependencies() {
if err != nil {
log.Error("failed to update python dependencies: %v", err)
}
err = python.PreparePythonDependenciesEnv()
if err != nil {
log.Error("failed to update python dependencies sandbox: %v", err)
}
log.Info("python dependencies updated")
}
}()
Expand Down

0 comments on commit d848aa9

Please sign in to comment.