Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal to allow custom Descriptors via hooks #768

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Ahuge
Copy link

@Ahuge Ahuge commented May 1, 2020

This PR is to allow toolkit developers to write custom IODescriptor classes without needing to take ownership over the entire tk-core repository.

We are no longer relying on a function in the __init__.py of tank.descriptor.io_descriptor to register our Descriptor types.
We have offloaded that work to the IODescriptorBase create method on it's first execution.

We have a class level initializer check that will call the external hook and fall back to the default types.

I have also added a sample use case for implementing a bitbucket_release IODescriptor example based off of the github_release IODescriptor

@Ahuge Ahuge changed the title [WIP] Proposal to allow custom Descriptors via hooks Proposal to allow custom Descriptors via hooks May 1, 2020
@Ahuge
Copy link
Author

Ahuge commented May 1, 2020

I don't think the test errors are me.. I see the PRs right before this have the same errors

@Ahuge
Copy link
Author

Ahuge commented May 22, 2020

Any chance I could get someone to look at this?

@pscadding @eshokrgozar

Would love to get thoughts on it...

Thanks

@jfboismenu
Copy link
Contributor

jfboismenu commented May 25, 2020

Hi @Ahuge ,

We've been interested in allowing people to add their own custom io descriptor types over the years, but we've never had a chance to prioritize it. While we understand the need to add new IODescriptor types, we're curious why you would need a custom Descriptor type. Could you elaborate on this concept?

With that being said, it's great that you've put so much effort in this submission, it's well documented, but we can't accept it at the moment.

There's the matter that it only works when using the ToolkitManager. Not every Toolkit workflow use the ToolkitManager. For example, many workflows involving creating a Toolkit instance using sgtk.sgtk_from_path and then start the engine manually through sgtk.platform.start_engine. The fact that the descriptor registries are only initialized when using the ToolkitManager will cause many problems. You can see this in the many tests that are now failing due to Unknown descriptor type for ...-like errors. For this reason, it seems this isn't a job for the ToolkitManager. If you want to run the tk-core unit tests, simply install tk-toolchain and run pytest at the root of the repository.

Also, I'd like to argue that custom descriptors should probably be available before bootstrapping, so it can be used in the descriptor field on a Pipeline Configuration entity in Shotgun. For example, might want your pipeline configuration to point to a specific bitbucket release.

We'd love to continue this with you or any other client (I know some have forked tk-core to have a tk-rez descriptor), so don't consider this as a refusal to see the feature be introduced at some point. Maybe you can start this in the community forum?

Let us know what you think!

JF

@Ahuge
Copy link
Author

Ahuge commented May 25, 2020

Hey @jfboismenu,

I appreciate the reply!
I will continue working on this one. Thanks for the tip about tk-toolkit I'll make sure I am doing that.

And in response to the Descriptor question, I think I was just adding it because I was in the area and someone someday might want descriptor customization maybe?
I can remove it from this PR if you'd prefer, because I personally don't need it. I just need the IODescriptor part.

Thanks
-Alex

@jfboismenu
Copy link
Contributor

jfboismenu commented May 25, 2020

Hi again!

Yeah, we would err on the side of caution and not allow custom Descriptor derived classes for now. Custom IODescriptors is what people seem to be asking for right now.

We want to be honest. We don't want to tell you not to work on your own implementation of this for your studio. You're obviously the best person to decide whether maintaining a fork of tk-core for your studio is best. However, given that we do not have currently the bandwidth to fully look at the impact on Toolkit of such a change, it's possible that where you end up on your own might be different than where we would end up if we ever implement this feature ourselves.

You may find it best for now to simply live with your fork of tk-core in the state it is in. I think starting the discussion with the community, seeing the appetite for it and the needs of our clients is the best first step. The last thing we want is to send you on a wild goose chase trying to think of every impact this feature can have on Toolkit.

If you haven't started a thread yet on the forum, let me know and I'll start one.

Also, may I ask, which problem are you trying to get around here specifically by having a custom descriptor?

JF

@Ahuge
Copy link
Author

Ahuge commented May 25, 2020

@Ahuge Ahuge force-pushed the ah/feature/custom-io-descriptor-hooks branch 6 times, most recently from adb5414 to 9985fa0 Compare May 26, 2020 06:28
Alex added 3 commits May 25, 2020 23:35
This error type my be thrown when registering custom descriptors
This is equivilent to the default tank.descriptor.io_descriptor init
method.
@Ahuge Ahuge force-pushed the ah/feature/custom-io-descriptor-hooks branch from 9985fa0 to 0280022 Compare May 26, 2020 07:49
Alex added 3 commits May 26, 2020 00:53
Both functions now pass in the baseclass to register against.
The hook has changed it's method from ``register_types`` to ``register_io_descriptors``.

The base class of this hook will run the same shotgun logic as before by calling the method in the __init__ of ``tank.descriptor.io_descriptor``.

``_register_io_descriptor_hook`` to call the RegisterDescriptors hook ``register_io_descriptors`` via the DescriptorManager method.
@Ahuge Ahuge force-pushed the ah/feature/custom-io-descriptor-hooks branch 2 times, most recently from 91a0c40 to fffc91f Compare May 26, 2020 07:57
@Ahuge
Copy link
Author

Ahuge commented May 26, 2020

Is this me?

Starting: Cloning UI automation tools
==============================================================================
Task         : Bash
Description  : Run a Bash script on macOS, Linux, or Windows
Version      : 3.163.2
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/bash
==============================================================================
Generating script.
Script contents:
git clone --depth 1 [email protected]:$UI_AUTOMATION_REPO ../ui_automation
========================== Starting Command Output ===========================
/bin/bash --noprofile --norc /home/vsts/work/_temp/faedb517-3acb-485e-a59a-7b6890fc91c0.sh
Cloning into '../ui_automation'...
Warning: Permanently added the RSA host key for IP address '140.82.118.3' to the list of known hosts.
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

@Ahuge
Copy link
Author

Ahuge commented May 26, 2020

Built docs

docs

@Ahuge
Copy link
Author

Ahuge commented May 26, 2020

Built docs

docs

Couple of typos there I need to fix

@Ahuge Ahuge force-pushed the ah/feature/custom-io-descriptor-hooks branch from fffc91f to 9af8ce0 Compare May 27, 2020 20:05
config_root = os.path.join(self.fixtures_root, "config")
sg = self.mockgun

d = sgtk.descriptor.create_descriptor(
Copy link

Choose a reason for hiding this comment

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

local variable 'd' is assigned to but never used

@Ahuge Ahuge force-pushed the ah/feature/custom-io-descriptor-hooks branch from 9af8ce0 to 1780349 Compare May 27, 2020 20:05
@jfboismenu
Copy link
Contributor

Re: Is this me?

No, we made a mistake in our build pipeline. This step should not be executed from fork, as forks do not have access to the build pipeline secrets.

@Ahuge
Copy link
Author

Ahuge commented Jun 1, 2020

Oh perfect good to hear haha!

That makes sense thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants