Skip to content

Commit

Permalink
Update gleanerIntegration.md
Browse files Browse the repository at this point in the history
make object function
  • Loading branch information
valentinedwv committed Nov 7, 2021
1 parent 6db54de commit 958398c
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 34 deletions.
90 changes: 71 additions & 19 deletions docs/gleanerIntegration.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,94 @@ the primary standards we need implemented include
Config file example

```
{
"sparql": {
"endpoint": "https://graph.example.org/sparql"
},
"objects": {
"bucket": "sourcebucket",
"prefix": ["bucket, "prefixes", "to", "load"],
"domain": "us-east-1"
},
"minio": {
"address": "objectstore.example.org",
"port": "",
"accesskey": "worldsbestaccesskey",
"secretkey": "worldsbestsecretkey"
}
}
minio:
address: localhost
port: 9000
ssl: false
accesskey: akey
secretkey: skey
bucket: gleaner2
objects:
bucket: gleaner2
domain: us-east-1
prefix:
- milled/iris
- prov/iris
- org
prefixoff:
- summoned/aquadocs
- prov/aquadocs
- milled/opentopography
- prov/opentopography
sparql:
endpoint: http://localhost/blazegraph/namespace/earthcube/sparql
authenticate: false
username: ""
password: ""
txtaipkg:
endpoint: http://0.0.0.0:8000
```

Commands are like the following:
### Help
nabu --help

### Prefix: load all objects in the bucket/prefixes

The mode "prefix" in Nabu is used for loading a S3 object prefix
path into a triplestore
```
nabu -cfg file -mode prefix
nabu prefix --cfg file
```
eg
```
nabu prefix --cfg ../gleaner/configs/nabu
```
and gleaner generated configuration:
```
nabu prefix --cfgPath directory --cfgName name
```
eg use generated
```
nabu prefix --cfgPath ../gleaner/configs --cfgName local
```

### Prune: load all objects in the bucket/prefixes

The mode "prune" in Nabu is to sync a prefix to the graph (remove graphs no longer in use, add new ones)

Note that updated graphs become new objects, since the object name is the SHA256 of the object

```
nabu -cfg file -mode prune
nabu prune --cfg file
```
and gleaner generated configuration:
```
nabu prefix --cfgPath directory --cfgName name
```
eg use generated
```
nabu prefix --cfgPath ../gleaner/configs --cfgName local
```

### Object: load one object in the bucket/prefixes

The mode "object" in Nabu is used for loading a S3 object
path into a triplestore
```
nabu object --cfg file objectId
```
eg
```
nabu object --cfg ../gleaner/configs/nabu milled/opentopography/ffa0df033bb3a8fc9f600c80df3501fe1a2dbe93.rdf
```

and gleaner generated configuration:
```
nabu object --cfgPath directory --cfgName name objectId
```
eg use generated
```
nabu object --cfgPath ../gleaner/configs --cfgName local milled/opentopography/ffa0df033bb3a8fc9f600c80df3501fe1a2dbe93.rdf
```

## TODO
Expand Down
30 changes: 17 additions & 13 deletions pkg/cli/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,28 @@ import (
"github.com/spf13/cobra"
)

var bucket, objectVal string
//var bucket, objectVal string

// checkCmd represents the check command
var objectCmd = &cobra.Command{
Use: "objectVal",
Short: "nabu objectVal command",
Long: `Load graph objectVal to triplestore`,
Use: "object",
Short: "nabu object command",
Long: `Load graph object to triplestore`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("objectVal called")
if objectVal == "" {

}
err := pkg.Object(viperVal, mc, bucketVal, objectVal)
if err != nil {
log.Fatal(err)
fmt.Println("object called")
if len(args) > 0 {
objectVal := args[0]

err := pkg.Object(viperVal, mc, bucketVal, objectVal)
if err != nil {
log.Fatal(err)
os.Exit(1)
}
os.Exit(0)
} else {
log.Fatal("must have an argument nabu object objectId")
os.Exit(1)
}
os.Exit(0)

},
}
Expand All @@ -36,7 +40,7 @@ func init() {

// Here you will define your flags and configuration settings.
// bucketVal is available at top level
objectCmd.Flags().StringVar(&objectVal, "objectVal", "", "objectVal to load")
//objectCmd.Flags().StringVar(&objectVal, "object", "", "object to load")
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// checkCmd.PersistentFlags().String("foo", "", "A help for foo")
Expand Down
6 changes: 4 additions & 2 deletions pkg/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (
"log"
"mime"
"os"
"path"
"path/filepath"

"github.com/spf13/viper"
)

var cfgFile, cfgName, cfgPath string
var cfgFile, cfgName, cfgPath, nabuConfName string
var minioVal, portVal, accessVal, secretVal, bucketVal string
var sslVal bool
var viperVal *viper.Viper
Expand Down Expand Up @@ -55,6 +56,7 @@ func init() {

rootCmd.PersistentFlags().StringVar(&cfgPath, "cfgPath", "configs", "base location for config files (default is configs/)")
rootCmd.PersistentFlags().StringVar(&cfgName, "cfgName", "local", "config file (default is local so configs/local)")
rootCmd.PersistentFlags().StringVar(&nabuConfName, "nabuConfName", "nabu", "config file (default is local so configs/local)")
rootCmd.PersistentFlags().StringVar(&cfgFile, "cfg", "", "compatibility/overload: full path to config file (default location gleaner in configs/local)")

// minio env variables
Expand Down Expand Up @@ -91,7 +93,7 @@ func initConfig() {
//viperVal.AddConfigPath(path.Join(cfgPath, cfgName))
//viperVal.SetConfigType("yaml")
//viperVal.SetConfigName("nabu")
viperVal, err = config.ReadNabuConfig(cfgName, cfgPath)
viperVal, err = config.ReadNabuConfig(nabuConfName, path.Join(cfgPath, cfgName))
if err != nil {
log.Fatal("cannot read config %s", err)
}
Expand Down

0 comments on commit 958398c

Please sign in to comment.