-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat: Write logged features to Offline Store (Go - Python integration) #2621
Merged
feast-ci-bot
merged 8 commits into
feast-dev:master
from
pyalex:feature-logging-integration
May 3, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fb26fe8
write logged features by path
pyalex 37f85f4
fix dummy sink
pyalex 081eed4
share snowflake cursor and stage name
pyalex b5ca9ac
share snowflake cursor and stage name
pyalex 5f22182
e2e tests WIP
pyalex 25fc614
graceful stop (grpc & logging)
pyalex f2ed4ef
revert accidental change
pyalex 83f51a3
add comments to go embedded methods
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package logging | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"io" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/apache/arrow/go/v8/arrow" | ||
"github.com/apache/arrow/go/v8/arrow/array" | ||
"github.com/apache/arrow/go/v8/parquet" | ||
"github.com/apache/arrow/go/v8/parquet/pqarrow" | ||
"github.com/google/uuid" | ||
) | ||
|
||
type OfflineStoreWriteCallback func(featureServiceName, datasetDir string) string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably should specify name as string too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a short form |
||
|
||
type OfflineStoreSink struct { | ||
datasetDir string | ||
writeCallback OfflineStoreWriteCallback | ||
} | ||
|
||
func NewOfflineStoreSink(writeCallback OfflineStoreWriteCallback) (*OfflineStoreSink, error) { | ||
return &OfflineStoreSink{ | ||
datasetDir: "", | ||
writeCallback: writeCallback, | ||
}, nil | ||
} | ||
|
||
func (s *OfflineStoreSink) getOrCreateDatasetDir() (string, error) { | ||
if s.datasetDir != "" { | ||
return s.datasetDir, nil | ||
} | ||
dir, err := ioutil.TempDir("", "*") | ||
if err != nil { | ||
return "", err | ||
} | ||
s.datasetDir = dir | ||
return s.datasetDir, nil | ||
} | ||
|
||
func (s *OfflineStoreSink) cleanCurrentDatasetDir() error { | ||
if s.datasetDir == "" { | ||
return nil | ||
} | ||
datasetDir := s.datasetDir | ||
s.datasetDir = "" | ||
return os.RemoveAll(datasetDir) | ||
} | ||
|
||
func (s *OfflineStoreSink) Write(record arrow.Record) error { | ||
fileName, _ := uuid.NewUUID() | ||
datasetDir, err := s.getOrCreateDatasetDir() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
var writer io.Writer | ||
writer, err = os.Create(filepath.Join(datasetDir, fmt.Sprintf("%s.parquet", fileName.String()))) | ||
if err != nil { | ||
return err | ||
} | ||
table := array.NewTableFromRecords(record.Schema(), []arrow.Record{record}) | ||
|
||
props := parquet.NewWriterProperties(parquet.WithDictionaryDefault(false)) | ||
arrProps := pqarrow.DefaultWriterProps() | ||
return pqarrow.WriteTable(table, writer, 1000, props, arrProps) | ||
} | ||
|
||
func (s *OfflineStoreSink) Flush(featureServiceName string) error { | ||
if s.datasetDir == "" { | ||
return nil | ||
} | ||
|
||
errMsg := s.writeCallback(featureServiceName, s.datasetDir) | ||
if errMsg != "" { | ||
return errors.New(errMsg) | ||
} | ||
|
||
return s.cleanCurrentDatasetDir() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really move some of this stuff to use a proper logger.