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

community[patch]: avoid shouldIgnore on folders for GithubRepoLoader #6255

Merged

Conversation

DipFlip
Copy link
Contributor

@DipFlip DipFlip commented Jul 29, 2024

This PR avoids the shouldIgnore check on directories when looping over files in a github repo that is loaded using the GithubRepoLoader.

The issue with checking shouldIgnore on a directory is that a directory path might match an ignore pattern while its content does not. For instance, ignorePaths: ["*", "!*/", "!**/*.txt"] results in ignore.ignores("subfolder") == true but ignore.ignores("subfolder/file.txt") == false. Before this fix, the GithubRepoLoader will miss subfolder/file.txt and any other files in subfolders that should be included. My solution here is to avoid the shouldIgnore test on directories and only check shouldIgnore on files. This means all directories will be traversed in a recursive load but only the correct files will be loaded.

I was unsure how to add a test case for this as an accessToken is required to do recursive collection of github repos.

Fixes #6214

Copy link

vercel bot commented Jul 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 7:57pm
langchainjs-docs ✅ Ready (Inspect) Visit Preview Jul 29, 2024 7:57pm

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. auto:improvement Medium size change to existing code to handle new use-cases labels Jul 29, 2024
@bracesproul bracesproul changed the title avoid shouldIgnore on folders for GithubRepoLoader community[patch]: avoid shouldIgnore on folders for GithubRepoLoader Jul 29, 2024
Copy link
Collaborator

@bracesproul bracesproul left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this! Would it be possible/easy to push up a test for this as well? If not no worries.

@dosubot dosubot bot added the lgtm PRs that are ready to be merged as-is label Jul 29, 2024
@DipFlip
Copy link
Contributor Author

DipFlip commented Jul 29, 2024

@bracesproul thanks for checking it. I'd be happy to add a test. What do I use as accessToken? Is there some variable I can access in libs/langchain-community/src/document_loaders/tests/github.int.test.ts to enable recursive github load?

@bracesproul
Copy link
Collaborator

@bracesproul thanks for checking it. I'd be happy to add a test. What do I use as accessToken? Is there some variable I can access in libs/langchain-community/src/document_loaders/tests/github.int.test.ts to enable recursive github load?

Only add a test if there's a way to mock the API request. If there's no way to do it without an API key then don't bother adding a test.

@DipFlip
Copy link
Contributor Author

DipFlip commented Jul 29, 2024

@bracesproul thanks for checking it. I'd be happy to add a test. What do I use as accessToken? Is there some variable I can access in libs/langchain-community/src/document_loaders/tests/github.int.test.ts to enable recursive github load?

Only add a test if there's a way to mock the API request. If there's no way to do it without an API key then don't bother adding a test.

Ok, I don't think it can be tested without an access token so this PR is ready to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:improvement Medium size change to existing code to handle new use-cases lgtm PRs that are ready to be merged as-is size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

webloader IgnorePaths unexpected
2 participants