Skip to content

Commit

Permalink
Update computation code retrieval logic (#5236)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbourbeau authored Aug 19, 2021
1 parent d904773 commit 8cff8b7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion distributed/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2522,7 +2522,7 @@ def _get_computation_code() -> str:

for fr, _ in traceback.walk_stack(None):
if pattern is None or (
not pattern.match(fr.f_globals["__name__"])
not pattern.match(fr.f_globals.get("__name__", ""))
and fr.f_code.co_name not in ("<listcomp>", "<dictcomp>")
):
try:
Expand Down
19 changes: 19 additions & 0 deletions distributed/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6774,6 +6774,25 @@ def fetch_comp_code(dask_scheduler):
assert code == test_function_code


def test_computation_object_code_not_available(client):
np = pytest.importorskip("numpy")
pd = pytest.importorskip("pandas")
dd = pytest.importorskip("dask.dataframe")
df = pd.DataFrame({"a": range(10)})
ddf = dd.from_pandas(df, npartitions=3)
result = np.where(ddf.a > 4)

def fetch_comp_code(dask_scheduler):
computations = list(dask_scheduler.computations)
assert len(computations) == 1
comp = computations[0]
assert len(comp.code) == 1
return comp.code[0]

code = client.run_on_scheduler(fetch_comp_code)
assert code == "<Code not available>"


@gen_cluster(client=True)
async def test_computation_object_code_dask_persist(c, s, a, b):
da = pytest.importorskip("dask.array")
Expand Down

0 comments on commit 8cff8b7

Please sign in to comment.