Blender Kitsu: New Way to Find Assets for Shot Builder #179

Closed
opened 2023-12-07 20:50:53 +01:00 by Nick Alberelli · 12 comments
Member

Issue

The current shot builder relies on Assets.py to define classes for all assets to be loaded into production. This can be tedious and is not dynamically when new assets are made in Kitsu.

  • Must define a class per asset
  • Doesn't integrate with current asset manager in Blender
  • Must be manually updated per asset or if asset is renamed/versioned up

Name Matching: Solution A

Remove the Assets.py file and instead use the same in file naming convention for both data-blocks and names on Kitsu. This means the names on kitsu will match collection names.

Kitsu Name Collection with Prefix
CH-mikassa CH-mikassa
CH-ballen_wrasse CH-ballen_wrasse

Name Matching: Solution B

Remove the Assets.py file and instead...

Match the name from Kitsu with the collection name. Using the Following Rules when converting names from Kitsu to Blender Collections.

  • If Collection is marked as Asset
  • Ignore Collection Prefix
  • All lowercase
  • Replace spaces with _
Kitsu Name Matching Name Collection with Prefix
Mikassa mikassa CH-mikassa
Ballen wrasse ballen_wrasse CH-ballen_wrasse

image

How it Works

After a user clicks operator to Build a New Shot This Feature Will Work as Follows

  • Recieve Asset Names from Kitsu Server for given Shot
  • We find assets/ directory via Project Root Preference
  • Loop over items in assets directory and find collections that match names from Kitsu via Name Matching Solution A or B.
  • Link in Libaries with matching names IF they are marked as an Asset (feature of asset pipeline add-on)

Additional Note

I would really like to re-write the shot builder to make it easier to maintain, this task could be grafted onto the existing shot builder or be part of that rewrite depending on how long until we are building shots.

Either way we need this feature for the next production.

Please advise @FoxGlove

# Issue The current shot builder relies on [`Assets.py`](https://projects.blender.org/studio/blender-studio-pipeline/src/branch/main/scripts-blender/addons/blender_kitsu/shot_builder/docs/examples/assets.py) to define classes for all assets to be loaded into production. This can be tedious and is not dynamically when new assets are made in Kitsu. - Must define a class per asset - Doesn't integrate with current asset manager in Blender - Must be manually updated per asset or if asset is renamed/versioned up # Name Matching: Solution A Remove the [`Assets.py`](https://projects.blender.org/studio/blender-studio-pipeline/src/branch/main/scripts-blender/addons/blender_kitsu/shot_builder/docs/examples/assets.py) file and instead use the same [in file naming convention](https://studio.blender.org/pipeline/naming-conventions/in-file-prefixes) for both data-blocks and names on Kitsu. This means the names on kitsu will match collection names. | Kitsu Name | Collection with Prefix | |---------------|------------------| | CH-mikassa | CH-mikassa | | CH-ballen_wrasse | CH-ballen_wrasse | # Name Matching: Solution B Remove the [`Assets.py`](https://projects.blender.org/studio/blender-studio-pipeline/src/branch/main/scripts-blender/addons/blender_kitsu/shot_builder/docs/examples/assets.py) file and instead... Match the name from Kitsu with the collection name. Using the Following Rules when converting names from Kitsu to Blender Collections. - If Collection is marked as Asset - Ignore Collection Prefix - All lowercase - Replace spaces with `_` | Kitsu Name | Matching Name | Collection with Prefix | |---------------|----------------|------------------| | Mikassa | mikassa | CH-mikassa | | Ballen wrasse | ballen_wrasse | CH-ballen_wrasse | ![image](/attachments/4839435c-84c4-4335-848b-cdadb481f2e7) # How it Works After a user clicks operator to Build a New Shot This Feature Will Work as Follows - Recieve Asset Names from Kitsu Server for given Shot - We find [`assets/`](https://studio.blender.org/pipeline/naming-conventions/svn-folder-structure) directory via [Project Root Preference](https://studio.blender.org/pipeline/addons/blender_kitsu#setup-project-settings:~:text=Setup%20Project%20Settings,per%20project%20basis) - Loop over items in assets directory and find collections that match names from Kitsu via Name Matching Solution **A** or **B**. - Link in Libaries with matching names IF they are marked as an Asset (feature of asset pipeline add-on) ## Additional Note I would really like to re-write the shot builder to make it easier to maintain, this task could be grafted onto the existing shot builder or be part of that rewrite depending on how long until we are building shots. Either way we need this feature for the next production. Please advise @FoxGlove
Nick Alberelli added the
Kind
Proposal
Kind
Enhancement
labels 2023-12-07 20:51:03 +01:00
Author
Member

