Skip to content

fix: Premature link success message #220

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

Merged
merged 24 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
28f50b0
Create draft PR for #214
in03 Aug 29, 2022
1b9eea7
feat: Add debug log for ffprobe
in03 Aug 30, 2022
78612c5
refactor(link): Remove search and rerender prompts
in03 Aug 30, 2022
8eecd4a
refactor: Update version_constraint_key
in03 Aug 30, 2022
955280d
fix(tasks): Remove hardcoded timecode value
in03 Aug 31, 2022
6ade3c0
feat(exceptions): Added NoneLinkableError exception
in03 Aug 31, 2022
71d1a65
refactor(link): Refactored link_with_mpi as class
in03 Aug 31, 2022
4c2ce46
refactor(queue): Integrate new linking class
in03 Aug 31, 2022
44c3d17
Merge branch 'bugfix/issue-214-Premature-linking-success-message' of …
in03 Aug 31, 2022
5566f62
refactor: Update version_constraint_key
in03 Aug 31, 2022
ee40434
refactor(__init__.py): Shorter absolute imports instead of relative
in03 Aug 31, 2022
9f91a9e
refactor: Absolute imports across all modules
in03 Aug 31, 2022
a857a3b
refactor: Remove old link command
in03 Aug 31, 2022
5ec4474
refactor(handlers): tuples > lists for linkable_types
in03 Aug 31, 2022
3b39d1a
fix(link): Restore re-render prompt on link fail
in03 Aug 31, 2022
0aea3d7
refactor: tuples > list (missed one)
in03 Aug 31, 2022
0d104b0
fix: wrong syntax for private functions
in03 Aug 31, 2022
8299933
fix: Reference to old import
in03 Aug 31, 2022
340c932
fix: Incorrect cwd error
in03 Aug 31, 2022
b681af2
fix: Reference to old import
in03 Aug 31, 2022
dfffbda
refactor: Absolute imports across all modules
in03 Aug 31, 2022
487366d
refactor(queue): tuples > lists for unlinked_types
in03 Aug 31, 2022
9dc90d2
Merge branch 'bugfix/issue-214-Premature-linking-success-message' of …
in03 Aug 31, 2022
5d9ffec
refactor: Update version_constraint_key
in03 Aug 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions proxima/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
__version__ = "0.0.1"
from .app.utils import core
from .app import broker
from .app import checks
from .app import exceptions
from .queuer import resolve
from .queuer.link import ProxyLinker
from .queuer import handlers
2 changes: 1 addition & 1 deletion proxima/app/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from rich.live import Live
from cryptohash import sha1

from proxima.settings.manager import SettingsManager
from proxima.settings import SettingsManager


class RedisConnection:
Expand Down
11 changes: 4 additions & 7 deletions proxima/app/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
import time
from typing import Union

from rich import print
from proxima import core
from proxima.app.utils import pkg_info
from proxima.settings import SettingsManager
from proxima.worker import celery_app
from rich.prompt import Confirm
from yaspin import yaspin

from .utils import pkg_info

from ..app.utils import core
from ..settings.manager import SettingsManager
from ..worker.celery import app as celery_app

settings = SettingsManager()

core.install_rich_tracebacks()
Expand Down
49 changes: 12 additions & 37 deletions proxima/app/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from rich.console import Console
from rich.rule import Rule

from .utils import pkg_info
from proxima.app.utils import pkg_info

# Init classes
cli_app = typer.Typer()
Expand Down Expand Up @@ -72,8 +72,8 @@ def draw_banner():
def run_checks():
"""Run before CLI App load."""

from ..app import checks
from ..settings.manager import SettingsManager
from proxima import checks
from proxima.settings import SettingsManager

settings = SettingsManager()

Expand Down Expand Up @@ -103,13 +103,13 @@ def queue():
"""

# Init
from ..app import checks
from ..settings.manager import SettingsManager
from .utils.core import setup_rich_logging
from proxima import checks
from proxima.settings import SettingsManager
from proxima import core

settings = SettingsManager()

setup_rich_logging()
core.setup_rich_logging()
logger = logging.getLogger(__name__)
logger.setLevel(settings["app"]["loglevel"])
# End init
Expand All @@ -123,38 +123,11 @@ def queue():
)
print("\n")

from ..queuer import queue
from proxima.queuer import queue

queue.main()


@cli_app.command()
def link():
"""
Manually link proxies from directory to
source media in open DaVinci Resolve project
"""

# Init
from ..settings.manager import SettingsManager
from .utils.core import setup_rich_logging

settings = SettingsManager()

setup_rich_logging()
logger = logging.getLogger(__name__)
logger.setLevel(settings["app"]["loglevel"])
# End init

from ..queuer import link

print("\n")
console.rule(f"[green bold]Link proxies[/] :link:", align="left")
print("\n")

link.main()


@cli_app.command()
def work(
hide_banner: bool = hide_banner,
Expand All @@ -181,7 +154,7 @@ def work(

print("\n")

from ..worker import launch_workers
from proxima.worker import launch_workers

launch_workers.main(workers_to_launch)

Expand Down Expand Up @@ -239,7 +212,7 @@ def celery(
def config():
"""Open user settings configuration file for editing"""

from ..settings.manager import SettingsManager
from proxima.settings import SettingsManager

settings = SettingsManager()

Expand All @@ -249,6 +222,8 @@ def config():
)
print("\n")

# TODO: Cross platform alternative to this hack?
# labels: enhancement
webbrowser.open_new(settings.user_file)


Expand Down
132 changes: 132 additions & 0 deletions proxima/app/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
class ResolveUnsupportedPlatform(Exception):
"""
Exception raised when Resolve's API does not support the current system.

