Skip to content

Commit

Permalink
Response to changes requested
Browse files Browse the repository at this point in the history
Added GetGraphVisualizationFile function in the entire pipeline of Gapid.
  • Loading branch information
elviscapiaq authored and bjoeris committed Jan 2, 2019
1 parent ef4bedc commit c6eaca1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 21 deletions.
19 changes: 8 additions & 11 deletions cmd/gapit/create_graph_visualization.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"flag"
"github.com/google/gapid/core/app"
"github.com/google/gapid/core/log"
"io/ioutil"
"os"
)

Expand Down Expand Up @@ -50,25 +49,23 @@ func (verb *createGraphVisualizationVerb) Run(ctx context.Context, flags flag.Fl

graphVisualization, err := client.GetGraphVisualization(ctx, capture)
if err != nil {
return log.Errf(ctx, err, "ExportCapture(%v)", capture)
return log.Errf(ctx, err, "GetGraphVisualization(%v)", capture)
}

filePath := verb.Out
if filePath == "" {
filePath = "graph_visualization.dot"
}

_, err = os.Stat(filePath)
if os.IsNotExist(err) {
file, err := os.Create(filePath)
if err != nil {
log.Errf(ctx, err, "Creating file (%v)", filePath)
}
defer file.Close()
file, err := os.Create(filePath)
if err != nil {
return log.Errf(ctx, err, "Creating file (%v)", filePath)
}
defer file.Close()

if err := ioutil.WriteFile(filePath, []byte(graphVisualization), 0666); err != nil {
return log.Errf(ctx, err, "Writing file: %v", filePath)
bytesWritten, err := file.Write(graphVisualization)
if err != nil {
return log.Errf(ctx, err, "Error after writing %d bytes to file", bytesWritten)
}
return nil
}
6 changes: 3 additions & 3 deletions gapis/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,15 +485,15 @@ func (c *client) GetTimestamps(ctx context.Context, capture *path.Capture, devic
return res, nil
}

func (c *client) GetGraphVisualization(ctx context.Context, capture *path.Capture) (string, error) {
func (c *client) GetGraphVisualization(ctx context.Context, capture *path.Capture) ([]byte, error) {
res, err := c.client.GetGraphVisualization(ctx, &service.GraphVisualizationRequest{
Capture: capture,
})
if err != nil {
return "", err
return []byte{}, err
}
if err := res.GetError(); err != nil {
return "", err.Get()
return []byte{}, err.Get()
}
return res.GetGraphVisualization(), nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
"github.com/google/gapid/gapis/resolve/dependencygraph2"
)

func GetGraphVisualizationFromCapture(ctx context.Context, p *capture.Capture) (string, error) {
func GetGraphVisualizationFromCapture(ctx context.Context, p *capture.Capture) ([]byte, error) {

config := dependencygraph2.DependencyGraphConfig{}
dependencyGraph, err := dependencygraph2.BuildDependencyGraph(ctx, config, p, []api.Cmd{}, interval.U64RangeList{})
_ = dependencyGraph

return "OutputFile", err
return []byte("OutputFile"), err
}
13 changes: 10 additions & 3 deletions gapis/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ import (
_ "github.com/google/gapid/gapis/api/all"
)

const (
FILE_SIZE_LIMIT_IN_BYTES = 2147483647
)

// Config holds the server configuration settings.
type Config struct {
Info *service.ServerInfo
Expand Down Expand Up @@ -299,17 +303,20 @@ func (s *server) DCECapture(ctx context.Context, p *path.Capture, requested []*p
return trimmed, nil
}

func (s *server) GetGraphVisualization(ctx context.Context, p *path.Capture) (string, error) {
func (s *server) GetGraphVisualization(ctx context.Context, p *path.Capture) ([]byte, error) {
ctx = status.Start(ctx, "RPC GetGraphVisualization")
defer status.Finish(ctx)
ctx = log.Enter(ctx, "GetGraphVisualization")
c, err := capture.ResolveFromPath(ctx, p)
if err != nil {
return "", err
return []byte{}, err
}
graphVisualization, err := graph_visualization.GetGraphVisualizationFromCapture(ctx, c)
if err != nil {
return "", err
return []byte{}, err
}
if len(graphVisualization) > FILE_SIZE_LIMIT_IN_BYTES {
return []byte{}, log.Errf(ctx, err, "The file size for graph visualization exceeds %d bytes", FILE_SIZE_LIMIT_IN_BYTES)
}
return graphVisualization, nil
}
Expand Down
2 changes: 1 addition & 1 deletion gapis/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type Service interface {
// DCECapture returns a new capture containing only the requested commands and their dependencies.
DCECapture(ctx context.Context, capture *path.Capture, commands []*path.Command) (*path.Capture, error)

GetGraphVisualization(ctx context.Context, capture *path.Capture) (string, error)
GetGraphVisualization(ctx context.Context, capture *path.Capture) ([]byte, error)

// GetDevices returns the full list of replay devices avaliable to the server.
// These include local replay devices and any connected Android devices.
Expand Down
2 changes: 1 addition & 1 deletion gapis/service/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ message GraphVisualizationRequest {
}
message GraphVisualizationResponse {
oneof res {
string graphVisualization = 1;
bytes graphVisualization = 1;
Error error = 2;
}
}
Expand Down

0 comments on commit c6eaca1

Please sign in to comment.