forked from fsspec/adlfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated _strip_protocol to support flexible urls * Commits for flexible url handling * Added unit test to evaluate new url format * Linting
- Loading branch information
Showing
5 changed files
with
90 additions
and
4 deletions.
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
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,53 @@ | ||
import dask.dataframe as dd | ||
import pandas as pd | ||
from pandas.testing import assert_frame_equal | ||
|
||
from adlfs import AzureBlobFileSystem | ||
|
||
|
||
URL = "http://127.0.0.1:10000" | ||
ACCOUNT_NAME = "devstoreaccount1" | ||
KEY = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" # NOQA | ||
CONN_STR = f"DefaultEndpointsProtocol=http;AccountName={ACCOUNT_NAME};AccountKey={KEY};BlobEndpoint={URL}/{ACCOUNT_NAME};" # NOQA | ||
|
||
|
||
def test_dask_parquet(storage): | ||
fs = AzureBlobFileSystem( | ||
account_name=storage.account_name, connection_string=CONN_STR | ||
) | ||
fs.mkdir("test") | ||
STORAGE_OPTIONS = { | ||
"account_name": "devstoreaccount1", | ||
"connection_string": CONN_STR, | ||
} | ||
df = pd.DataFrame( | ||
{ | ||
"col1": [1, 2, 3, 4], | ||
"col2": [2, 4, 6, 8], | ||
"index_key": [1, 1, 2, 2], | ||
"partition_key": [1, 1, 2, 2], | ||
} | ||
) | ||
|
||
dask_dataframe = dd.from_pandas(df, npartitions=1) | ||
for protocol in ["abfs", "az"]: | ||
dask_dataframe.to_parquet( | ||
"{}://test@dfs.core.windows.net/test_group.parquet".format(protocol), | ||
storage_options=STORAGE_OPTIONS, | ||
engine="pyarrow", | ||
) | ||
|
||
fs = AzureBlobFileSystem(**STORAGE_OPTIONS) | ||
assert fs.ls("test/test_group.parquet") == [ | ||
"test/test_group.parquet/_common_metadata", | ||
"test/test_group.parquet/_metadata", | ||
"test/test_group.parquet/part.0.parquet", | ||
] | ||
fs.rm("test/test_group.parquet") | ||
|
||
df_test = dd.read_parquet( | ||
"abfs://test/test_group.parquet", | ||
storage_options=STORAGE_OPTIONS, | ||
engine="pyarrow", | ||
).compute() | ||
assert_frame_equal(df, df_test) |