in03 / proxima

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

Fix status update #198

Closed github-actions[bot] closed 2 years ago

github-actions[bot] commented 2 years ago

Fix status update

It's only showing picked up status?

If I replace this with a print, it works fine.

https://github.com/in03/Resolve-Proxy-Encoder/blob/72e933ab181e1bcfadf3b8e29c8545a49d841588/resolve_proxy_encoder/app/broker.py#L172


            switch = {
                "SUCCESS": f"[bold green] :green_circle: {worker}[/] -> finished '{file_name}'",
                "FAILURE": f"[bold red] :red_circle: {worker}[/] -> [red]failed '{file_name}'",
                "STARTED": f"[bold cyan] :blue_circle: {worker}[/] -> picked up '{file_name}'",
            }

            self.status = switch[data["status"]]

            # TODO: Fix status update
            # It's only showing picked up status?
            # If I replace this with a print, it works fine.
            # labels: bug

            # Update spinner last status
            self.last_status.update(
                task_id=self.last_status_id,
                last_status=switch[data['status']],
            )

    def handle_task_progress(self, message):

        # If task is registered, track it
        data = json.loads(message["data"])
        if data["task_id"] in self.matched_task_ids:

            # Store all vals for future purposes maybe?
            self.progress_latest_data.update(
                {data["task_id"]: [data.get("completed"), data.get("total")]}
            )
            # Get up-to-date average
            progress_data = self.progress_latest_data[data["task_id"]]
            percentage = round(progress_data[0] / progress_data[1] * 100)     
            self.prog_percentages.update({data["task_id"]: percentage})
            active_task_average = round(sum(self.prog_percentages.values()) / len(self.prog_percentages))
            total_task_average = round(active_task_average / (len(self.callable_tasks) - self.completed_tasks))

            # Log debug
            self.logger.debug(f"[magenta]Current task percentage: {percentage}")
            self.logger.debug(f"[magenta]Active tasks average percentage: {active_task_average}")
            self.logger.debug(f"[magenta]Total tasks average percentage: {total_task_average}\n")

            # TODO: Better way to prevent progress going backward on task pickup?
            # Not sure why the task progress is going backwards.
            # It happens on new task pick up, which I thought we accounted for?
            # It doesn't seem to be off by much though.
            # labels: enhancement
            if total_task_average > self.last_task_average:

                # Update average progress bar
                self.average_progress.update(
                    task_id=self.average_id,
                    completed=total_task_average,
                )

            # Add new workers
            if data["worker_name"] not in self.active_workers:

97c4e5bf77e499d22f8994127cf7798df937ea1f

github-actions[bot] commented 2 years ago

Closed in 539f8711fb486b346a06f93fc284b950bbfaa1c1