Exception when executing task graph with HighLevelGraph after a shuffle
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 42/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- python
调研方向
使用 Dask 2024.8.1 和 dask-expr 1.1.11 运行最小的完整可验证示例,然后检查 dask_geopandas/sjoin.py 中的 HighLevelGraph 构建以及 dask_expr.from_graph 调用。跟踪 shuffle 键在 x1.compute() 期间的解析方式;当图将其替换为具体的 DataFrames 且示例在没有 TypeError 的情况下完成时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Describe the issue:
In https://github.com/geopandas/dask-geopandas/issues/303, dask-geopandas has a report that its custom sjoin method fails with a TypeError under some conditions. Internally, that method constructs a HighLevelGraph.
The observed failure is a TypeError raised by geopandas because dask fails to substitute the concrete (geo)DataFrame for the key (name, partition_number) when executing the task graph.
I've managed to produce a dask / dask-expr only version:
Minimal Complete Verifiable Example:
import dask.dataframe as dd
import pandas as pd
import dask
import dask_expr
dask.config.set(scheduler="single-threaded")
l1 = dd.from_pandas(pd.DataFrame({"a": [1, 2], "b": [0, 0]}), npartitions=1).shuffle("a")
r1 = dd.from_pandas(pd.DataFrame({"a": [1, 3], "c": [1, 1]}), npartitions=1).shuffle("a")
def func(left, right):
assert isinstance(left, pd.DataFrame), f"Wrong type {left}"
return pd.merge(left, right, how="inner")
dsk = {}
name = "myjoin-" + dask.base.tokenize(l1, r1, ensure_deterministic=True)
for i in range(1):
dsk[(name, i)] = (
func,
(l1._name, i),
(r1._name, i),
)
divisions = [None] * (len(dsk) + 1)
g1 = dask.highlevelgraph.HighLevelGraph.from_collections(name, dsk, dependencies=[l1, r1])
x1 = dask_expr.from_graph(g1, func(l1._meta, r1._meta), divisions, dsk.keys(), "myjoin")
x1.compute()
That fails with
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Cell In[3], line 30
28 g1 = dask.highlevelgraph.HighLevelGraph.from_collections(name, dsk, dependencies=[l1, r1])
29 x1 = dask_expr.from_graph(g1, func(l1._meta, r1._meta), divisions, dsk.keys(), "myjoin")
---> 30 x1.compute()
File [~/gh/geopandas/dask-geopandas/.direnv/python-3.10/lib/python3.10/site-packages/dask_expr/_collection.py:477](http://127.0.0.1:8889/~/gh/geopandas/dask-geopandas/.direnv/python-3.10/lib/python3.10/site-packages/dask_expr/_collection.py#line=476), in FrameBase.compute(self, fuse, **kwargs)
475 out = out.repartition(npartitions=1)
476 out = out.optimize(fuse=fuse)
--> 477 return DaskMethodsMixin.compute(out, **kwargs)
File [~/gh/geopandas/dask-geopandas/.direnv/python-3.10/lib/python3.10/site-packages/dask/base.py:376](http://127.0.0.1:8889/~/gh/geopandas/dask-geopandas/.direnv/python-3.10/lib/python3.10/site-packages/dask/base.py#line=375), in DaskMethodsMixin.compute(self, **kwargs)
352 def compute(self, **kwargs):
353 """Compute this dask collection
354
355 This turns a lazy Dask collection into its in-memory equivalent.
(...)
374 dask.compute
375 """
--> 376 (result,) = compute(self, traverse=False, **kwargs)
377 return result
File [~/gh/geopandas/dask-geopandas/.direnv/python-3.10/lib/python3.10/site-packages/dask/base.py:662](http://127.0.0.1:8889/~/gh/geopandas/dask-geopandas/.direnv/python-3.10/lib/python3.10/site-packages/dask/base.py#line=661), in compute(traverse, optimize_graph, scheduler, get, *args, **kwargs)
659 postcomputes.append(x.__dask_postcompute__())
661 with shorten_traceback():
--> 662 results = schedule(dsk, keys, **kwargs)
664 return repack([f(r, *a) for r, (f, a) in zip(results, postcomputes)])
Cell In[3], line 14, in func(left, right)
13 def func(left, right):
---> 14 assert isinstance(left, pd.DataFrame), f"Wrong type {left}"
15 return pd.merge(left, right, how="inner")
AssertionError: Wrong type ('rearrangebycolumn-8e5135a4ed46029cf9bb3c4bc7eff32e', 0)
As I mentioned, the shuffle there is important. Without that shuffle, things work fine.
Anything else we need to know?:
I'll take a look at this today.
Environment:
- Dask version: '2024.8.1'
- dask-expr version: '1.1.11'
- 主要语言
- Python
- 星标
- 89
- 派生
- 26
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dask/dask-expr 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 38/100
-
难度 3/5 1-2 天 新手友好度 45/100
-
难度 5/5 一周以上 新手友好度 30/100
-
难度 4/5 3-5 天 新手友好度 30/100
-
难度 3/5 1-2 天 新手友好度 25/100
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
BCDA-APS/polar-bits#93 ·
-
infer_audio_type only recognises one MPEG Layer III frame header, so most MP3 files are rejected可能已有人在做 @Steve-20-ai 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
[BUG] - ssh_config `Match tagged` statement always applies可能已有人在做 @AtharvRG 今天认领。 未关闭Bug
难度 2/5 1-3 小时 新手友好度 68/100
paramiko/paramiko#2715 · 1 条评论 ·
维护者通常 9 天内回复
-
auto-rejected intake mcp-intake needs-salvage priority:high type:feature
难度 2/5 1-3 小时 新手友好度 65/100
Ikalus1988/MisakaNet#4221 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复