Skip to content

Instantly share code, notes, and snippets.

Embed
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():
return datetime.datetime.now().strftime(
"%Y%m%dT%H%M%SZ"
)
"""
date = datetime.datetime.now() - 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}}):
print(version)
@BigRoy
Copy link
Author

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.datetime.now() - 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)
    print(path)

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