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

Parallel recursive breadth-first w.workspace.list(..., recursive=True, threads=os.cpu_count()) to iterate over 10K notebooks faster #284

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nfx
Copy link
Contributor

@nfx nfx commented Aug 11, 2023

for when we need to list 10K notebooks a bit faster.

Copy link
Contributor

@pietern pietern left a comment

Choose a reason for hiding this comment

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

Couple notes, I think this probably hangs as-is.

databricks/sdk/mixins/workspace.py Outdated Show resolved Hide resolved
databricks/sdk/mixins/workspace.py Show resolved Hide resolved
databricks/sdk/mixins/workspace.py Outdated Show resolved Hide resolved
databricks/sdk/mixins/workspace.py Outdated Show resolved Hide resolved
@nfx nfx changed the title (PoC) Parallel recursive listing for w.workspace.list() Parallel recursive listing for w.workspace.list() Sep 21, 2023
@nfx nfx changed the title Parallel recursive listing for w.workspace.list() Parallel recursive breadth-first listing for w.workspace.list() to iterate over 10K notebooks faster Sep 21, 2023
@nfx nfx changed the title Parallel recursive breadth-first listing for w.workspace.list() to iterate over 10K notebooks faster Parallel recursive breadth-first w.workspace.list(..., recursive=True, threads=os.cpu_count()) to iterate over 10K notebooks faster Sep 21, 2023
@nfx nfx added the ergonomics UX of SDK label Sep 25, 2023
Copy link
Contributor

@mgyucht mgyucht left a comment

Choose a reason for hiding this comment

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

I think this is a good addition to the SDK. Let's drop the reporter for now, or if you want, add it as a parameter to this API. Aside from this, I think there is one bug in the _list method.

Can we add an integration test where we actually create some recursive directory structure, try to list everything, and check that it worked correctly?

def _list(self, path):
listing = self._listing(path, notebooks_modified_after=self._notebooks_modified_after)
for object_info in sorted(listing, key=lambda _: _.path):
if object_info.object_type != ObjectType.DIRECTORY:
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 this should be ==? The code in this block refers to what happens in a directory.

with self._cond:
return self._in_progress > 0

def _reporter(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

The reporter is a bit weird. Given that this is a generator and users may not list all of the items "right away", this would just continue to print logs until the generator is consumed. Alternatively, this could be provided as a parameter to the parallel list operation, allowing users to provide a callback that is periodically called with statistics like this if they desire, then they can control when/whether they want to log or do something else.

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

Successfully merging this pull request may close these issues.

3 participants