Skip to content

Add isdag method to determine if a dask is a DAG, and add non-recursive get#12

Merged
mrocklin merged 7 commits intodask:masterfrom
eriknw:isdag_nonrecursive_get
Feb 1, 2015
Merged

Add isdag method to determine if a dask is a DAG, and add non-recursive get#12
mrocklin merged 7 commits intodask:masterfrom
eriknw:isdag_nonrecursive_get

Conversation

@eriknw
Copy link
Member

@eriknw eriknw commented Jan 21, 2015

Both of these additions need better documentation and tests, but I wanted to share.

isdag is a pretty standard DFS, which is stack-based (referring to data container), not recursive.

The non-recursive get is only used when the "get" keyword isn't given. It can handle arbitrarily large graphs, because it is not limited by Python's recursion depth limit. It is also faster than the recursive method.

…sive `get`.

Both of these need better documentation and tests, but I wanted to share.

`isdag` is a pretty standard DFS, which is stack-based (referring to data
container), not recursive.

The non-recursive `get` is only used when the "get" keyword isn't given.
It can handle arbitrarily large graphs, because it is not limited by
Python's recursion depth limit.  It is also faster than the recursive method.
dask/core.py Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're missing a return statement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, I think the return statement got indented a level when I switched the function to work on a list of keys from a single key.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return for this function is on line 86.

dask/core.py Outdated
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change this exception to either a dask-defined exception or a RuntimeError, which is what one would get with a recursive method.

Conflicts:
	dask/tests/test_core.py
…d cycle if not DAG.

Also changed exception raised by non-recursive `get` to RuntimeError.  This
is the same error type that a recursive `get` would return (if `isdag` weren't
checked).  The exception is more informative and shows the nodes in the cycle.
mrocklin added a commit that referenced this pull request Feb 1, 2015
Add `isdag` method to determine if a dask is a DAG, and add non-recursive `get`
@mrocklin mrocklin merged commit fd4a853 into dask:master Feb 1, 2015
mrocklin referenced this pull request in mrocklin/dask Mar 28, 2019
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

Successfully merging this pull request may close these issues.

3 participants