Skip to content

Collect Input Versions: Convert hero version links to their real version equivalents - #1741

Merged
iLLiCiTiT merged 21 commits into
ynput:developfrom
BigRoy:1634-yn-0359-collect-input-link-versions-from-hero-to-real-version
Mar 18, 2026
Merged

iLLiCiTiT merged 21 commits into
ynput:developfrom
BigRoy:1634-yn-0359-collect-input-link-versions-from-hero-to-real-version

Conversation

@BigRoy

@BigRoy BigRoy commented Mar 9, 2026 •

Copy link
Copy Markdown
Member

Changelog Description

Collect Input Versions: Convert hero version links to their real version equivalents

Additional info

Fix #1634

Requires latest ayon-python-api so that public facing create_links supports the data argument, see: ynput/ayon-python-api#308

Hero versions are now created as links to the real version entity ids. It stores metadata on the link that it was originally a hero version together with the hero version id.

{
  "data": {
    "hero": true,
    "hero_version_id": "fe3162a05b2711f099b83c0af39c4c02"
  },
  "entityId": "5c575e305cc411f090013c0af39c4c02",
  "linkType": "generative"
}

Regular versions would still be collected without data:

{
  "data": {},
  "entityId": "7251106f18e311f197b060cf848a5b16",
  "linkType": "reference"
}

Testing notes:

  1. Publishing should collect input links
  2. Loaded hero versions should be collected now with their 'real version ids'
  3. These hero version -> real version id links should now come with metadata pointing to the hero version.

You can validate the metadata via e.g. a GraphQL in the GraphQL explorer. Here's one:

