Skip to content
Permalink
Browse files

Bug fixes.

  • Loading branch information...
hscells committed Mar 27, 2019
1 parent 54ebf48 commit 4f2935e55e42e3771f22c557a5a2159c65c2ed0e
Showing with 26 additions and 38 deletions.
  1. +11 −12 api.go
  2. +0 −10 routes.go
  3. +15 −6 server.go
  4. +0 −10 web/index.html
23 api.go
@@ -3,10 +3,12 @@ package main
import (
"bytes"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"github.com/go-errors/errors"
"github.com/gorilla/websocket"
"github.com/hscells/boogie"
"github.com/hscells/groove"
gpipeline "github.com/hscells/groove/pipeline"
"github.com/hscells/transmute/backend"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/mem"
@@ -18,8 +20,6 @@ import (
"path/filepath"
"strings"
"time"
"fmt"
"github.com/go-errors/errors"
)

// upgrader is a struct that upgrades a web socket.
@@ -155,7 +155,6 @@ func handleApiSave(c *gin.Context) {
}

func handleApiRun(c *gin.Context) {
queryPath := c.PostForm("path")
pipelineData := c.PostForm("pipeline")

var dsl boogie.Pipeline
@@ -175,7 +174,7 @@ func handleApiRun(c *gin.Context) {

trecEvalBuff := bytes.NewBuffer([]byte{})

pipelineChan := make(chan groove.PipelineResult)
pipelineChan := make(chan gpipeline.Result)

var trecEvalFile *os.File
if len(dsl.Output.Trec.Output) > 0 {
@@ -189,15 +188,15 @@ func handleApiRun(c *gin.Context) {
defer trecEvalFile.Close()
}

go pipeline.Execute(queryPath, pipelineChan)
go pipeline.Execute(pipelineChan)
for {
result := <-pipelineChan
if result.Type == groove.Done {
if result.Type == gpipeline.Done {
log.Println("Completed pipeline, formatting files")
break
}
switch result.Type {
case groove.Measurement:
case gpipeline.Measurement:
// Process the measurement outputs.
for i, formatter := range dsl.Output.Measurements {
err := ioutil.WriteFile(formatter.Filename, bytes.NewBufferString(result.Measurements[i]).Bytes(), 0644)
@@ -206,7 +205,7 @@ func handleApiRun(c *gin.Context) {
return
}
}
case groove.Transformation:
case gpipeline.Transformation:
// Output the transformed queries
if len(dsl.Transformations.Output) > 0 {
s, err := backend.NewCQRQuery(result.Transformation.Transformation).StringPretty()
@@ -221,11 +220,11 @@ func handleApiRun(c *gin.Context) {
return
}
}
case groove.Evaluation:
case gpipeline.Evaluation:
for i, e := range result.Evaluations {
evaluations[i] = e
}
case groove.TrecResult:
case gpipeline.TrecResult:
if result.TrecResults != nil && len(*result.TrecResults) > 0 {
l := make([]string, len(*result.TrecResults))
for i, r := range *result.TrecResults {
@@ -236,7 +235,7 @@ func handleApiRun(c *gin.Context) {
result.TrecResults = nil
}
trecEvalBuff.Truncate(0)
case groove.Error:
case gpipeline.Error:
if len(result.Topic) > 0 {
log.Printf("an error occurred in topic %v", result.Topic)
} else {

This file was deleted.

Oops, something went wrong.
@@ -3,6 +3,7 @@ package main
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/gobuffalo/packr/v2"
"io"
"log"
"net/http"
@@ -23,19 +24,27 @@ type file struct {

func main() {

lf, err := os.OpenFile("web/static/log", os.O_WRONLY|os.O_RDONLY|os.O_CREATE, 0644)
lf, err := os.OpenFile("querylab.log", os.O_WRONLY|os.O_RDONLY|os.O_CREATE, 0644)
if err != nil {
log.Fatalln(err)
}
lf.Truncate(0)

staticBox := packr.New("static", "./web/static")
webBox := packr.New("web", "./web")

router := gin.Default()

router.LoadHTMLFiles("web/index.html")
router.Static("/static/", "./web/static")
router.GET("/static/*any", gin.WrapH(http.StripPrefix("/static/", http.FileServer(staticBox))))

// Main query interface.
router.GET("/", handleIndex)
router.GET("/", func(c *gin.Context) {
s, err := webBox.Find("index.html")
if err != nil {
log.Fatal(err)
}
c.Data(http.StatusOK, "text/html", s)
})

router.GET("/api/files", handleApiFiles)
router.GET("/api/file/*path", handleApiFile)
router.POST("/api/save/*path", handleApiSave)
@@ -60,5 +69,5 @@ Y88b.Y8b88P Y88b 888 Y8b. 888 Y88b 888 888 888 888 888 d88P
Harry Scells 2018
https://ielab.io/querylab
`)
log.Fatal(http.ListenAndServe(":5862", router))
log.Fatal(router.Run(":5862"))
}
@@ -51,16 +51,6 @@
<!-- mutually exclusive Accordions example (with same input names) -->
<div class="accordion">
<input type="checkbox" id="r1" name="c1" hidden title="" checked>
<label class="accordion-header text-bold bg-secondary" for="r1">
Configure
</label>
<div class="accordion-body">
<div class="form-group">
<label class="form-label" for="input-queries">Query Path</label>
<input class="form-input" type="text" id="input-queries" v-model="queryPath"
placeholder="/data/queries">
</div>
</div>
</div>
<div class="accordion">
<input type="checkbox" id="r2" name="c2" hidden title="" checked>

0 comments on commit 4f2935e

Please sign in to comment.
You can’t perform that action at this time.