AcademySoftwareFoundation / OpenCue

A render management system you can deploy for visual effects and animation productions.
https://www.opencue.io
Apache License 2.0
832 stars 203 forks source link

Automate show archive process #1362

Open DiegoTavares opened 6 months ago

DiegoTavares commented 6 months ago

Feature request

Add a new methods to the show api wrapper to allow archiving a show that has been inactive for a while.

Example of the usage:

from opencue import api

shows = api.findShow("wam")
if shows:
  show = shows[0]
  show.archive()

Context

Archiving a show is useful because it enables jobs to be submitted to the archived show to be executed by allocations subscribed to the show it has been alias to. For example, if a facility has a show called ABC that has wrapped, but its content might still be useful for training purposes, a show calls TRN (training) could be created with small group of hosts assigned to it and ABC could be aliased to TRN which would make jobs submitted to ABC to be picked up by hosts assigned to TRN.

Mechanism

Shows can already be aliased on the database, the current process requires going to the database and adding an entry with the aliased show to the show_alias table and renaming the existing show on the show table to append .archived. Ideally this should be a hidden feature on the API.

The implementation involves adding a new api call to the proto layer, implementing the client call on pycue and the server logic on cuebot.

To help with the development of this feature, here's a database function that can be triggered to archive a show on demand.

CREATE OR REPLACE FUNCTION archive_show_to_trn(IN SHOW_STR_NAME VARCHAR)
RETURNS VOID AS $body$
BEGIN
    INSERT into show_alias (pk_show_alias, pk_show, str_name)
        SELECT s.pk_show, '00000000-0000-0000-0000-000000000221', s.str_name
            from show s
            where s.str_name = SHOW_STR_NAME;
    UPDATE show set str_name = CONCAT(SHOW_STR_NAME, '_archive') where str_name = SHOW_STR_NAME;
END;
$body$
LANGUAGE PLPGSQL;

-- 00000000-0000-0000-0000-000000000221 is the PK for the show to be used as the destination of the alias
DiegoTavares commented 6 months ago

FYI @n-jay this is a good first issue to get involved on pycue and cuebot while also touching the database

n-jay commented 6 months ago

Ack @DiegoTavares, thanks! Will check this out. Also, could I be assigned to this? I'll start working on it on the side and get in fully once the addon CI work is at a satisfactory level.

Will send any questions/doubts in a new mail thread.

n-jay commented 4 months ago

@DiegoTavares, I'm gradually shifting to work on this. To make sure if I've properly understood this;

The implementation involves adding a new api call to the proto layer, implementing the client call on pycue and the server logic on cuebot.

show_alias and show tables currently exist. Correct me if I'm wrong but I believe they are in V1_initial_schema.sql, yes? The new API should add a new entry to show_alias and concatenate the _archived suffix to the existing entry in the show table.

the flow is as follows: pycue (API) ▶️ proto layer (new CreateShowAlias rpc) ▶️ cuebot logic (writing data to the show_alias table and updating show table).

DiegoTavares commented 4 months ago

I think you got it all right. One thing that might need to be added is a property on cuebot indicating what show be used as a default as an alias for archive shows, and maybe the api function can take an optional argument to provide another show if needed.

from opencue import api

shows = api.findShow("wam")
if shows:
  show = shows[0]
  show.archive(alias_to="trn")
n-jay commented 4 months ago

One thing that might need to be added is a property on cuebot indicating what show be used as a default as an alias for archive shows

Noted @DiegoTavares. Will send my initial PR and clarify my doubts on it as I make progress.