@ZedDB as we discussed ^

@ZedDB as we discussed ^
Member

this sounds good to me! where would the location of the asset be defined? Just automatically derive it from the asset type and our current project structure?

this sounds good to me! where would the location of the asset be defined? Just automatically derive it from the asset type and our current project structure?

Hmm, I still think we should have the name mapping logic be as simple as possible.

For example on the Kitsu side with the current mappings I would expect the following rules on the Kistu side of things that we have to enforce:

  1. Names can not contain underscores. IE no: "Mikassa v_003"
  2. Only the first letter can/should be upper case. IE no: "MiKaSSa" or "Euro Sea Bass"
  3. No prefixes or dashes. For example if we have "Spider-Man" as an asset, then this means that the conversion code could mistake Spider- as a prefix and drop it.

For me personally, I would prefer the mappings to be "one to one" (the name is the exact same in Blender and in Kitsu).
Otherwise you can get into weird corner cases like if we have CH-rock, PR-rock, and SE-rock.
(IE, we have a character named "Rock", a rigged prop rock, and a set centered around a rock or the character Rock)

Of course it is a bit of a contrived example because you could avoid this by more careful naming. But I think being able to not have to think about these things at all would be good.

By having a "one to one" mapping we will never have any confusion about what asset something maps to and users will never be surprised when authoring assets as there is no chance of the code mangling the asset names and remapping it to the wrong thing.

For example: Someone in "The Rock" production gets a task to create a "Prop rock". They mistake their task and creates PR-rock instead of PR-prop_rock and push data to Kistu unknowingly mangling the data of CH-rock.

If we instead go "one to one", the task/asset on Kitsu would be to create PR-prop_rock. In this case they could just copy paste the name and not have to think about any special naming conversions.

Less code, less mental overhead -> Win, Win.

Hmm, I still think we should have the name mapping logic be as simple as possible. For example on the Kitsu side with the current mappings I would expect the following rules on the Kistu side of things that we have to enforce: 1. Names can not contain underscores. IE no: "Mikassa v_003" 2. Only the first letter can/should be upper case. IE no: "MiKaSSa" or "Euro Sea Bass" 3. No prefixes or dashes. For example if we have "Spider-Man" as an asset, then this means that the conversion code could mistake `Spider-` as a prefix and drop it. For me personally, I would prefer the mappings to be "one to one" (the name is the exact same in Blender and in Kitsu). Otherwise you can get into weird corner cases like if we have `CH-rock`, `PR-rock`, and `SE-rock`. (IE, we have a character named "Rock", a rigged prop rock, and a set centered around a rock or the character Rock) Of course it is a bit of a contrived example because you could avoid this by more careful naming. But I think being able to not have to think about these things at all would be good. By having a "one to one" mapping we will never have any confusion about what asset something maps to and users will never be surprised when authoring assets as there is no chance of the code mangling the asset names and remapping it to the wrong thing. For example: Someone in "The Rock" production gets a task to create a "Prop rock". They mistake their task and creates `PR-rock` instead of `PR-prop_rock` and push data to Kistu unknowingly mangling the data of `CH-rock`. If we instead go "one to one", the task/asset on Kitsu would be to create `PR-prop_rock`. In this case they could just copy paste the name and not have to think about any special naming conversions. Less code, less mental overhead -> Win, Win.
Author
Member

this sounds good to me! where would the location of the asset be defined? Just automatically derive it from the asset type and our current project structure?

@eyecandy Yes it in theory be based on the folder structure we have defined for SVN because we already get a project root from Kitsu Preferences we simply add assets/ to that path.

I have updated the Issue with this information.

