async def ensure_task_status(
project: "ProjectEntity",
task_status_name: str,
) -> bool:
"""#TODO: cerebro listener for new task statuses would be preferable"""
if task_status_name not in [status["name"] for status in project.statuses]:
logging.info(f"Creating task status {task_status_name} for '{project.name}'")
project.statuses.append(
{
"name": task_status_name,
"short_name": task_status_name[:4],
}
)
await project.save()
return True
return False
This code creates the new task type but doesnt create the short_name
for it for some reason. Attaching the example
Hi @vivimage !
The anatomy attribute for the “Short name” is actually called shortName
rather than short_name
, you can see it if you try hitting the “Copy anatomy” and then paste it into a text editor:
"task_types": [
{
"name": "Modeling",
"shortName": "mdl",
"icon": "language",
"original_name": "Modeling"
},
{
"name": "Shading",
"shortName": "shdn",
"icon": "format_paint",
"original_name": "Shading"
},
This is unfortunately also broken in the Kitsu integration addon (where I’m guessing you got this code from), there’s an open issue for it at:
opened 03:21PM - 29 Aug 24 UTC
type: bug
### Is there an existing issue for this?
- [X] I have searched the existing iss… ues
### Current Behavior:
It seems that new task types sync to AYON as:
```
{'name': 'TestType', 'short_name': 'Test'}
```
So it doesn't contain the shortName key
But that should be:
```
{'name': 'TestType', 'shortName': 'Test'}
```
This breaks the launcher:
```
Traceback (most recent call last):
File "C:\Users\joseph.henry\AppData\Local\Ynput\AYON\addons\core_0.4.3\ayon_core\tools\utils\lib.py", line 444, in run
self._result = self._callback()
File "C:\Users\joseph.henry\AppData\Local\Ynput\AYON\addons\core_0.4.3\ayon_core\tools\utils\tasks_widget.py", line 198, in _thread_getter
task_type_items = self._controller.get_task_type_items(
File "C:\Users\joseph.henry\AppData\Local\Ynput\AYON\addons\core_0.4.3\ayon_core\tools\launcher\control.py", line 68, in get_task_type_items
return self._projects_model.get_task_type_items(
File "C:\Users\joseph.henry\AppData\Local\Ynput\AYON\addons\core_0.4.3\ayon_core\tools\common_models\projects.py", line 357, in get_task_type_items
return self._get_project_items(
File "C:\Users\joseph.henry\AppData\Local\Ynput\AYON\addons\core_0.4.3\ayon_core\tools\common_models\projects.py", line 380, in _get_project_items
cache_value = getter(self.get_project_entity(project_name))
File "C:\Users\joseph.henry\AppData\Local\Ynput\AYON\addons\core_0.4.3\ayon_core\tools\common_models\projects.py", line 454, in _task_type_items_getter
return [
File "C:\Users\joseph.henry\AppData\Local\Ynput\AYON\addons\core_0.4.3\ayon_core\tools\common_models\projects.py", line 455, in <listcomp>
TaskTypeItem.from_project_item(task_type)
File "C:\Users\joseph.henry\AppData\Local\Ynput\AYON\addons\core_0.4.3\ayon_core\tools\common_models\projects.py", line 138, in from_project_item
short=task_type_data["shortName"],
KeyError: 'shortName'
```
### Expected Behavior:
Syncing shouldn't break AYON.
### Version
1.0.0
### What platform you are running on?
Windows
### Steps To Reproduce:
1. Created a new task type in Kitsu, added it to a newly created shot
2. Sync the project in Ayon admin interface
3. Open the launcher and click on a tree object
### Are there any labels you wish to add?
- [X] I have added the relevant labels to the bug report.
### Relevant log output:
_No response_
### Additional context:
See discord discussion here https://discord.com/channels/517362899170230292/1278648431338065992
**Note** There also appears to be logic that makes the short name, however that logic would fail if the long name is shorter than four characters. Here: https://github.com/ynput/ayon-kitsu/blob/a049b3be8dde9d033fbf8beb3c9427a56076c715/server/kitsu/push.py#L458-L469
But changing from short_name
to shortName
as the key should theoretically fix the issue for you I believe!
Cheers,
Nikhil