Skip to content

Links: Fetch data#311

Merged
iLLiCiTiT merged 11 commits intodevelopfrom
enhancement/fetch-links-data
Mar 19, 2026
Merged

Links: Fetch data#311
iLLiCiTiT merged 11 commits intodevelopfrom
enhancement/fetch-links-data

Conversation

@iLLiCiTiT
Copy link
Member

Changelog Description

Fetch links data if server does support it.

Additional review information

Data can be fetched since AYON server 1.14.2 so it is quite new feature and can't be added all the time.

Testing notes:

  1. Links data are fetched with server 1.14.2 .

@iLLiCiTiT iLLiCiTiT added the type: enhancement New feature or request label Mar 13, 2026
@iLLiCiTiT iLLiCiTiT self-assigned this Mar 13, 2026
@BigRoy
Copy link
Contributor

BigRoy commented Mar 18, 2026

It seems that when running print(ayon_api.get_version_links("test", "fa03f536-1ec3-11f1-98b1-60cf848a5b16")) it always prints [] for me, even though it should be in the database?

image

@BigRoy
Copy link
Contributor

BigRoy commented Mar 18, 2026

For completeness sake - this returning an empty list is not new. It was also in older builds it seems, so is not due to this PR.

This does return something though:

query GetVersionLinks {
  project(name: "test") {
    versions(ids: "fa03f536-1ec3-11f1-98b1-60cf848a5b16"){
      edges {
        node {
          links {
            edges {
              entityId
              linkType
              data
            }
          }
        }
      }
    }
  }
}

Returning:

{
  "data": {
    "project": {
      "versions": {
        "edges": [
          {
            "node": {
              "links": {
                "edges": [
                  {
                    "entityId": "f9d4aa9e1ec311f1ae7160cf848a5b16",
                    "linkType": "generative",
                    "data": {}
                  },
                  {
                    "entityId": "fe3162a05b2711f099b83c0af39c4c02",
                    "linkType": "reference",
                    "data": {}
                  },
                  {
                    "entityId": "5c575e305cc411f090013c0af39c4c02",
                    "linkType": "reference",
                    "data": {}
                  },
                  {
                    "entityId": "f77bf84a1d9711f1942460cf848a5b16",
                    "linkType": "reference",
                    "data": {}
                  }
                ]
              }
            }
          }
        ]
      }
    }
  }
}

@BigRoy
Copy link
Contributor

BigRoy commented Mar 18, 2026

Ok, found it.

version_id = "fa03f536-1ec3-11f1-98b1-60cf848a5b16"
print(ayon_api.get_version_links("test", version_id, link_types=["reference"], link_direction="in"))
print(ayon_api.get_versions_links("test", [version_id], link_types=["reference"], link_direction="in"))

The latter does print the output, the first prints the empty list.
Why is it? Because apparently the - are stripped off of the id on the returned result.

defaultdict(<class 'list'>, {'fa03f5361ec311f198b160cf848a5b16': [{'linkType': 'reference', 'direction': 'in', 'id': 'fa8a7e681ec311f18c9592a342bf613b', 'description': 'reference link with input version and output version', 'entityId': 'fe3162a05b2711f099b83c0af39c4c02', 'name': None, 'author': 'bigroy', 'entityType': 'version', 'projectName': 'test'}, {'linkType': 'reference', 'direction': 'in', 'id': 'fa93a3d01ec311f18c9592a342bf613b', 'description': 'reference link with input version and output version', 'entityId': '5c575e305cc411f090013c0af39c4c02', 'name': None, 'author': 'bigroy', 'entityType': 'version', 'projectName': 'test'}, {'linkType': 'reference', 'direction': 'in', 'id': 'fa9b4df61ec311f18c9592a342bf613b', 'description': 'reference link with input version and output version', 'entityId': 'f77bf84a1d9711f1942460cf848a5b16', 'name': None, 'author': 'bigroy', 'entityType': 'version', 'projectName': 'test'}]})

As such, the value isn't in the dict and instead the default results [] is returned.

version_id = "fa03f5361ec311f198b160cf848a5b16"
print(ayon_api.get_version_links("test", version_id, link_types=["reference"], link_direction="in"))

And voila, this does print something.

version_id = "f9d4aa9e-1ec3-11f1-ae71-60cf848a5b16".replace("-", "")
print(ayon_api.get_version_links("test", version_id, link_direction="in"))
[{'author': 'bigroy',
  'data': {},
  'description': 'generative link with input version and output version',
  'direction': 'in',
  'entityId': 'fa03f5361ec311f198b160cf848a5b16',
  'entityType': 'version',
  'id': 'fa70d4861ec311f18c9592a342bf613b',
  'linkType': 'generative',
  'name': None,
  'projectName': 'test'},
 {'author': 'bigroy',
  'data': {'hero': True, 'hero_version_id': 'fe3162a05b2711f099b83c0af39c4c02'},
  'description': 'generative link with input version and output version',
  'direction': 'in',
  'entityId': '5c575e305cc411f090013c0af39c4c02',
  'entityType': 'version',
  'id': 'fa79b4e81ec311f18c9592a342bf613b',
  'linkType': 'generative',
  'name': None,
  'projectName': 'test'}]

Note that data does indeed now get included.

Copy link
Contributor

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

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

Works. There is the caveat that with certain api calls using ids with - in them does not return any data, like described here because it seems they are stripped on the returned id. Not sure if that should be handled more gracefully?

@iLLiCiTiT
Copy link
Member Author

Not sure where did you get version id with dashes?

@iLLiCiTiT iLLiCiTiT merged commit 30851bd into develop Mar 19, 2026
3 checks passed
@iLLiCiTiT iLLiCiTiT deleted the enhancement/fetch-links-data branch March 19, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants