-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(load): Simplify Loader more, various cleanups
Loader now only provides LoadDataset. LoadResolved has been removed. For base, cleanup the simpler implementation that it has, and use that for transform and sql tests. Change handling of dataset names so that it is now an error to use upper-case letters, not just a warning. Rename can still be used to fix bad names fsi loading is handled by the loader via a useFSI flag, which scope sets for the few commands that require it. Fix the bug with listWarning that prevented `list` from working if the user's refstore contained bad username / profileID combinations Remove some TODOs that are no longer applicable. TODO: lib/load_test is not working due to changes in the semantics of LoadDataset. Need to figure out how to fix it before merging.
- Loading branch information
Showing
24 changed files
with
199 additions
and
12,804 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,45 @@ | ||
package base | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/qri-io/dataset" | ||
"github.com/qri-io/qfs" | ||
"github.com/qri-io/qri/base/dsfs" | ||
"github.com/qri-io/qri/dsref" | ||
) | ||
|
||
type loader struct { | ||
fs qfs.Filesystem | ||
resolver dsref.Resolver | ||
} | ||
|
||
// NewTestDatasetLoader constructs a loader that is useful for tests | ||
// since they only need a simplified version of resolution and loading | ||
func NewTestDatasetLoader(fs qfs.Filesystem, resolver dsref.Resolver) dsref.Loader { | ||
return loader{ | ||
fs: fs, | ||
resolver: resolver, | ||
} | ||
} | ||
|
||
// LoadDataset loads a dataset | ||
func (l loader) LoadDataset(ctx context.Context, refstr string) (*dataset.Dataset, error) { | ||
ref, err := dsref.Parse(refstr) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
_, err = l.resolver.ResolveRef(ctx, &ref) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ds, err := dsfs.LoadDataset(ctx, l.fs, ref.Path) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
err = OpenDataset(ctx, l.fs, ds) | ||
return ds, err | ||
} |
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
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
Oops, something went wrong.