Skip to content

Commit

Permalink
fix: kgbuilder bug (#756)
Browse files Browse the repository at this point in the history
fix: bug
  • Loading branch information
mizy authored Jan 22, 2024
1 parent d61286d commit 0c7ac38
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions server/api/studio/pkg/llm/importjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"path"
"path/filepath"
"regexp"
"runtime/debug"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -70,15 +71,9 @@ func RunFileJob(job *db.LLMJob) {
CompletionTokens: 0,
},
}
err := llmJob.AddLogFile()
if err != nil {
llmJob.SetJobFailed(err)
return
}
defer llmJob.CloseLogFile()
defer func() {
if err := recover(); err != nil {
llmJob.WriteLogFile(fmt.Sprintf("panic: %v", err), "error")
llmJob.WriteLogFile(fmt.Sprintf("panic: %v , stack: %v", err, string(debug.Stack())), "error")
llmJob.SetJobFailed(err)
}
processJson, err := json.Marshal(llmJob.Process)
Expand All @@ -94,6 +89,12 @@ func RunFileJob(job *db.LLMJob) {
return
}
}()
err := llmJob.AddLogFile()
if err != nil {
llmJob.SetJobFailed(err)
return
}
defer llmJob.CloseLogFile()
go llmJob.SyncProcess(job)

llmJob.Process.Ratio = 0.01
Expand Down Expand Up @@ -357,6 +358,9 @@ func (i *ImportJob) ParseText(text string) {
i.CacheNodes[node.Name] = node
continue
}
if nowNode.Props == nil {
nowNode.Props = make(map[string]any)
}
for key, value := range node.Props {
nowNode.Props[key] = value
}
Expand All @@ -373,6 +377,9 @@ func (i *ImportJob) ParseText(text string) {
i.CacheEdges[src][dst] = edge
continue
}
if nowEdge.Props == nil {
nowEdge.Props = make(map[string]any)
}
for key, value := range edge.Props {
nowEdge.Props[key] = value
}
Expand Down

0 comments on commit 0c7ac38

Please sign in to comment.