Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 93
unpinning dask#1006
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
Uh oh!
There was an error while loading. Please reload this page.
unpinning dask #1006
Changes from all commits
dd38ad44feb4911c042eab733de2e53e2153ae1d2919684fb51b733e88fe003d8b2cc4239f693afad6bde017ca7d11655a8253eb8078469a65839b41a7bfbfa7a6018f1fb487d7d0b4d66a60952c8150947670da8b18989e3c8bc8868a5a2d43753cf7e0caae0ab1d84257183b765da2e49a58048b38b9ed6b45797630160415c891541265dc40fdeb5206aa3770407e2905e5f46e225f76672ef68d55d9f2654939dc8fb1a8343918fdb70d43cac1a78c6808d5251bb9a228a7efabfe3ed65bd182429642c245293b48be1813c8450374bbfafede5a06302d990891a72121d3File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -14,6 +14,7 @@ | ||
| import zarr | ||
| from anndata import AnnData | ||
| from dask._task_spec import Task | ||
| from dask.array import Array as DaskArray | ||
| from dask.dataframe import DataFrame as DaskDataFrame | ||
| from geopandas import GeoDataFrame | ||
| @@ -301,6 +302,19 @@ def _get_backing_files(element: DaskArray | DaskDataFrame) -> list[str]: | ||
| return files | ||
| def _find_piece_dict(obj: dict[str, tuple[str | None]] | Task) -> dict[str, tuple[str | None | None]] | None: | ||
| """Recursively search for dict containing the key 'piece' in Dask task specs containing the parquet file path.""" | ||
| if isinstance(obj, dict): | ||
| if "piece" in obj: | ||
| return obj | ||
| elif hasattr(obj, "args"): # Handles dask._task_spec.* objects like Task and List | ||
| for v in obj.args: | ||
| result = _find_piece_dict(v) | ||
| if result is not None: | ||
| return result | ||
| return None | ||
| def _search_for_backing_files_recursively(subgraph: Any, files: list[str]) -> None: | ||
| # see the types allowed for the dask graph here: https://docs.dask.org/en/stable/spec.html | ||
| @@ -327,25 +341,31 @@ def _search_for_backing_files_recursively(subgraph: Any, files: list[str]) -> No | ||
| path = getattr(v.store, "path", None) if getattr(v.store, "path", None) else v.store.root | ||
| files.append(str(UPath(path).resolve())) | ||
| elif name.startswith("read-parquet") or name.startswith("read_parquet"): | ||
| if hasattr(v, "creation_info"): | ||
| # https://github.com/dask/dask/blob/ff2488aec44d641696e0b7aa41ed9e995c710705/dask/dataframe/io/parquet/core.py#L625 | ||
| t = v.creation_info["args"] | ||
| if not isinstance(t, tuple) or len(t) != 1: | ||
| raise ValueError( | ||
| f"Unable to parse the parquet file from the dask subgraph {subgraph}. Please " | ||
| f"report this bug." | ||
| ) | ||
| parquet_file = t[0] | ||
| files.append(str(UPath(parquet_file).resolve())) | ||
| elif isinstance(v, tuple) and len(v) > 1 and isinstance(v[1], dict) and "piece" in v[1]: | ||
| # Here v is a read_parquet task with arguments and the only value is a dictionary. | ||
| if "piece" in v.args[0]: | ||
| # https://github.com/dask/dask/blob/ff2488aec44d641696e0b7aa41ed9e995c710705/dask/dataframe/io/parquet/core.py#L870 | ||
| parquet_file, check0, check1 = v[1]["piece"] | ||
| parquet_file, check0, check1 = v.args[0]["piece"] | ||
| if not parquet_file.endswith(".parquet") or check0 is not None or check1 is not None: | ||
melonora marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| raise ValueError( | ||
| f"Unable to parse the parquet file from the dask subgraph {subgraph}. Please " | ||
| f"report this bug." | ||
| ) | ||
melonora marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| files.append(os.path.realpath(parquet_file)) | ||
| else: | ||
| # This occurs when for example points and images are mixed, the main task still starts with | ||
| # read_parquet, but the execution happens through a subgraph which we iterate over to get the | ||
| # actual read_parquet task. | ||
| for task in v.args[0].values(): | ||
| # Recursively go through tasks, this is required because differences between dask versions. | ||
| piece_dict = _find_piece_dict(task) | ||
| if isinstance(piece_dict, dict) and "piece" in piece_dict: | ||
| parquet_file, check0, check1 = piece_dict["piece"] # type: ignore[misc] | ||
| if not parquet_file.endswith(".parquet") or check0 is not None or check1 is not None: | ||
| raise ValueError( | ||
| f"Unable to parse the parquet file from the dask subgraph {subgraph}. Please " | ||
| f"report this bug." | ||
| ) | ||
| files.append(os.path.realpath(parquet_file)) | ||
| def _backed_elements_contained_in_path(path: Path, object: SpatialData | SpatialElement | AnnData) -> list[bool]: | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
Do you think that we could report this to
dask? Maybe it is an unintended change. Or was it more that the order was never guaranteed in the first place?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.
I will discuss it during their community meeting. I would have to dive a bit deeper into the exact cause, but they themselves don't seem to define
set_categoriesso to me it seems like it comes from pandas dataframe but then the pandas dataframe only works per partition, but I am not certain about that. I did not want to spend too much time on it for now though as they can point me in the right direction much quicker.