-
Notifications
You must be signed in to change notification settings - Fork 18
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
Resolve relative links used by multi-level datasets as specified #637
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
27d2e44
In FS data stores, multi-level datasets now behave as specified
forman 8994c7b
In levels module, multi-level datasets now behave as specified
forman 0feb3bb
Removed silly question
forman a664085
Documented new property
forman 29f7de4
Added docs & tests
forman ec2fa48
Update
forman 1149ff1
Merge branch 'master' into forman-636-resolve_rel_mldataset_links
forman 2058a47
Merge branch 'master' into forman-636-resolve_rel_mldataset_links
forman 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import pathlib | ||
import unittest | ||
|
||
import fsspec | ||
import fsspec.implementations.local | ||
|
||
from xcube.core.store.fs.helpers import get_fs_path_class | ||
from xcube.core.store.fs.helpers import resolve_path | ||
|
||
|
||
class FsHelpersTest(unittest.TestCase): | ||
|
||
def test_resolve_path_succeeds(self): | ||
path = pathlib.PurePosixPath("a", "b", "c") | ||
self.assertEqual(pathlib.PurePosixPath("a", "b", "c"), | ||
resolve_path(path)) | ||
|
||
path = pathlib.PurePosixPath(".", "b", "c") | ||
self.assertEqual(pathlib.PurePosixPath("b", "c"), | ||
resolve_path(path)) | ||
|
||
path = pathlib.PurePosixPath("a", ".", "c") | ||
self.assertEqual(pathlib.PurePosixPath("a", "c"), | ||
resolve_path(path)) | ||
|
||
path = pathlib.PurePosixPath("a", "b", ".") | ||
self.assertEqual(pathlib.PurePosixPath("a", "b"), | ||
resolve_path(path)) | ||
|
||
path = pathlib.PurePosixPath("a", "..", "c") | ||
self.assertEqual(pathlib.PurePosixPath("c"), | ||
resolve_path(path)) | ||
|
||
path = pathlib.PurePosixPath("a", "b", "..") | ||
self.assertEqual(pathlib.PurePosixPath("a"), | ||
resolve_path(path)) | ||
|
||
def test_resolve_path_fails(self): | ||
path = pathlib.PurePosixPath("..", "b", "c") | ||
with self.assertRaises(ValueError) as cm: | ||
resolve_path(path) | ||
self.assertEqual('cannot resolve path, misplaced ".."', | ||
f'{cm.exception}') | ||
|
||
path = pathlib.PurePosixPath("a", "..", "..") | ||
with self.assertRaises(ValueError) as cm: | ||
resolve_path(path) | ||
self.assertEqual('cannot resolve path, misplaced ".."', | ||
f'{cm.exception}') | ||
|
||
def test_get_fs_path_class(self): | ||
self.assertIs(pathlib.PurePath, | ||
get_fs_path_class( | ||
fsspec.implementations.local.LocalFileSystem() | ||
)) | ||
self.assertIs(pathlib.PurePath, | ||
get_fs_path_class(fsspec.filesystem("file"))) | ||
self.assertIs(pathlib.PurePosixPath, | ||
get_fs_path_class(fsspec.filesystem("s3"))) | ||
self.assertIs(pathlib.PurePosixPath, | ||
get_fs_path_class(fsspec.filesystem("memory"))) |
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.
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.
This method also returns the appropriate path class for other file systems.
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.
What other filesystems? There is only one argument named fs.