-
Notifications
You must be signed in to change notification settings - Fork 363
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
Delta Lake Diff: Change default plugin loading #5495
Merged
Jonathan-Rosenberg
merged 7 commits into
feature/delta/releaser
from
feature/delta/change-default-loading
Mar 22, 2023
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9d45221
change default behavior of plugin loading to scan in the default plug…
Jonathan-Rosenberg 5f48bf0
get delta lake diff plugin from default path if available
Jonathan-Rosenberg d480587
Merge branch 'feature/delta/releaser' into feature/delta/change-defau…
Jonathan-Rosenberg 9df4818
add homedir.Expand call to custom plugin path
Jonathan-Rosenberg 1f90ddf
remove empty line
Jonathan-Rosenberg ae1363c
change version from a pointer to an int
Jonathan-Rosenberg 2b24479
Delta Lake Diff: Dockerfile (#5496)
Jonathan-Rosenberg 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,14 @@ package tablediff | |
import ( | ||
"context" | ||
"errors" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
"sync" | ||
"time" | ||
|
||
"github.com/mitchellh/go-homedir" | ||
|
||
"github.com/treeverse/lakefs/pkg/config" | ||
"github.com/treeverse/lakefs/pkg/logging" | ||
"github.com/treeverse/lakefs/pkg/plugins" | ||
|
@@ -133,7 +137,7 @@ func (s *Service) appendClosingFunction(diffType string, f func()) { | |
} | ||
|
||
// NewService is used to initialize a new Differ service. The returned function is a closing function for the service. | ||
func NewService(diffProps map[string]config.DiffProps, pluginProps map[string]config.PluginProps) (*Service, func()) { | ||
func NewService(diffProps map[string]config.DiffProps, pluginProps config.Plugins) (*Service, func()) { | ||
service := &Service{ | ||
pluginHandler: internal.NewManager[Differ](), | ||
closeFunctions: make(map[string]func()), | ||
|
@@ -142,14 +146,20 @@ func NewService(diffProps map[string]config.DiffProps, pluginProps map[string]co | |
return service, service.Close | ||
} | ||
|
||
func registerPlugins(service *Service, diffProps map[string]config.DiffProps, pluginProps map[string]config.PluginProps) { | ||
func registerPlugins(service *Service, diffProps map[string]config.DiffProps, pluginProps config.Plugins) { | ||
registerDefaultPlugins(service, pluginProps.DefaultPath) | ||
for n, p := range diffProps { | ||
pluginName := p.PluginName | ||
// If the requested plugin wasn't configured with a path, it will be defined under the default location | ||
pluginPath := config.DefaultPluginLocation(pluginName) | ||
pluginPath := filepath.Join(diffPluginsDefaultPath(pluginProps.DefaultPath), pluginName) | ||
pluginVersion := 1 // default version | ||
if props, ok := pluginProps[pluginName]; ok { | ||
pluginPath = props.Path | ||
if props, ok := pluginProps.Properties[pluginName]; ok { | ||
pp, err := homedir.Expand(props.Path) | ||
if err != nil { | ||
logging.Default().Errorf("failed to register a plugin for an invalid path: '%s'", props.Path) | ||
continue | ||
} | ||
pluginPath = pp | ||
if props.Version != nil { | ||
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. I think we can remove the Version pointer from the configuration as we fallback to version 1 in the code - we can document that 0 is the default. |
||
pluginVersion = *props.Version | ||
} | ||
|
@@ -166,3 +176,25 @@ func registerPlugins(service *Service, diffProps map[string]config.DiffProps, pl | |
logging.Default().Infof("successfully registered a plugin for diff type: '%s'", n) | ||
} | ||
} | ||
|
||
func registerDefaultPlugins(service *Service, pluginsPath string) { | ||
diffPluginsDir := diffPluginsDefaultPath(pluginsPath) | ||
deltaPath := filepath.Join(diffPluginsDir, "delta") | ||
_, err := os.Stat(deltaPath) | ||
|
||
if err != nil { | ||
Jonathan-Rosenberg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if !os.IsNotExist(err) { | ||
logging.Default().WithError(err).Error("failed to access delta lake diff plugin") | ||
} | ||
return | ||
} | ||
|
||
pid := plugins.PluginIdentity{ProtocolVersion: 1, ExecutableLocation: deltaPath} | ||
pa := plugins.PluginHandshake{} | ||
RegisterDeltaLakeDiffPlugin(service, pid, pa) | ||
} | ||
|
||
func diffPluginsDefaultPath(pluginsPath string) string { | ||
pp, _ := homedir.Expand(pluginsPath) | ||
return filepath.Join(pp, "diff") | ||
} |
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
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.
I think we should define the supported formats and not leave it dynamic as it is not dynamic.
If the code was able to support new formats dynamically I would keep the map. But not it looks like we just moved the lookup at runtime to the specific format we support.
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.
Created an issue for that and will be handled in the following iteration.