Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fhir json schema + Remove Elasticsearch support from Grip #318

Merged
merged 35 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
42de601
Start JSON schema loader into grip graph
matthewpeterkort Oct 22, 2024
f9cf8f4
Add support for extensions
matthewpeterkort Oct 22, 2024
9a800dc
cleanup vertex generation
matthewpeterkort Oct 23, 2024
b9da7be
Add edge generation
matthewpeterkort Oct 23, 2024
5f507f8
Adds schema load command
matthewpeterkort Nov 1, 2024
c1ee086
start implement json load
matthewpeterkort Nov 1, 2024
7051f51
working json loader
matthewpeterkort Nov 13, 2024
be854ce
cleanup, add support for graph and project-id customization
matthewpeterkort Nov 14, 2024
1fcac9f
Adds tests, new schema load method
matthewpeterkort Nov 15, 2024
f4ae5df
trim down test data size
matthewpeterkort Nov 15, 2024
c9f36fe
bug fix
matthewpeterkort Nov 15, 2024
694ef9d
bug fix
matthewpeterkort Nov 15, 2024
f11f79e
cleanup
matthewpeterkort Nov 15, 2024
0e7ce90
fix schema dataset
matthewpeterkort Nov 15, 2024
7351ace
fix logs
matthewpeterkort Nov 15, 2024
14f0a58
Bug fix auth test
matthewpeterkort Nov 18, 2024
bb2b9dd
Adds more tests
matthewpeterkort Nov 18, 2024
821431f
Add server err message response
matthewpeterkort Nov 19, 2024
a7f6fdd
fix tests
matthewpeterkort Nov 19, 2024
b8d9a0a
Remove elasticSearch from grip
matthewpeterkort Nov 20, 2024
a3ff902
Bugfix protobuf definition
matthewpeterkort Nov 20, 2024
515a682
bugfix, rename cmd
matthewpeterkort Nov 22, 2024
67d787e
factor out project_id into an optional extra arg
matthewpeterkort Nov 30, 2024
007f2fc
fix docs hostname and schema import name
matthewpeterkort Dec 3, 2024
9537849
fix double slash in paths
matthewpeterkort Dec 4, 2024
3bb0fde
remove extra file
matthewpeterkort Dec 4, 2024
a1646b0
Flesh out jsonschema to graphql schema command
matthewpeterkort Dec 10, 2024
146c50e
fixup graphql schema generation
matthewpeterkort Dec 11, 2024
b772ede
fix up cmd args to work with jsonschemagraph changes
matthewpeterkort Dec 11, 2024
1eed29a
Make go.mod versions compatible with grip plugin versions and move gr…
matthewpeterkort Dec 12, 2024
e938d18
Add support for yaml schemas, change AddSchema to an upsert operation
matthewpeterkort Jan 2, 2025
f365481
clean up / improve tests
matthewpeterkort Jan 2, 2025
683df7a
cleanup
matthewpeterkort Jan 2, 2025
c2dbbc7
cleanup
matthewpeterkort Jan 2, 2025
9654ae9
Add gripql query function calls
matthewpeterkort Jan 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,30 +130,6 @@ jobs:
sleep 5
make test-conformance


elasticTest:
needs: build
name: Elastic Test
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Python Dependencies for Conformance
run: pip install requests numpy
- name: Download grip
uses: actions/download-artifact@v4
with:
name: gripBin
- name: Elastic Conformance
run: |
chmod +x grip
make start-elastic
sleep 15
./grip server --rpc-port 18202 --http-port 18201 --config ./test/elastic.yml &
sleep 5
make test-conformance


