-
Notifications
You must be signed in to change notification settings - Fork 76
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
Show path to file #2896
Show path to file #2896
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2896 +/- ##
=======================================
Coverage 88.79% 88.80%
=======================================
Files 111 111
Lines 17223 17234 +11
=======================================
+ Hits 15293 15304 +11
Misses 1930 1930 ☔ View full report in Codecov by Sentry. |
Would it be possible to have standalone point at the local folder? I remember @pllim has done something to this effect in the past. As it is now, it points to |
I think the immediate improvement is to just display what is currently being adopted so that it is clear where they are going and then we can improve the behavior (or allow choosing the directory) either as a follow-up or when using solara. EDIT: unless something is super-easy now, of course! We probably do want this to be smart enough to handle when the user passes an absolute path (or even |
I thought I commented about the standalone workaround but maybe it was a different PR. jdaviz/jdaviz/configs/default/plugins/export/export.py Lines 346 to 350 in ec80391
|
The ticket was made pre-Export plugin with the main objective being to display the location where file(s) are supposed to be stored. There are 2 follow up tickets in the backlog: one for address the bug relating to where the file(s) actually get stored (the UI and API have variable behavior), and a ticket to enable the user to select their desired directory with which the file(s) would be stored (defaulting to the Jupyter cwd). If this programmatic methodology works for reviewers, I can continue to build these improvements within this PR! |
Showing the path is done, but the behavior is still not ideal. I propose, in order of priority:
For later: make the path editable. |
2f7347d
to
97bb2e6
Compare
Updated behavior to basically handle relative paths: Screen.Recording.2024-05-30.at.3.09.37.PM.movIn this, the filename is a part of the filepath, I can remove it if that is preferred. |
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'm confused – even though there's a "file path export location", when I click export, my file goes to ~/Downloads/
. I see there's discussion about doing something different in follow-ups, but this makes the appearance of a bug.
e71970e
to
3e8b44c
Compare
An additional ticket is in this sprint that shall address the issue of the file path location in standalone pointing to the current working directory (or the directory the user selects in the filename section). I do have a mock solution, but have been unable to test it in an editable environment of standalone. I will bring this up to troubleshoot in the next tagup so we can get it tested and in ASAP. (When I get this troubleshooted I will also look into loading images into the viewer too). Regarding the Overwrite issue, I believe that this is the intended behavior. My assumption is that there was an existing file with the same name |
I would expect to get the warning when I click Export, not when I first open the plugin, but I guess this is up for debate :) Thank you for reminding me about the other ticket. I hope you manage to troubleshoot the standalone editable environment issue soon. |
Sorry, I misread the part about Exporting when the plugin was first opened, I thought it had to do with no receiving the overwrite warning in general. I am all for making sure when the user reopens Export with a file previously downloaded in their directory, to initially show the standard UI and not have the overwrite warning prompted to them until the they chose to export that exact filename/file path |
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.
# Update the UI Filepath if relative or absolute paths are provided | ||
# by user via self.filename_value | ||
if '~' in self.filename_value and '/' in self.filename_value: | ||
expanded_path = os.path.expanduser(self.filename_value) | ||
abs_path = Path(expanded_path).resolve() | ||
self.default_filepath = str(abs_path) | ||
elif '/' in self.filename_value and \ | ||
('.' in self.filename_value or '..' in self.filename_value): | ||
abs_path = Path(self.filename_value).resolve() | ||
self.default_filepath = str(abs_path) | ||
elif '/' in self.filename_value: | ||
self.default_filepath = str(self.filename_value) |
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.
The file path separator /
is specific to unix machines. I don't expect this to work as expected on Windows. Is there any reason not to resolve every file path with the same Path
methods?
export_plugin.filename_value = '/img.png' | ||
assert os.path.abspath(export_plugin.default_filepath) == os.path.abspath(export_plugin.filename_value) # noqa: E501 | ||
|
||
export_plugin.filename_value = '~/img.png' | ||
expected_path = os.path.normpath(os.path.expanduser('~/img.png')) | ||
|
||
assert export_plugin.default_filepath == expected_path | ||
|
||
export_plugin.filename_value = '../img.png' | ||
expected_path = os.path.abspath('../img.png') | ||
|
||
assert export_plugin.default_filepath == expected_path | ||
|
||
export_plugin.filename_value = './img.png' | ||
expected_path = os.path.abspath('./img.png') |
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.
You might want to create these filenames with OS independent methods for building paths like Path('.') / 'image.png'
.
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'm all for these changes, thank you for comment (and the one above), both will be implemented shortly!
This is unexpected, I passed the same input and got the expected results (the correct filename, in the expected directory). I have seen the behavior your screenshot displays before, I'm unsure why we're seeing different results from me. @camipacifici whenever you have the time, do you mind testing this and see whether the file name gets interpreted as a string or a Path |
905b82e
to
c3630b9
Compare
@camipacifici Thank you for the extensive testing! I went through and recreated each of the issues that exist. I will start making tickets for each of them now. Regarding the last issue in standalone where the path reverts to /private/, I will double check today with the devs, but I believe the default is that there is always a selection made in the UI for Export plugin. The moment another selection is made, the standalone file path will then update to the cwd again. Ultimately, I believe this issue comes from the underlying bug(s) with the histogram, and will be resolved if we ensure the histogram exists even if the tray has yet to be opened for Plot Options, (or a less ideal temporary solution is disable the histogram export and disable a message to the user the must open Plot Options tray to be able to export the histogram). UPDATE: Tickets are now in the backlog |
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.
This issue may not be related to this PR, but here's a workflow that confused me. I open data in Imviz, open Export, try to export the plot options histogram. The file path defaults disappear, and no file is saved:
imviz-export-no-hist.mov
If you do the same workflow, but open plot options first before trying to export the histogram, it works fine. So I expect this is just a problem of trying to export a figure that hasn't been rendered. Should we remove export options for plugin figures that aren't yet rendered?
See #2934 (the disappearing selection is not yet fixed, but will be there soon). |
@bmorris3 this is actually what Kyle's PR is addressing. The PR handles the case where plot options hasn't been opened but the user tries to download the histogram. The other bug that is somewhat associated and will likely be in Kyle's PR is when you do export the histogram, the filename is cleared and no selection is made (has to do with the list of choices being built from scratch every time you export, when we actually want the current selection to be maintained): #2934 |
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.
In light of the fact that my only concerns have pending fixes in other PRs, this looks good 👌🏻
where do we want this milestoned? #2934 is milestoned for the next bugfix release. This should maybe either go there as well or in 3.11 (in case that ends up existing)? |
I found one more thing. Sorry for not catching it before.
|
I approve this for its scope. Please file another bug ticket for the markers behavior. |
…th shows cwd and not temp path
…or building paths
c3630b9
to
b221862
Compare
* show default filepath in Export plugin * update filepath if ., .., and/or / provided by user in filename * add ~ relative path, revert to PosixPath instead of string, UI/API export to filepath * add some test coverage * update test, reduce transparency of overwrite overlay as temporary fix * add / testing * address 3.10 test failures * address 3.10 test failures * ensure overwrite only occurs after export button click, standalone path shows cwd and not temp path * update paths to use os/Path and tests to use OS independent methods for building paths * update change log milestone
Description
This pull request is to address displaying the default file path in the Export plugin UI. The default path shall update if the user inputs a relative or absolute path into the filename input field in the UI.
It also re-enables exporting for them the API. If a user provides a path via in the API, the file shall be exported there.
In the UI, the default filepath will be used (cwd), or, if a user provides a path, it will export to that location instead of exporting only to the users Downloads directory.
Follow up tickets are needed to address:
Change log entry
CHANGES.rst
? If you want to avoid merge conflicts,list the proposed change log here for review and add to
CHANGES.rst
before merge. If no, maintainershould add a
no-changelog-entry-needed
label.Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
trivial
label.