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

Add --stream option to ls command #5611

Merged
merged 7 commits into from
Nov 21, 2018
Merged

Conversation

hannahhoward
Copy link
Contributor

Features

Adds the option to stream results from ls -- so that large directories (particularly HAMT dirs) start returning data immediately instead of waiting for the whole DAG to be walked

Fixes #5600
Requires ipfs/go-unixfs#39

Implementation

  • Update LS Command to use go-ipld-cmds library
  • Update LS Command with --stream option
    • Consume EnumLinksAsync in Ls command instead of synchronous Links method
    • Support breaking up of command output. Instead of LsObject having to be a full directory, it can represent the beginning of a directory, one more more links in a directory, or the end of the directory - so that outputs can be CAT together to produce the same combined output

For Discussion

  • Not mergable until go-unixfs is updated for referenced PR
  • What is our preferred method for unit testing commands?
  • Suggested refactors for ls command file? Feels a bit overloaded and complicated

@alanshaw
Copy link
Member

ping @achingbrain

@hannahhoward
Copy link
Contributor Author

Rebased on master, pending updated go-unixfs. However, in the meantime, ready for review @eingenito @Stebalien @magik6k

@magik6k
Copy link
Member

magik6k commented Nov 1, 2018

Some imports are broken, see jenkins. Try running gx-go rw - - fix && gx-go rw

@hannahhoward
Copy link
Contributor Author

@magik6k the issue is while the code for this is merged into go-unixfs, no new version is published. Is there an appropriate process to update and publish a subpackage like go-unixfs?

@magik6k
Copy link
Member

magik6k commented Nov 1, 2018

You just run gx release [patch/minor/major], pin the hash somewhere (like using pinbot), push.

Then if the thing you are trying to update has dependencies, run gx-workspace bubble-list [package-name] in go-ipfs directory and for each dependency open a PR with updates (gx update QmDependency for each changed dependency), and any changes if necessary.

Alternatively, if there are no breaking/few changes and more than say 2-3 dependencies you should try gx-workspace update (see its --help for more).

@hannahhoward hannahhoward force-pushed the features/streaming-ls-5600 branch 2 times, most recently from 8033722 to a4e3897 Compare November 1, 2018 21:19
@ghost ghost assigned Stebalien Nov 2, 2018
@Stebalien
Copy link
Member

This is now unblocked. Can someone review it?

@kevina kevina self-requested a review November 2, 2018 21:24
Copy link
Contributor

@kevina kevina left a comment

Choose a reason for hiding this comment

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

I am not really happy with all the extra flags and would like to find another way if possible.

core/commands/ls.go Outdated Show resolved Hide resolved
core/commands/ls.go Outdated Show resolved Hide resolved
core/commands/ls.go Outdated Show resolved Hide resolved
core/commands/ls.go Outdated Show resolved Hide resolved
core/commands/ls.go Outdated Show resolved Hide resolved
core/commands/ls.go Outdated Show resolved Hide resolved
@kevina
Copy link
Contributor

kevina commented Nov 5, 2018

@Stebalien This is now blocking #5464. Could we get #5663 in first or separate out the switch to a new commands library into a separate p.r.

@kevina
Copy link
Contributor

kevina commented Nov 5, 2018

If required I would be happy to either separate out the command lib. stuff in a separate commit or rebase this on top of #5663. It shouldn't be that hard and I am not sure I am happy with how things are implemented right now so it may take awhile to get this in.

core/commands/ls.go Outdated Show resolved Hide resolved
magik6k and others added 3 commits November 16, 2018 14:53
uses single flag to support state needed by PostRun
supports encoding=text

License: MIT
Signed-off-by: hannahhoward <hannah@hannahhoward.net>
License: MIT
Signed-off-by: hannahhoward <hannah@hannahhoward.net>
License: MIT
Signed-off-by: hannahhoward <hannah@hannahhoward.net>
@hannahhoward
Copy link
Contributor Author

@Stebalien this incorporates @kevina 's last round of suggestions and I think is ready to merge, pending your approval.

Copy link
Contributor

@kevina kevina left a comment

Choose a reason for hiding this comment

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

LGTM now.

There is one comment by @magik6k that I think should be addressed, but we can also clean that up later.


func makeDagNodeLinkResults(req *cmds.Request, dagnode ipld.Node) <-chan unixfs.LinkResult {
linkResults := make(chan unixfs.LinkResult)
go func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, but we can clean this up afterwards.

@hannahhoward
Copy link
Contributor Author

@kevina did cleanup suggested by @magik6k. thank you for the reminder

kevina
kevina previously requested changes Nov 19, 2018
Copy link
Contributor

@kevina kevina left a comment

Choose a reason for hiding this comment

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

See comment.

License: MIT
Signed-off-by: hannahhoward <hannah@hannahhoward.net>
@kevina kevina dismissed their stale review November 20, 2018 21:00

Remaining issue is minor.

@kevina
Copy link
Contributor

kevina commented Nov 20, 2018

@Stebalien there is one minor issue (keeping me from approving) but otherwise this LGTM.

@Stebalien Stebalien merged commit b7a4853 into master Nov 21, 2018
@ghost ghost removed the status/in-progress In progress label Nov 21, 2018
@Stebalien
Copy link
Member

Thank @hannahhoward and everyone that reviewed this. Finding a solution when there is no good solution is painful and difficult but you all managed to do it.

🎉

@hannahhoward
Copy link
Contributor Author

Thanks @Stebalien and @kevina and @magik6k for all the feedback!

achingbrain added a commit to ipfs-inactive/js-ipfs-http-client that referenced this pull request Dec 4, 2018
N.b will not actually do any streaming until ipfs/kubo#5611
lands
achingbrain added a commit to ipfs-inactive/interface-js-ipfs-core that referenced this pull request Dec 4, 2018
N.b will not actually do any streaming until ipfs/kubo#5611 is released.
achingbrain added a commit to ipfs-inactive/interface-js-ipfs-core that referenced this pull request Dec 4, 2018
The only mfs ls method at the moment buffers the output into an array
before returning it to the user. This PR adds two new methods,
lsPullStream and lsReadableStream to allow the user to either buffer
the output themseleves (in case they need sorting, etc) or just
stream it on to an output of some sort.

N.b the http API will not actually do any streaming until ipfs/kubo#5611
is released.
achingbrain added a commit to ipfs-inactive/js-ipfs-http-client that referenced this pull request Dec 4, 2018
N.b will not actually do any streaming until ipfs/kubo#5611
lands
alanshaw pushed a commit to ipfs-inactive/interface-js-ipfs-core that referenced this pull request Dec 4, 2018
The only mfs ls method at the moment buffers the output into an array
before returning it to the user. This PR adds two new methods,
lsPullStream and lsReadableStream to allow the user to either buffer
the output themseleves (in case they need sorting, etc) or just
stream it on to an output of some sort.

N.b the http API will not actually do any streaming until ipfs/kubo#5611
is released.
@Stebalien Stebalien deleted the features/streaming-ls-5600 branch February 28, 2019 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants