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

Implement dak.backend as an overload of ak.backend #497

Closed
jpivarski opened this issue Apr 11, 2024 · 6 comments · Fixed by #498
Closed

Implement dak.backend as an overload of ak.backend #497

jpivarski opened this issue Apr 11, 2024 · 6 comments · Fixed by #498

Comments

@jpivarski
Copy link
Collaborator

The implementation would be really easy:

# in dask-awkward

def backend(*arrays):
    ak_arrays = [x._meta if isinstance(x, dak.Array) else x for x in arrays]
    return ak.backend(*ak_arrays)

but it would fix scikit-hep/awkward#3077. See the discussion there, particularly the end of scikit-hep/awkward#3077 (comment).

@martindurant
Copy link
Collaborator

Do you intend to make this a PR? I don't see any problem with it.

@jpivarski
Copy link
Collaborator Author

In which module should I put it?

@martindurant
Copy link
Collaborator

Hmm... I have no better idea than utils, which catches everything else.

@jpivarski
Copy link
Collaborator Author

utils.py doesn't have user-facing functions. The describe.py/reducers.py/structure.py is reminiscent of the way Awkward 1 organized its functions (same module names), before we switched to having one file per ak.* function, which I like much better, even if some of the files are really small.

In the describe.py/reducers.py/structure.py taxonomy, I guess backend would go into describe.py, so I'll put it there.

I'll open PR.

@agoose77
Copy link
Collaborator

I'm about to head out the door, but this would always return typetracer for meta arrays, which is probably not what we want.

@jpivarski
Copy link
Collaborator Author

In fact, I wrote the test as assert dak.backend(daa) == "typetracer". Coffea code is using ak.backend(something) to determine if something is a typetracer-backed array. Right now, that's equivalent to being a dask-awkward array and they could have checked isinstance(something, (dak.Array, dak.Record, dak.Scalar)) instead, but checking the backend may be preferable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants