in03 / proxima

Transcode source media directly from DaVinci Resolve using multiple machines for encoding. Great for creating proxies quickly.
MIT License
53 stars 3 forks source link

Project change prompt runs on every link fail #212

Closed in03 closed 2 years ago

in03 commented 2 years ago

Philosophy

This problem actually revealed something in me that I need to work on as a dev. I like control. I think programmers generally do. They like to see the things they build do exactly as they will, and they have the patience to make it so. People not so! We shouldn't treat our users like sheep. Anyone capable of installing this and using Resolve is smarter than the below original code gives them credit for. So that's where I draw the line. I need to write better code when my programs interact with people. Writing code logic takes so much time, it's easy to forget about user experience with controls, commands, errors, feedback, etc. I'll try to do more research and study on UX and UI design. I'm sure that's something I can improve on.

Problem

Pasted image 20220818120132

Flawed logic

Since there was a failed link, Proxima assumes that user has changed projects and prompts them to change back and run the search again. This might be nice and pre-emptive, but the inteded desire was that it should only prompt when NONE of them link. There's my implementation's logic hole. If more than zero link, we can assume that we're still in the same project:

if queued - failed == 0:
    answer = input("All the proxies failed to link! If you've changed projects, would you like to change back and link again?")
    if answer.lower().startswith("y"):
        print("Okay open your project again now and press any key when done")
        # .... Okay you get the picture

Now sure that fixes the logic hole, but this whole thing is a dumb idea because it...

Makes an ass out of u and me

Again, assuming project change because of amount of linked files is an assumption and a bad one: This assumes "atomic" project structure on disk, i.e. a "project" folder matching the Resolve project name and proxy paths mirroring source structure. This means no proxies are shared and the same clip used between projects will be a duplicate on disk. If a user doesn't structure their media in projects, but instead has Resolve projects linking to all sorts of different clips then this assumption doesn't hold. That presumptuous statement would confuse anyone who hasn't changed projects. Essentially, it's too opinionated.

It's also a bad idea because it...

Micromanages the user

The questioning is weird. If they say "yes" for "I have changed projects and would like to link again. You better check they actually change projects first. Then that's another question and it's ambiguous and weird and overly interactive for something that could just fail with a nice message and they could run again to relink everything. No spoon feeding. This isn't a Windows98 install wizard.

And finally...

All that interactive logic is hard to maintain

Let's not try to do some fancy interactive thing here, there's just more chance for something to break. We don't want any unnecessary logic to maintain. We'll just tell the user what's wrong and the quickest way to fix it. No stress. No mess.

Solution

And of course I don't know why I didn't think of this in the first place... Just query the Resolve API and check to see if we're still in the same project:

We can add onto that a check to see if Resolve is even open anymore, as well as point the user to something to a comprehensive troubleshooting guide if all the project criteria is in place but none of the files linked. We can leave that ball in their court. They may know exactly why. Let's not step them through a wizard.

try:
    current_project = get_current_project_blah()
except ApiErrorOrWhatever:
    print("Can't communicate with Resolve. Maybe it's closed?\n"
          "Run `proxima queue` when you're ready to link your proxies later.")
    # press enter to continue then exit blah

if current_project != queued_project:
    print("Looks like you've changed projects. Proxies can't be linked to a closed project.\n"
         "Run `proxima queue` when you're ready to link your proxies later.")

if queued - failed == 0:
    print("All the proxies failed to link! Resolve might not like your proxy settings.\n" 
      "See [troubleshooting](link)")
in03 commented 2 years ago

Fixed by #220