This will occur when using any OS other than Windows, MacOS or Linux.
"""

def __init__(self, message: str = "Platform is not 'Windows', 'MacOS' or 'Linux'"):
self.message = message
super().__init__(self.message)


class ResolveAPIConnectionError(Exception):
"""
Exception raised when Resolve API is unreachable.

This can occur when Resolve is not open or the API server has crashed.
"""

def __init__(
self,
message: str = "Resolve Python API is not accessible. Is DaVinci Resolve running?",
):
self.message = message
super().__init__(self.message)


class ResolveNoCurrentProjectError(Exception):
"""
Exception raised when the current project is unknown.

This can occur when Resolve is running but no project has been opened.
"""

def __init__(
self,
message: str = "Couldn't get the current project. Is a project open in Resolve?",
):
self.message = message
super().__init__(self.message)


class ResolveNoCurrentTimelineError(Exception):
"""
Exception raised when the current timeline is unknown.

This can occur when Resolve is running and a project is open
but no timeline has been opened.
"""

def __init__(
self,
message: str = "Couldn't get the current timeline. Is a timeline open in Resolve?",
):
self.message = message
super().__init__(self.message)


class ResolveNoMediaPoolError(Exception):
"""
Exception raised when the Media Pool object is not accessible.

This shouldn't occur under normal circumstances.
"""

def __init__(self, message: str = "Resolve's Media Pool is inacessible."):
self.message = message
super().__init__(self.message)


class ResolveLinkMismatchError(Exception):
"""
Exception raised when Resolve's `LinkProxyMedia` API method rejects a provided proxy.

The API method returns a bool with no additional error context.
Common reasons for a mismatch include incorrect proxy settings (framerate, timecode)
or a corrupt/unfinished proxy file.
"""

def __init__(self, proxy_file: str, message: str = ""):

self.proxy_file = proxy_file

if message != "":
self.message = message
else:
self.message = f"Couldn't link source media to proxy '{self.proxy_file}'\n"
f"The proxy file may be corrupt, incomplete or encoding settings may be incorrect (framerate, timecode, etc)"

super().__init__(self.message)


class ResolveLostMPIReferenceError(Exception):
"""
Exception raised when media pool items passed to Resolve's `LinkProxyMedia` no longer reference in memory objects.

This occurs when any amount of project switching occurs between queuing and linking.
MPI references exist per session and will be lost on project changes.
"""

def __init__(self, media_pool_item, message: str = ""):

self.media_pool_item = media_pool_item

if message != "":
self.message = message
else:
self.message = f"Lost reference to original media pool items, has the project been changed?\n"
f"Post-encode linking after a project change is not possible without re-iterating media pool items."

super().__init__(self.message)


class NoneLinkableError(Exception):
"""
Exception raised when no jobs passed to `ProxyLinker` are in the `linkable_types` list

This shouldn't occur under normal circumstances, but may occur if the `linkable_types`
list is changed in a way that no queued proxies will match the list.
"""

def __init__(self, message: str = ""):

if message != "":
self.message = message
else:
self.message = (
f"No jobs passed to ProxyLinker are in the 'linkable_types' list.\n"
)
"This shouldn't happen under normal circumstances. Probably the list has been misconfigured."

super().__init__(self.message)
22 changes: 13 additions & 9 deletions proxima/queuer/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import pathlib
import shutil
from typing import Union
from typing import Union, Tuple

from rich import print as pprint
from rich.prompt import Confirm, Prompt
Expand Down Expand Up @@ -174,7 +174,7 @@ def handle_orphaned_proxies(media_list: list) -> list:


def handle_already_linked(
media_list: list, unlinked_types: list = ["Offline", "None"]
media_list: list, unlinked_types: Tuple[str, ...] = ("Offline", "None")
) -> list:
"""Remove items from media-list that are already linked to a proxy.

Expand Down Expand Up @@ -205,7 +205,7 @@ def handle_already_linked(


def handle_existing_unlinked(
media_list: list, unlinked_types: list = ["Offline", "None"]
media_list: list, unlinked_types: Tuple[str, ...] = ("Offline", "None")
) -> list:

"""Prompts user to either link or re-render unlinked proxy media that exists in the expected location.
Expand Down Expand Up @@ -320,12 +320,16 @@ def get_newest_proxy_file(media, expected_proxy_path: str) -> Union[str, None]:
linkable_now.append(x)
media_list.remove(x)

remaining = link.link_proxies_with_mpi(
linkable_now,
linkable_types=["Offline", "None"],
prompt_rerender=True,
)
media_list.extend(remaining)
proxy_linker = link.ProxyLinker(linkable_now)
proxy_linker.link()

# Prompt to requeue if any failures
if proxy_linker.mismatch_fail:
if Confirm.ask(
f"[yellow]{len(proxy_linker.mismatch_fail)} files failed to link."
"They may be corrupt or incomplete. Re-render them?"
):
media_list.extend(proxy_linker.mismatch_fail)

else:

Expand Down
Loading