-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Distance File: Don't accept dropped .xlsx files #6601
base: master
Are you sure you want to change the base?
Conversation
44ac0ef
to
7b324f9
Compare
@@ -158,7 +160,12 @@ def parametersFromFile(self, path): | |||
return {"recent_paths": stored_recent_paths_prepend(self.WIDGET, r)} | |||
|
|||
def canDropFile(self, path: str) -> bool: | |||
return os.path.splitext(path)[1].lower() in (".dst", ".xlsx") | |||
try: |
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 could keep the old condition (only .dst) for better performance.
@@ -158,7 +160,12 @@ def parametersFromFile(self, path): | |||
return {"recent_paths": stored_recent_paths_prepend(self.WIDGET, r)} | |||
|
|||
def canDropFile(self, path: str) -> bool: | |||
return os.path.splitext(path)[1].lower() in (".dst", ".xlsx") | |||
try: | |||
distances = DistMatrix.from_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.
This may take too long for big files.
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.
What was the file dimension again? Can you tell me which file it was - or send it? I tried 600x1000 and takes a few seconds.
What I discovered was that, unfortunately, most time is spent in opening the Excel file. Hence, the File widget will take more or less the same time as well.
Of course, with this PR, the file is read twice and we must prevent this. I'm considering decorating functions that open excel files with a lru cache of size 1 that would remember the last read excel workbook - of course checking not only the file name but also the timestamp. In this way - and given that opening the file takes majority of time - the time spent in owdistancefile would be saved in owfile because it would reuse the workbook object.
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.
It was 1000x1000 .xlsx.
7b324f9
to
69a7d1b
Compare
Note: taking a file and dragging it around the canvas triggers an incessant, continuous stream of calls to |
@ales-erjavec, can we assume that Could we avoid incessant calling of |
canHandleDrop should not do anything computationally expensive. Only check filename, possibly read a limited amount of the file (e.g. magic header byte[s])... |
Issue
When dropping an .xlsx file onto canvas, the user has to choose between Distance File and File, which is confusing (because these are widget names). The user almost always wants to load an .xlsx with File.
Description of changes
Distance File's functionality now no longer accepts .xlsx files.
Includes