Skip to main content

No dependencies

The package is standard library only. Drop the renderflow folder onto sys.path and import renderflow works in any Python, including a DCC’s own bundled interpreter, with nothing to install:
The wheel declares Python 3.10 or newer. The plugin runtime a render node imports is a different file in the same package and is 3.8 syntax, because a node resolves whatever interpreter it finds. If you are writing a step that runs on the farm, that is the one you are writing against.

Connecting

Each argument falls back to the environment and then to this machine: No credential is a real configuration, not a missing one. A caller on the machine running RenderFlow has already proved where it is, so a submitter inside an artist’s application needs no key. A key is what a call from anywhere else needs, and Authentication covers both. The address may be given with or without /api/v1. timeout is per request and defaults to 60 seconds. Farm is a context manager, so with rf.connect() as farm: closes it. TLS is verified against the machine’s own trust store. A server presenting a certificate from a studio certificate authority needs that authority installed on the machine doing the calling, the same as any other client on your network would.

Finding the operation you want

Nothing in this package is written per operation. The methods are the operations of the API document shipped inside it, bound on first use, which is why the client is explorable rather than something you read a reference for:
Names are the document’s operation ids in snake case, so one operation reads the same here: Positional arguments are the path parameters, in the document’s order. Everything else is named: a query parameter by its own name, a request body as body=. A parameter named like a Python keyword takes a trailing underscore, so from is written from_.

Reading an answer

Answers read with dot access and hand back the payload with to_dict(). Requests are plain dicts. An operation the service does not answer as JSON comes back as bytes, which is what you want for the one that is not: a task preview is a rendered frame, and a frame decoded as text is mojibake.
The exports work the same way. A CSV export comes back as bytes, and an NDJSON export, which is one JSON object per line, comes back as text:

Typed, with nothing installed

Every request and response schema has a name in renderflow.models, and your editor reads them from a stub file that the interpreter never loads. So autocomplete and mypy work, and the package still has no dependencies. At runtime a model is a dict, because the wire is JSON.

Submitting

That is a recipe: the flat per-application form, which the service expands into a step. type, file and host are required on every one of them, and there is one per job type. wait=True blocks until the job is built and answers 201; without it the call answers 202 with a job still being prepared, which is what you want inside an application you are not going to hold open.
A job with several steps is the same call with a steps list instead of the flat fields, and each step’s configuration is its props. Build the chain once in the submitter, read it back with farm.jobs.get_job(job_id), and send that list with your own values. Guessing at props from the schema alone is the hard way.

Using the RenderFlow submitter

You do not have to build a submitter of your own. Send the same recipe to open_submitter and RenderFlow opens its own submitter on this machine, with the job and the scene’s properties already filled in from what you sent. This is how the Submit to RenderFlow buttons in every supported application work.
The artist gets the full submitter, can change anything in it, and presses Submit to create the job. The RenderFlow app has to be running on this machine: when it is not, opened is false and reason says why. When several people are signed in to one machine, pass user="<name>" to open it on that person’s desktop. When the scene lists several render items, the submitter opens one job per item by default; pass batch=False to open a single job.

Waiting for a job

That resolves when the job reaches the required state or times out:
None means the job is no longer there: archiving and deleting look the same from outside, and neither is going to finish. A stop is not an end, because suspending a job is resumable, so pass statuses=["completed", "failed", "suspended"] when a stop is an answer for your caller. A timeout raises TimeoutError rather than handing back a job that has not finished. This polls rather than watching, so a wait needs no socket, no thread and no reconnect behaviour, and it still works where a proxy passes HTTP and refuses an upgrade. The interval is the cost: two seconds is right for a test render and wrong for an overnight one. When the moment a job finishes is what matters, watch it instead.

Which machines can run a step

When a step is not starting, its wait says whether it is waiting for a render license seat or for a machine that meets its requirements. To see which machines could take it and why the rest cannot, ask for its candidates:
The REST API page explains the verdicts and the rest of the report.

Live updates

One socket, shared by every subscription, opened on the first and closed with the last. No polling, and it is the same endpoint the operator UI watches.
on is on every group whose collection the farm pushes: jobs, tasks, nodes, pools, users, user_groups, errors, schedule and licenses. The second argument narrows it, id on any of them, step_id on tasks, node_id on the node joins, and a list is one subscription over several ids rather than several subscriptions. An insert carries the whole row on event.doc. An update carries event.patch, keyed by dotted path, so a job’s progress arrives as event.patch["progress.percent"] and a step’s task counts as event.patch["steps.0.task_info.done"]. A delete carries the id and nothing else.
resync arrives in the same stream as the changes, and it is not one. It means events were missed and this collection has to be read again. The socket has no replay, so a reconnect, a dropped frame or a client the farm outran all mean the same thing. It comes through your handler rather than a second callback precisely so there is nothing to forget to pass.
The socket runs on a daemon thread, so a script that forgot to unsubscribe still exits. farm.live.close() drops everything, and farm.live.on_error reports a refused credential; it writes to stderr until you replace it.

Errors

ApiError carries status, body, and the service’s own sentence as its message, so str(error) is what to put in front of a person. A DCC submitter does exactly that.

A shelf button

A Maya shelf button that submits the open scene and tells the artist what happened, running in Maya’s own Python:
Forward slashes, because a path that crosses machines travels that way. And the error goes in a dialog as the sentence the service wrote, which is why that sentence is written for a person.

A nightly script

Requeue everything that failed because a license was not free, which is the one failure that is worth retrying without a human looking at it:
A negative offset counts back from the end of the log, so that reads the tail rather than paging through a whole render.