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

index on repr #13

Open
majidaldo opened this issue Jul 1, 2021 · 8 comments
Open

index on repr #13

majidaldo opened this issue Jul 1, 2021 · 8 comments

Comments

@majidaldo
Copy link

When the structures get really nested, it would be nice to have an index printed out in the structure.

@brandonwillard
Copy link
Member

Can you provide an example/illustration?

@majidaldo
Copy link
Author

majidaldo commented Jul 2, 2021

Like pipeliney process structure: begin with something and put it through operations.

from etuples import etuple as et
def add1(x): return x+1
e = et(add1, 1)
e = et(add1, e) # say i want to index into this etuple
e = et(add1, e) 
#...
e = et(add1, e)
e

shows up as

e(
  <function __main__.add1(x)>,
  e(
    <function __main__.add1(x)>,
   # v-- what's the index into this one?
    e(<function __main__.add1(x)>, e(<function __main__.add1(x)>, 1))))

i have some great use cases for being able to easily get to a node.

@brandonwillard
Copy link
Member

brandonwillard commented Aug 30, 2021

Yes, easy access to a particular node like that would be nice.

The easiest approach might involve unique labels. A debug print-out could apply a very deterministic unique labeling, so one would determine which label they wanted to select by viewing that print-out, and then a follow-up "get"-like method could be given said label and return the associated node.

In this case, the index you're requesting is the label and we would need to implement two things: general etuple graph printing, unique (and convenient) labeling for that, and a query function.

Aside from that, I've seen symbolic libraries offer query languages (e.g. JSON-like and/or REGEX-based) for more general cases of this sort of thing, but that's ultimately what unification and/or kanren does. Since we wouldn't want to reinvent those wheels, if such a query languages was necessary, it would have to serve as a more palatable front-end for unification/kanren.

@majidaldo
Copy link
Author

Yes, easy access to a particular node like that would be nice.

The easiest approach might involve unique labels. A debug print-out could apply a very deterministic unique labeling, so one would determine which label they wanted to select by viewing that print-out, and then a follow-up "get"-like method could be given said label and return the associated node.

idk maybe make use of what dask does here.

@majidaldo
Copy link
Author

majidaldo commented Aug 30, 2021

Aside from that, I've seen symbolic libraries offer query languages (e.g. JSON-like and/or REGEX-based) for more general cases of this sort of thing, but that's ultimately what unification and/or kanren does. Since we wouldn't want to reinvent those wheels, if such a query languages was necessary, it would have to serve as a more palatable front-end for unification/kanren.

My thought here is to keep this as a separate layer; Essentially, kanren provides a graph onto which you can use whatever query language you'd like.

i've actually experimented with making kanren more palatable by using dataclasses where mappings b/w classes are arbitrary python code instead of relations. i found that describing everything as a relation makes it difficult to use. (there needs to be a path from 'normal' programming to having it be a strict relational program.)

@brandonwillard
Copy link
Member

idk maybe make use of what dask does here.

Which part of what Dask does?

I don't remember whether or not Dask assigns unique IDs/labels when nodes are created, but that's a possibility—depending on how well this library sticks to immutability. Even so, I don't know if this would make sense for a repr, but such an ID could be part of a str representation.

@majidaldo
Copy link
Author

idk maybe make use of what dask does here.

Which part of what Dask does?

I don't remember whether or not Dask assigns unique IDs/labels when nodes are created, but that's a possibility—depending on how well this library sticks to immutability. Even so, I don't know if this would make sense for a repr, but such an ID could be part of a str representation.

I think every execution aspect of of etuples can be subsumbed by dask https://docs.dask.org/en/latest/graphs.html. Immutability/pure-funcs as well as naming nodes (dask_key_name) are figured out.

Considering that, etuples value would be to provide a programming model different from dask.delayed (focusing on expressions).

@brandonwillard
Copy link
Member

brandonwillard commented Aug 30, 2021

I think every execution aspect of of etuples can be subsumbed by dask https://docs.dask.org/en/latest/graphs.html. Immutability/pure-funcs as well as naming nodes (dask_key_name) are figured out.

Considering that, etuples value would be to provide a programming model different from dask.delayed (focusing on expressions).

A comparison with Dask's graphs isn't particularly useful. The way in which they both share the same concerns, features, etc., is far too simple (e.g. using tuples or dicts to represent a graph), and the rest is extremely dependent on unshared contexts and goals—design and otherwise.

There's also nothing that really needs to be figured out, aside from feature-based choices.

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

No branches or pull requests

2 participants