> this sounds good to me! where would the location of the asset be defined? Just automatically derive it from the asset type and our current project structure? @eyecandy Yes it in theory be based on the folder structure we have defined for [SVN](https://studio.blender.org/pipeline/naming-conventions/svn-folder-structure) because we already get a [project root](https://studio.blender.org/pipeline/addons/blender_kitsu#setup-project-settings:~:text=Setup%20Project%20Settings,per%20project%20basis) from Kitsu Preferences we simply add `assets/` to that path. I have updated the Issue with this information.
Author
Member

@ZedDB That is a good idea, so just a full one to one copy of the names in Kitsu to match the datablock naming in Blender. Essentially this means that the kitsu naming will follow the same in file naming convention as the datablocks and my propsal gets even simpler!

I have updated the issue with this as a possible solution

@ZedDB That is a good idea, so just a full one to one copy of the names in Kitsu to match the datablock naming in Blender. Essentially this means that the kitsu naming will follow the same [in file naming convention](https://studio.blender.org/pipeline/naming-conventions/in-file-prefixes) as the datablocks and my propsal gets even simpler! I have updated the issue with this as a possible solution

Had a chat with Nick, let's go with solution B, provided that there is a way to prefix the asset type to the name (as defined in the in-file naming conventions). For example, take the asset type, pick the fist 2 letters, make it uppercase.

Had a chat with Nick, let's go with solution B, provided that there is a way to prefix the asset type to the name (as defined in the in-file naming conventions). For example, take the asset type, pick the fist 2 letters, make it uppercase.

Why not go with the most simple and straight forward solution?

I don't see any benefits of not having a one to one mapping of assets names.

Besides potential mistakes during production, it also means that we will have to employ two different naming conventions that we have to keep track of and maintain. Especially because the names will refer to the exact same data.

Why not go with the most simple and straight forward solution? I don't see any benefits of not having a one to one mapping of assets names. Besides potential mistakes during production, it also means that we will have to employ two different naming conventions that we have to keep track of and maintain. Especially because the names will refer to the exact same data.
Author
Member

@fsiddi Sorry I didn't express my opinion on the call as I was trying to rush through the meeting agenda. If this is up to debate here is my opinion:

I agree with @ZedDB that option A is cleaner and requires less thought from the code side.

Mainly I would be concerned with another piece of documentation that needs to be created for users to understand the mapping between the two name types, if we use Solution B.

BUT if we don't include the prefixs in the names, maybe there is a happy medium between the two? So...

Solution C

Match the Kitsu Name Exactly to Collection Name minus the Prefix

Kitsu Name Type -> Prefix Collection with Prefix
mikassa Character -> CH CH-mikassa
my_new_prop Prop -> PR PR-my_new_prop
@fsiddi Sorry I didn't express my opinion on the call as I was trying to rush through the meeting agenda. If this is up to debate here is my opinion: I agree with @ZedDB that option A is cleaner and requires less thought from the code side. Mainly I would be concerned with another piece of documentation that needs to be created for users to understand the mapping between the two name types, if we use Solution B. BUT if we don't include the prefixs in the names, maybe there is a happy medium between the two? So... ### Solution C Match the Kitsu Name Exactly to Collection Name minus the Prefix | Kitsu Name | Type -> Prefix | Collection with Prefix | |---------------|----------------|------------------| | mikassa | Character -> CH | CH-mikassa | | my_new_prop | Prop -> PR | PR-my_new_prop |

Kitsu is about human-readable information. I rather see a new metadata field, called slug, used to store that info. A bit more work when creating assets, but overall ok.

Kitsu Name Slug Type -> Prefix Collection with Prefix
Mikassa mikassa Character -> CH CH-mikassa
European sea bass european_sea_bass Prop -> PR PR-european_sea_bass
Kitsu is about human-readable information. I rather see a new metadata field, called `slug`, used to store that info. A bit more work when creating assets, but overall ok. | Kitsu Name | Slug | Type -> Prefix | Collection with Prefix | |---------------|----------------|------------------|--| | Mikassa | mikassa | Character -> CH | CH-mikassa | | European sea bass | european_sea_bass | Prop -> PR | PR-european_sea_bass|

I agree that storing this information is a slug is a good way forward.

Andy suggested that we could even have a slug for each category type in kitsu as well so we don't need to have any lookup there either. IE, the Prop catergory has a slug with PR- in it so to get the name in Blender you just combine them.

No guess work and easy logic. I like it!

I agree that storing this information is a slug is a good way forward. Andy suggested that we could even have a slug for each category type in kitsu as well so we don't need to have any lookup there either. IE, the `Prop` catergory has a slug with `PR-` in it so to get the name in Blender you just combine them. No guess work and easy logic. I like it!

To reiterate

Kitsu Name Slug
Mikassa CH-mikassa
European sea bass CH-european_sea_bass
Sailboat PR-sailboat
To reiterate | Kitsu Name | Slug | |---------------|----------------| | Mikassa | `CH-mikassa` | | European sea bass | `CH-european_sea_bass` | | Sailboat | `PR-sailboat` |
Author
Member
Closed by https://projects.blender.org/studio/blender-studio-pipeline/pulls/183
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: studio/blender-studio-tools#179
No description provided.