Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
OpenPype v3 example queries for recently published versions and representation filepaths
from openpype.pipeline import legacy_io
import datetime
# This is what OpenPype v3 uses for the date it stores on versions (reference)
def get_formatted_current_time():
date = - datetime.timedelta(days=1)
# Print all latest versions
formatted_date = date.strftime("%Y%m%dT%H%M%SZ")
for version in legacy_io.find({"type": "version", "data.time": {"$gt": formatted_date}}):
Copy link

BigRoy commented Jun 10, 2022

Here's getting all representation paths since yesterday:

from openpype.pipeline import legacy_io, get_representation_path
import datetime

date = - datetime.timedelta(days=1)
formatted_date = date.strftime("%Y%m%dT%H%M%SZ")

version_ids = legacy_io.distinct("_id", {"type": "version", "data.time": {"$gt": formatted_date}})
representations = legacy_io.find({"type": "representation", "parent": {"$in": version_ids}})
for representation in representations:
    path = get_representation_path(representation)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment