-
-
Notifications
You must be signed in to change notification settings - Fork 340
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
Support added for a single file and directory #663
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR! I left some feedback for you to address. Let me know if you have further questions. 🤗
subdirs[:] = [ | ||
d for d in subdirs if not (d[0] == "." or d in EXCLUDE_DIRS) | ||
] | ||
filenames = [f for f in filenames if not f[0] == "."] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few issues with the implementation proposed by this branch:
-
We seek a list of file paths relative to the current directory. However, this branch only adds file names.
-
This branch updates
filenames
using the assignment operator=
instead of.append()
, meaning that the list of filenames is dropped with each iteration of thefor
loop. -
filenames
is also being used by thefor
block itself. This means that even if the previous issue is fixed, every iteration of thisfor
loop will still delete the value offilenames
set by the previous iteration. Take this as a simplified example:
>>> for i in range(5):
... print(i)
... i = 1
...
0
1
2
3
4
This implementation can be corrected and simplified greatly. Here are my suggestions.
-
The logic within the
for filename in filenames: ...
block on line 69 should be extracted to a separatesplit_file(path, splitter)
function. -
Revert the other changes, and simply add this block at the very top of this
split()
function definition:
if os.path.isfile(path):
return split_file(path, splitter)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked all this info by adding print()
statements in the definition of split()
to verify the value of filenames
. To test, I ran jupyter lab
from the root of this Git repo and called /learn docs
to learn all of the Jupyter AI documentation.
Can you do the same before I review this again? Thanks in advance!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dlqqq The code for the function split()
can be simplified to the following form of the original function:
I have tested this separately and it works for a single file or a directory.
Superseded by #712. |
Hello Team,
Issue number of the reported bug or feature request: #641
Changes
Support added to QA a single file. The code is capable to detect single file or directory and process accordingly.
Testing performed
The functionality has been tested on my system (MacOS).
Additional context
I have tested for single files, file inside a directory and directory only.