Skip to content

Conversation

@kuldeepgudekar
Copy link

@kuldeepgudekar kuldeepgudekar commented Dec 12, 2025

DO NOT MERGE THIS PR, this is only to do code review for now

Copy link
Contributor

@barbara-darkshot barbara-darkshot left a comment

Choose a reason for hiding this comment

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

hey @kuldeepgudekar ,
I left some comments so you can start to make the code more readable
I'll look more into the logic once the code will be cleaned :)
thanks!

info.yml Outdated
#
project_visible_pipeline_steps:
type: bool
description: If True, only pipeline Steps visible for the current Project and entity type are listed.
Copy link
Contributor

Choose a reason for hiding this comment

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

could you improve the description? it's not clear what you are talking about here
pipeline steps can be used at other locations in the code, would be nice to describe it more in details (what menu is affected, what's the default behavior, ...)

Copy link
Author

Choose a reason for hiding this comment

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

I have updated the documentation for the flag.

return

bundle = sgtk.platform.current_bundle()
shotgun_api = bundle.shotgun
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need to create a new variable to store the shotgun_api object, you can directly call it from bundle.shotgun

bundle = sgtk.platform.current_bundle()
shotgun_api = bundle.shotgun
# Use the engine's Shotgun instance for schema calls
engine_shotgun_api = sgtk.platform.current_engine().shotgun
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, why you need the shotgun instance of the engine while you have the one from the current bundle?

Copy link
Author

Choose a reason for hiding this comment

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

In sgtk.platform.current_bundle() schema_field_read method not available, that's why I need to use sgtk.platform.current_engine()shotgun instance, maybe because shotgun_schema_read method is part of the lower-level implementation?

limit_steps_to_project_visible = bundle.get_setting(
"project_visible_pipeline_steps", False
)
current_project = getattr(bundle.context, "project", None)
Copy link
Contributor

Choose a reason for hiding this comment

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

in this case, the context will always have a project so you don't need to store it in a variable, you can just call bundle.context.project where you need to access the context project

:returns: List of Step dictionaries with at least 'id', 'code',
'entity_type' and optionally 'color'.
"""
StepListWidget._cache_step_list()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm probably being picky but I really don't like non-UI code calling into UI code even if _cache_step_list is a class method on the UI class. I wonder if the step cache should be a class of it's own that both the StepListWidget and get_steps_for_entity_type make use of?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, sure. I have updated the implementation, let me know how that looks.

Copy link
Contributor

@pscadding pscadding left a comment

Choose a reason for hiding this comment

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

@barbara-darkshot asked me to give this a review, I just had a couple of small comments.

return list(StepCache.get_step_map().get(entity_type, []))


class StepCache(object):
Copy link
Contributor

@pscadding pscadding Dec 17, 2025

Choose a reason for hiding this comment

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

@barbara-darkshot It feels to me like any logic around step caching should live in the shotgun utils?
https://github.com/shotgunsoftware/tk-framework-shotgunutils/blob/master/python/shotgun_globals/cached_schema.py

@pscadding I have migrated caching code to the cached_schema.py. Ref : shotgunsoftware/tk-framework-shotgunutils#173

Copy link
Contributor

@barbara-darkshot barbara-darkshot Dec 17, 2025

Choose a reason for hiding this comment

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

oh, that's a good catch! I was not aware of this class!
it's a great idea, especially because this class already has a method to ensure if a field is visible so we could use that => https://github.com/shotgunsoftware/tk-framework-shotgunutils/blob/master/python/shotgun_globals/cached_schema.py#L907C9-L907C25
maybe we could add a get_visible_steps_for_project method in this class as well?

@barbara-darkshot , reused the field is visible functionality for the class and added respective methods as well. Ref : shotgunsoftware/tk-framework-shotgunutils#173

:returns: List of Step dictionaries with at least 'id', 'code',
'entity_type' and optionally 'color'.
"""
StepCache.ensure_loaded()
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like its rebuilding the step cache everytime this function is called, can we instead reuse it if it is already built in the session?
It looks like calling get_step_map on its own would do that?

Copy link
Author

Choose a reason for hiding this comment

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

Updated the code.

super().__init__()
self._list_widget = list_widget
self._cache_step_list()
StepCache.ensure_loaded()
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to above do we need to call ensure_loaded here? It looks like it is called as part of get_step_map.

Copy link
Author

Choose a reason for hiding this comment

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

Updated the code.

return list(get_step_map().get(entity_type, []))


def get_step_map():
Copy link
Contributor

Choose a reason for hiding this comment

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

should we make this method private and only expose get_steps_for_entity_type?
I feel like get_step_map is only intended to be used in StepListWidget
Also, I'm not sure if the function name is enough descriptive?

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense. Updated the method name and scope.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants