Skip to content

Commit c897b6f

Browse files
committed
Refactor logging and enhance RDF metadata generation
Replace standard log package with logrus for enhanced logging capabilities across the project. Update RDF metadata generation to include dynamic timestamps and bucket-derived names, improving the accuracy and relevance of generated data descriptions.
1 parent 22099ff commit c897b6f

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

docs/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,12 @@ nabu object --cfgPath directory --cfgName name objectId
177177
eg use generated
178178
```
179179
nabu object --cfgPath ../gleaner/configs --cfgName local milled/opentopography/ffa0df033bb3a8fc9f600c80df3501fe1a2dbe93.rdf
180+
```
181+
182+
### Using URL based configuration
183+
184+
Nabu can also read the configuration file from over the network
185+
186+
```
187+
go run ../../cmd/nabu/main.go release --cfgURL https://provisium.io/data/nabuconfig.yaml --prefix summoned/dataverse --endpoint localoxi
180188
```

internal/graph/toFromRDF.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"log"
7+
log "github.com/sirupsen/logrus"
88
"strings"
99

1010
"github.com/knakk/rdf"

internal/objects/pipecopy.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io"
99
"strings"
1010
"sync"
11+
"time"
1112

1213
"github.com/spf13/viper"
1314

@@ -17,6 +18,11 @@ import (
1718
"github.com/minio/minio-go/v7"
1819
)
1920

21+
func getLastElement(s string) string {
22+
parts := strings.Split(s, "/")
23+
return parts[len(parts)-1]
24+
}
25+
2026
// PipeCopy writes a new object based on an prefix, this function assumes the objects are valid when concatenated
2127
// v1: viper config object
2228
// mc: minio client pointer
@@ -118,19 +124,24 @@ func PipeCopy(v1 *viper.Viper, mc *minio.Client, name, bucket, prefix, destprefi
118124
if lastProcessed {
119125

120126
data := `_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://schema.org/DataCatalog> .
121-
_:b0 <https://schema.org/dateCreated> "2024-09-20" .
122-
_:b0 <https://schema.org/description> "This is an example data catalog containing various datasets from this organization" .
127+
_:b0 <https://schema.org/dateCreated> "` + time.Now().Format("2006-01-02 15:04:05") + `" .
128+
_:b0 <https://schema.org/description> "GleanerIO Nabu generated catalog" .
123129
_:b0 <https://schema.org/provider> _:b1 .
124130
_:b0 <https://schema.org/publisher> _:b2 .
125131
_:b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://schema.org/Organization> .
126-
_:b1 <https://schema.org/name> "Provider XYZ" .
132+
_:b1 <https://schema.org/name> "` + getLastElement(prefix) + `" .
127133
_:b2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://schema.org/Organization> .
128-
_:b2 <https://schema.org/name> "DeCoder" .
129-
`
134+
_:b2 <https://schema.org/name> "` + bucket + `" .`
135+
130136
for _, item := range idList {
131137
data += `_:b0 <https://schema.org/dataset> <` + item + `> .` + "\n"
132138
}
133139

140+
// TODO MakeURN with _:b0 Q's Will this work with a blank node? do after Skolemization?
141+
// namedgraph, err := graph.MakeURN(v1, "resource IRI")
142+
// sdataWithContext, err := graph.NtToNq(sdata, namedgraph)
143+
144+
// TODO: Skolemize with sdataWithContext
134145
sdata, err := graph.Skolemization(data, "release graph prov for ORG")
135146
if err != nil {
136147
log.Println(err)

pkg/config/nabuConfig.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package config
22

33
import (
44
"fmt"
5+
log "github.com/sirupsen/logrus"
56
"github.com/spf13/viper"
67
"io"
78
"net/http"
@@ -41,7 +42,7 @@ func ReadNabuConfigURL(configURL string) (*viper.Viper, error) {
4142
v.SetDefault(key, value)
4243
}
4344

44-
fmt.Printf("Reading config from URL: %v\n", configURL)
45+
log.Printf("Reading config from URL: %v\n", configURL)
4546

4647
resp, err := http.Get(configURL)
4748
if err != nil {
@@ -83,9 +84,5 @@ func ReadNabuConfigURL(configURL string) (*viper.Viper, error) {
8384
return v, err
8485
}
8586

86-
fmt.Printf("Config read from URL: %v\n", v.AllSettings())
87-
88-
//err = v.ReadInConfig()
89-
9087
return v, err
9188
}

0 commit comments

Comments
 (0)