-
Notifications
You must be signed in to change notification settings - Fork 6
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 FileOpener module #116
Conversation
for more information, see https://pre-commit.ci
Codecov Report
@@ Coverage Diff @@
## master #116 +/- ##
==========================================
- Coverage 63.07% 62.82% -0.26%
==========================================
Files 18 19 +1
Lines 669 702 +33
==========================================
+ Hits 422 441 +19
- Misses 247 261 +14
Continue to review full report at Codecov.
|
return "File not found." | ||
full_filename = job.fn(self.filename) | ||
cmd = f"{self.open_cmd} {full_filename}" | ||
os.system(cmd) |
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 might recommend using the default handler for a given file type? It depends a bit on exactly what you want (the equivalent of a double-click in Finder/Explorer vs. an arbitrary terminal command?) but this is one way to achieve that: https://stackoverflow.com/a/435669
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 will use the default handler for a given file type, at least on mac. I indeed do want the equivalent of a double click on in Finder/Explorer, and it looks like using the subprocess module is better than os.system()
.
from signac_dashboard.module import Module | ||
|
||
|
||
class FileOpener(Module): |
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.
We might be able to make an equivalent of the FileList module that opens instead of downloading the file. Or both, with buttons for either open/download action. Perhaps with a regex filter of filenames to display?
@tcmoore3 Instead of adding a module, we could change the This is the button icon I would use: What do you think about that idea? |
@tcmoore3 do you still have interest in this feature/PR? If so do you have time to complete this? Also, what are your thoughts on Bradley's suggestion? |
I love that idea. This would be really useful for hybrid remote/local work. |
@b-butler My interest has dropped quite a bit (although not to zero!). I don't really have the bandwidth to complete this at the moment, so I'm going to close this and reopen in the future if I come across a stronger need for it. |
Description, motivation, and context
This PR adds a module that enables to open files with the system file viewer as determined by the OS.
One issue I run into while exploring a project in the dashboard is when I see something interesting in the data displayed in the dashboard and want to look into that job in more detail by opening the trajectory in OVITO. When this happens, I have to go my terminal type
open workspace/<first few characters of job id><tab><tab><tab>/trajectory.gsd
, which can interrupt my workflow. When browsing through tens to hundreds of jobs, this time can add up to a signfiicant amount of time (not to mention the added mental energy barrier). This PR makes it possible to run this command directly from the dashboard at the click of a button.The current implementation takes two arguments: the "open command" and the filename. The open command can vary by operating system (on macOS, just using
open
works; I'm not sure what this should be on Windows or Linux). This implementation also currently just usesos.system
since I found it simple enough for my use case. Current limitations are:FileOpener
module can be registered (for the same reason as theNotes
module as documented in Only 1 Notes instance appears on dashboard #74)Types of Changes
1The change breaks (or has the potential to break) existing functionality.
Checklist:
If necessary: