Skip to content

Commit

Permalink
Fix get protocol and path (#4409)
Browse files Browse the repository at this point in the history
* Fixed _parse_filepath

Signed-off-by: Elena Khaustova <[email protected]>

* Updated unit tests

Signed-off-by: Elena Khaustova <[email protected]>

* Updated release notes

Signed-off-by: Elena Khaustova <[email protected]>

---------

Signed-off-by: Elena Khaustova <[email protected]>
  • Loading branch information
ElenaKhaustova authored Jan 14, 2025
1 parent f72d5cd commit 25bb58b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Added `node` import to the pipeline template.
* Update error message when executing kedro run without pipeline.
* Safeguard hooks when user incorrectly registers a hook class in settings.py.
* Fixed parsing paths with query and fragment.

## Breaking changes to the API
## Documentation changes
Expand Down
5 changes: 5 additions & 0 deletions kedro/io/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,11 @@ def _parse_filepath(filepath: str) -> dict[str, str]:
if windows_path:
path = ":".join(windows_path.groups())

if parsed_path.query:
path = f"{path}?{parsed_path.query}"
if parsed_path.fragment:
path = f"{path}#{parsed_path.fragment}"

options = {"protocol": protocol, "path": path}

if parsed_path.netloc and protocol in CLOUD_PROTOCOLS:
Expand Down
18 changes: 18 additions & 0 deletions tests/io/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,24 @@ def test_get_filepath_str(self):
("file:///C:\\Projects\\file.txt", ("file", "C:\\Projects\\file.txt")),
("https://example.com/file.txt", ("https", "example.com/file.txt")),
("http://example.com/file.txt", ("http", "example.com/file.txt")),
(
"https://example.com/search?query=books&category=fiction#reviews",
("https", "example.com/search?query=books&category=fiction#reviews"),
),
(
"https://example.com/search#reviews",
("https", "example.com/search#reviews"),
),
(
"http://example.com/search?query=books&category=fiction",
("http", "example.com/search?query=books&category=fiction"),
),
(
"s3://some/example?query=query#filename",
("s3", "some/example?query=query#filename"),
),
("s3://some/example#filename", ("s3", "some/example#filename")),
("s3://some/example?query=query", ("s3", "some/example?query=query")),
],
)
def test_get_protocol_and_path(self, filepath, expected_result):
Expand Down

0 comments on commit 25bb58b

Please sign in to comment.