query GetProjectLinksData {
  project(name: "test") {
    folders(paths: ["/apps/maya"]) {
      edges {
        node {
          path
          products {
            edges {
              node {
                name
                versions(latestOnly: true, hasLinks: IN) {
                  edges {
                    node {
                      links {
                        edges {
                          entityId
                          linkType
                          data
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

This would list all products' latest versions (only those with links) under folder /apps/maya in test project. That should make for a relatively limited view that shows relevant links.

You'll need server 1.14.2 or higher to be able to query it - due to needing this PR: ynput/ayon-backend#867

@BigRoy
BigRoy marked this pull request as draft March 9, 2026 23:31
@BigRoy BigRoy self-assigned this Mar 9, 2026
@ynbot ynbot added the size/S label Mar 9, 2026
@BigRoy BigRoy added type: enhancement Improvement of existing functionality or minor addition sponsored This is directly sponsored by a client or community member and removed size/S labels Mar 9, 2026
@BigRoy
BigRoy requested a review from iLLiCiTiT March 9, 2026 23:32
@BigRoy

BigRoy commented Mar 10, 2026 •

Copy link
Copy Markdown
Member Author
  • We'll likely also need to remap loadedVersions data:
    # QUESTION should we add same representation id when loaded multiple
    # times?
    loaded_versions = []
    for con in containers:
    repre_id = con["representation"]
    repre_entity = repre_entities_by_id.get(repre_id)
    if repre_entity is None:
    self.log.warning((
    "Skipping container,"
    " did not find representation document. {}"
    ).format(str(con)))
    continue
    # NOTE:
    # may have more than one representation that are same version
    version = {
    "container_name": con["name"],
    "representation_id": repre_entity["id"],
    "version_id": repre_entity["versionId"],
    }
    loaded_versions.append(version)
    self.log.debug(f"Collected {len(loaded_versions)} loaded versions.")
    context.data["loadedVersions"] = loaded_versions

Comment thread client/ayon_core/plugins/publish/collect_input_representations_to_versions.py Outdated
Comment thread client/ayon_core/plugins/publish/integrate_inputlinks.py Outdated
Comment thread client/ayon_core/plugins/publish/integrate_inputlinks.py Outdated
Comment thread client/ayon_core/plugins/publish/integrate_inputlinks.py Outdated
Comment thread client/ayon_core/plugins/publish/integrate_inputlinks.py Outdated
Comment thread client/ayon_core/plugins/publish/collect_input_representations_to_versions.py Outdated
Comment thread client/ayon_core/plugins/publish/collect_input_representations_to_versions.py Outdated
Comment thread client/ayon_core/plugins/publish/collect_input_representations_to_versions.py Outdated
Comment thread client/ayon_core/plugins/publish/integrate_inputlinks.py
@BigRoy
BigRoy marked this pull request as ready for review March 11, 2026 21:38
@antirotor

Copy link
Copy Markdown
Member

not sure what's wrong, but it doesn't add the data. I'll check directly in database as I am not sure if I am looking at the correct version via GraphQL

@BigRoy

BigRoy commented Mar 12, 2026 •

Copy link
Copy Markdown
Member Author

not sure what's wrong, but it doesn't add the data. I'll check directly in database as I am not sure if I am looking at the correct version via GraphQL

The data key for edges is only present in a recent server release, you'll need 1.14.2 or higher. Otherwise you couldn't really query for it :P

If you remain stuck; share a publish report please :)

@antirotor

antirotor commented Mar 12, 2026 •

Copy link
Copy Markdown
Member

I have 1.14.3 and latest ayon-python-api

publish-report-260312-15-29.json

I've added some debug logs to see the links being created but they are missing data:

DEBUG: added link: LinkPayload(input_id='39c0552e1e1f11f191cb04e8b9404c68', output_id='399001ca1e1f11f1b7d604e8b9404c68', data={})
DEBUG: added link: LinkPayload(input_id='42e768770e0f11ef9ad404e8b9404c68', output_id='39c0552e1e1f11f191cb04e8b9404c68', data={})

EDIT: I am also checking this directly in database table links, data field is empty.

@BigRoy

BigRoy commented Mar 12, 2026

Copy link
Copy Markdown
Member Author

I have 1.14.3 and latest ayon-python-api

publish-report-260312-15-29.json

I've added some debug logs to see the links being created but they are missing data:

DEBUG: added link: LinkPayload(input_id='39c0552e1e1f11f191cb04e8b9404c68', output_id='399001ca1e1f11f1b7d604e8b9404c68', data={})
DEBUG: added link: LinkPayload(input_id='42e768770e0f11ef9ad404e8b9404c68', output_id='39c0552e1e1f11f191cb04e8b9404c68', data={})

EDIT: I am also checking this directly in database table links, data field is empty.

Are these hero versions that you have loaded as inputs in your scene?

@iLLiCiTiT

iLLiCiTiT commented Mar 12, 2026 •

Copy link
Copy Markdown
Member

Looks good but needs testing. Can you create issue in ayon_api to add data field for links (if is not created yet)?

@antirotor

antirotor commented Mar 12, 2026 •

Copy link
Copy Markdown
Member

Are these hero versions that you have loaded as inputs in your scene?

Yes, there is nothing else than hero version loaded, just to make sure. It is a layout with hero version inside.

image

…cause it returns a generator, so the second use yielded nothing. So store them in `list` to fix

+ Add type hints to avoid issues
@BigRoy

BigRoy commented Mar 13, 2026

Copy link
Copy Markdown
Member Author

Thanks, reproduced - I seemed to have made a bug on my last cleanup. Essentially I iterated over the result of get_representations twice, but because it returns a Generator (iterator) it was exhausted already on the first loop. Now stored it in a list and that fixed it.

Also added some type hints to hopefully capture this quicker next time around.

@LiborBatek @antirotor, sorry. Please try again.

@antirotor antirotor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm it works now - case of simple layout with loaded hero version of referenced model from Maya. Confirmed using SQL client.

@BigRoy

BigRoy commented Mar 16, 2026

Copy link
Copy Markdown
Member Author

@iLLiCiTiT please review if you're happy with the code and merge if all ok.

Comment thread client/ayon_core/pipeline/publish/input_versions.py Outdated
Comment thread client/ayon_core/pipeline/publish/input_versions.py
@BigRoy
BigRoy requested a review from iLLiCiTiT March 17, 2026 22:34
@iLLiCiTiT
iLLiCiTiT merged commit ce65e2c into ynput:develop Mar 18, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sponsored This is directly sponsored by a client or community member type: enhancement Improvement of existing functionality or minor addition

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YN-0359: Collect input link versions from hero to real version

4 participants