ynput / ayon-core

Apache License 2.0
18 stars 30 forks source link

Pass status when integrating version #615

Closed fabiaserra closed 3 weeks ago

fabiaserra commented 1 month ago

Changelog Description

This passes the status and author(now resolved at https://github.com/ynput/ayon-core/commit/43787fd9c39f16bc8bf75d401b038a5a2fb56988) args to the creation of new version on integrate. Without passing author when integrating in Deadline it was defaulting to the service user

I also changed the collect_current_ayon_user plugin to this, although looking back now I'm not sure if that was necessary or it was just a matter of exposing the author.

        user = os.getenv("AYON_USERNAME")
        if not user:
            user = get_ayon_username()

Additional Information

Needless to say that currently the instance.data["status"] isn't being set by any of the collect plugins in AYON but it would be as simple as adding that in order for this to take any effect. In my situation, I'm setting that over the integrate_shotgrid_version of the ayon-shotgrid as there's some other data that I need from the SG integration to also add to the AYON version entity. This is the code that I'm running in my ayon-shotgrid:integrate_shotgrid_version:

        # Update AYON version entity with updated data
        update_data = {
            "attrib": {
                "shotgridId": str(version_id),
                "shotgridType": "Version"
            },
        }

        # We need to map the SG status short name to the long name as AYON
        # expects that longer name
        project_name = get_current_project_name()
        project_statuses = ayon_api.get_project(project_name)["statuses"]
        for proj_status in project_statuses:
            if proj_status["shortName"] == sg_status:
                update_data["status"] = proj_status["name"]
                break

        op_session = OperationsSession()
        version_entity = instance.data["versionEntity"]
        op_session.update_entity(
            instance.context.data["projectName"],
            "version",
            version_entity["id"],
            update_data
        )
        op_session.commit()
        self.log.info("Updated AYON version with %s", update_data)

Testing notes:

  1. Publish in Deadline
  2. Check the author
iLLiCiTiT commented 1 month ago

I think we should rather use ayon api functionality to behave as other user during farm publishing, rather than changing coller user functionality.

https://github.com/ynput/ayon-core/commit/43787fd9c39f16bc8bf75d401b038a5a2fb56988 (available in branch )