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

A better DSL for flow queries #39

Closed
nsbgn opened this issue Sep 24, 2021 · 4 comments
Closed

A better DSL for flow queries #39

nsbgn opened this issue Sep 24, 2021 · 4 comments

Comments

@nsbgn
Copy link
Contributor

nsbgn commented Sep 24, 2021

Right now, querying workflows is done using Flows, which are constructed by abusing Python's >> operator and ... ellipsis type. This is not future-proof, because it leaves very little room for adding functionality, and there are some other issues (such as: how do you express at what node a flow starts?)

A LINQ-style domain-specific language within Python would probably fit better.

@nsbgn nsbgn added this to the Version 0.2: RDF support milestone Sep 24, 2021
@nsbgn
Copy link
Contributor Author

nsbgn commented Oct 5, 2021

A format like the following would probably be most:

Flow(a, b & Flow(..., c, d, ...))

Or perhaps 'Seq' instead of 'Flow'?

@nsbgn
Copy link
Contributor Author

nsbgn commented Oct 5, 2021

Perhaps best to just use lists for branches and tuples for sequences.

Flow(R3a(Obj, Reg, Ratio), ..., apply, [
        (..., ratio),
        (..., groupby, [(..., size), (..., pi1, R2(L, _))]),
        (..., apply, [(..., size), (..., R2(Obj, Reg))])
    ]
)

nsbgn added a commit that referenced this issue Oct 6, 2021
A better DSL was necessary for `Flow`s (workflow queries), because the
previous approach of abusing Python operators was confusing and not
future-proof, as mentioned in issue #39. This commit improves the
situation: we may now use `Flow.serial()`, with tuples for serial flows
and lists for parallel flows.

Additionally, the use of the ellipsis and the necessary recursive types
should now be typechecked.
@nsbgn
Copy link
Contributor Author

nsbgn commented Oct 6, 2021

Closed 6bee39b

@nsbgn
Copy link
Contributor Author

nsbgn commented Oct 15, 2021

Note that the reflected << operator (__rrshift__) could also have been used to allow ... in the first position. The solution I went with is still preferable, though, because it's more concise and idiomatic (at the small cost of not having an intuitive visual indicator for the direction of flow).

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

1 participant