postgresTest:
needs: build
name: Postgres Test
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ gripql/R/*.tar.gz
# dev tools
.idea/
.vscode/
.DS_Store
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ start-mongo:
@docker rm -f grip-mongodb-test > /dev/null 2>&1 || echo
docker run -d --name grip-mongodb-test -p 27017:27017 mongo:7.0.13-rc0-jammy > /dev/null

start-elastic:
@docker rm -f grip-es-test > /dev/null 2>&1 || echo
docker run -d --name grip-es-test -p 19200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "xpack.security.enabled=false" docker.elastic.co/elasticsearch/elasticsearch:5.6.3 > /dev/null

start-postgres:
@docker rm -f grip-postgres-test > /dev/null 2>&1 || echo
docker run -d --name grip-postgres-test -p 15432:5432 -e POSTGRES_PASSWORD= -e POSTGRES_USER=postgres postgres:10.4 > /dev/null
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

https://bmeg.github.io/grip/

GRIP stands for GRaph Integration Platform. It provides a graph interface on top of a variety of existing database technologies including: MongoDB, Elasticsearch, PostgreSQL, MySQL, MariaDB, Badger, and LevelDB.
GRIP stands for GRaph Integration Platform. It provides a graph interface on top of a variety of existing database technologies including: MongoDB, PostgreSQL, MySQL, MariaDB, Badger, and LevelDB.

Properties of an GRIP graph:

Expand Down
44 changes: 44 additions & 0 deletions accounts/bulk_write_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,47 @@ func (bw *BulkWriteFilter) RecvMsg(m interface{}) error {
}
}
}

type BulkWriteRawFilter struct {
SS grpc.ServerStream
User string
Access Access
}

func (bw *BulkWriteRawFilter) SetHeader(m metadata.MD) error {
return bw.SS.SendHeader(m)
}

func (bw *BulkWriteRawFilter) SendHeader(m metadata.MD) error {
return bw.SS.SendHeader(m)
}

func (bw *BulkWriteRawFilter) SetTrailer(m metadata.MD) {
bw.SS.SetTrailer(m)
}

func (bw *BulkWriteRawFilter) Context() context.Context {
return bw.SS.Context()
}

func (bw *BulkWriteRawFilter) SendMsg(m interface{}) error {
return bw.SS.SendMsg(m)
}

func (bw *BulkWriteRawFilter) RecvMsg(m interface{}) error {
for {
var ge gripql.RawJson
err := bw.SS.RecvMsg(&ge)
if err != nil {
return err
}
err = bw.Access.Enforce(bw.User, ge.Graph, Write)
if err == nil {
mPtr := m.(*gripql.RawJson)
*mPtr = ge
return nil
} else {
log.Infof("Graph write error: %s", ge.Graph)
}
}
}
26 changes: 14 additions & 12 deletions accounts/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,20 @@ var MethodMap = map[string]Operation{
"/gripql.Job/ViewJob": Read,
"/gripql.Job/ResumeJob": Exec,

"/gripql.Edit/AddVertex": Write,
"/gripql.Edit/AddEdge": Write,
"/gripql.Edit/BulkAdd": Write,
"/gripql.Edit/BulkDelete": Write,
"/gripql.Edit/AddGraph": Write,
"/gripql.Edit/DeleteGraph": Write,
"/gripql.Edit/DeleteVertex": Write,
"/gripql.Edit/DeleteEdge": Write,
"/gripql.Edit/AddIndex": Write,
"/gripql.Edit/AddSchema": Write,
"/gripql.Edit/AddMapping": Write,
"/gripql.Edit/SampleSchema": Write, //Maybe exec?
"/gripql.Edit/AddVertex": Write,
"/gripql.Edit/AddEdge": Write,
"/gripql.Edit/BulkAdd": Write,
"/gripql.Edit/BulkAddRaw": Write,
"/gripql.Edit/BulkDelete": Write,
"/gripql.Edit/AddGraph": Write,
"/gripql.Edit/DeleteGraph": Write,
"/gripql.Edit/DeleteVertex": Write,
"/gripql.Edit/DeleteEdge": Write,
"/gripql.Edit/AddIndex": Write,
"/gripql.Edit/AddSchema": Write,
"/gripql.Edit/AddJsonSchema": Write,
"/gripql.Edit/AddMapping": Write,
"/gripql.Edit/SampleSchema": Write, //Maybe exec?

"/gripql.Configure/StartPlugin": Admin,
"/gripql.Configure/ListPlugin": Admin,
Expand Down
5 changes: 5 additions & 0 deletions accounts/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ func streamAuthInterceptor(auth Authenticate, access Access) grpc.StreamServerIn
return handler(srv, &BulkWriteFilter{ss, user, access})
} else if info.FullMethod == "/gripql.Edit/BulkDelete" {
return handler(srv, &BulkWriteFilter{ss, user, access})
} else if info.FullMethod == "/gripql.Edit/BulkAddRaw" {
return handler(srv, &BulkWriteRawFilter{ss, user, access})
} else {
log.Errorf("Unknown input streaming op %#v!!!", info)
return handler(srv, ss)
Expand Down Expand Up @@ -189,6 +191,9 @@ func getUnaryRequestGraph(req interface{}, info *grpc.UnaryServerInfo) (string,
case "/gripql.Edit/AddSchema", "/gripql.Edit/AddMapping":
o := req.(*gripql.Graph)
return o.Graph, nil
case "/gripql.Edit/AddJsonSchema":
o := req.(*gripql.RawJson)
return o.Graph, nil
case "/gripql.Edit/SampleSchema":
o := req.(*gripql.GraphID)
return o.Graph, nil
Expand Down
88 changes: 88 additions & 0 deletions cmd/jsonload/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package jsonload

import (
"encoding/json"

"github.com/bmeg/grip/gripql"
"github.com/bmeg/grip/log"
"github.com/bmeg/grip/util"
"github.com/bmeg/grip/util/rpc"
"github.com/spf13/cobra"
)

var host = "localhost:8202"
var NdJsonFile string
var workerCount = 5
var graph string
var ExtraArgs string
var logRate = 10000

var Cmd = &cobra.Command{
Use: "jsonload <NdJsonFile> <graph> <ExtraArgs>",
Short: "Load, Validate NdJson data into grip graph",
Long: ``,
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error {
NdJsonFile = args[0]
graph = args[1]
ExtraArgs = args[2]

var args_map map[string]any
if ExtraArgs != "" {
err := json.Unmarshal([]byte(ExtraArgs), &args_map)
if err != nil {
return err
}
}

conn, err := gripql.Connect(rpc.ConfigWithDefaults(host), true)
if err != nil {
return err
}
resp, err := conn.ListGraphs()
if err != nil {
return err
}
found := false
for _, g := range resp.Graphs {
if graph == g {
found = true
}
}
if !found {
log.WithFields(log.Fields{"graph": graph}).Info("creating graph")
err := conn.AddGraph(graph)
if err != nil {
return err
}
}
elemChan := make(chan *gripql.RawJson)
wait := make(chan bool)
go func() {
_, err := conn.BulkAddRaw(elemChan)
if err != nil {
log.Errorf("bulk add raw error: %v", err)
}
wait <- false
}()

jsonChan, err := util.StreamRawJsonFromFile(NdJsonFile, workerCount, graph, args_map)
if err != nil {
return err
}
count := 0
for j := range jsonChan {
count++
if count%logRate == 0 {
log.Infof("Loaded %d vertices", count)
}
elemChan <- j
}

close(elemChan)
<-wait

log.WithFields(log.Fields{"graph": graph}).Info("loading data")
return nil
},
}
5 changes: 3 additions & 2 deletions cmd/load/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/bmeg/grip/cmd/load/example"
"github.com/bmeg/grip/gripql"
"github.com/bmeg/grip/log"
"github.com/bmeg/grip/schema"
"github.com/bmeg/grip/util"
"github.com/bmeg/grip/util/rpc"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -153,7 +154,7 @@ var Cmd = &cobra.Command{

if jsonFile != "" {
log.Infof("Loading json file: %s", jsonFile)
graphs, err := gripql.ParseJSONGraphsFile(jsonFile)
graphs, err := schema.ParseJSONGraphsFile(jsonFile)
if err != nil {
return err
}
Expand All @@ -171,7 +172,7 @@ var Cmd = &cobra.Command{

if yamlFile != "" {
log.Infof("Loading YAML file: %s", yamlFile)
graphs, err := gripql.ParseYAMLGraphsFile(yamlFile)
graphs, err := schema.ParseYAMLGraphsFile(yamlFile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this graphSchema?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

if err != nil {
return err
}
Expand Down
13 changes: 7 additions & 6 deletions cmd/mapping/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"

"github.com/bmeg/grip/gripql"
graphSchema "github.com/bmeg/grip/schema"
"github.com/bmeg/grip/util/rpc"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -43,9 +44,9 @@ var getCmd = &cobra.Command{

var txt string
if yaml {
txt, err = gripql.GraphToYAMLString(schema)
txt, err = graphSchema.GraphToYAMLString(schema)
} else {
txt, err = gripql.GraphToJSONString(schema)
txt, err = graphSchema.GraphToJSONString(schema)
}
if err != nil {
return err
Expand Down Expand Up @@ -78,9 +79,9 @@ var postCmd = &cobra.Command{
if err != nil {
return err
}
graphs, err = gripql.ParseJSONGraphs(bytes)
graphs, err = graphSchema.ParseJSONGraphs(bytes)
} else {
graphs, err = gripql.ParseJSONGraphsFile(jsonFile)
graphs, err = graphSchema.ParseJSONGraphsFile(jsonFile)
}
if err != nil {
return err
Expand All @@ -101,9 +102,9 @@ var postCmd = &cobra.Command{
if err != nil {
return err
}
graphs, err = gripql.ParseYAMLGraphs(bytes)
graphs, err = graphSchema.ParseYAMLGraphs(bytes)
} else {
graphs, err = gripql.ParseYAMLGraphsFile(yamlFile)
graphs, err = graphSchema.ParseYAMLGraphsFile(yamlFile)
}
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/bmeg/grip/cmd/erclient"
"github.com/bmeg/grip/cmd/info"
"github.com/bmeg/grip/cmd/job"
"github.com/bmeg/grip/cmd/jsonload"
"github.com/bmeg/grip/cmd/kvload"
"github.com/bmeg/grip/cmd/list"
"github.com/bmeg/grip/cmd/load"
Expand Down Expand Up @@ -60,6 +61,7 @@ func init() {
RootCmd.AddCommand(job.Cmd)
RootCmd.AddCommand(load.Cmd)
RootCmd.AddCommand(mongoload.Cmd)
RootCmd.AddCommand(jsonload.Cmd)
RootCmd.AddCommand(query.Cmd)
RootCmd.AddCommand(erclient.Cmd)
RootCmd.AddCommand(rdf.Cmd)
Expand Down
Loading
Loading