Skip to content
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

ML-2296: Add support for datastore profiles #455

Merged
merged 3 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion integration/test_filesystems_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import pandas as pd
import pytest
import v3io
from fsspec.implementations.local import LocalFileSystem

from integration.integration_test_utils import V3ioHeaders, _generate_table_name
from storey import (
Expand All @@ -38,7 +39,7 @@
build_flow,
)
from storey.dtypes import V3ioError
from storey.utils import get_remaining_path
from storey.utils import get_remaining_path, url_to_file_system


@pytest.fixture()
Expand Down Expand Up @@ -672,3 +673,10 @@ def test_get_path_utils():
schema, path = get_remaining_path(url)
assert path == "mycontainer/path/to/object.csv"
assert schema == "wasbs"


def test_ds_get_path_utils():
gtopper marked this conversation as resolved.
Show resolved Hide resolved
url = "ds://:file@profile/path/to/object.csv"
fs, path = url_to_file_system(url, "")
assert path == "/path/to/object.csv"
assert isinstance(fs, LocalFileSystem)
8 changes: 7 additions & 1 deletion storey/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def get_remaining_path(url):
if "://" in url:
parsed_url = urlparse(url)
scheme = parsed_url.scheme.lower()
if scheme in ("v3io", "dbfs"):
if scheme in ("ds", "v3io", "dbfs"):
remaining_path = parsed_url.path
elif scheme in ["wasb", "wasbs"]:
remaining_path = f"{parsed_url.username}{parsed_url.path}"
Expand All @@ -138,6 +138,12 @@ def get_remaining_path(url):

def url_to_file_system(url, storage_options):
scheme, remaining_path = get_remaining_path(url)
if url.startswith("ds://"):
parsed_url = urlparse(url)
if parsed_url.password:
scheme = parsed_url.password
gtopper marked this conversation as resolved.
Show resolved Hide resolved
else:
raise ValueError("Datastore profile URL is expected to have underlying scheme embedded as password")
if scheme:
load_fs_dependencies(scheme)

Expand Down