Skip to content

Commit 97b6432

Browse files
committed
Update creation of dcc workfile
- add .flake8 copied from tk-core - add vim files to .gitignore - remove restrictions of single dcc workfile of same type per parent - add workfile type designation to workfile asset name - remove sg_task_name parameter - fix flake complaints
1 parent ccae094 commit 97b6432

6 files changed

Lines changed: 77 additions & 25 deletions

File tree

.flake8

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Copyright (c) 2017 Shotgun Software Inc.
2+
#
3+
# CONFIDENTIAL AND PROPRIETARY
4+
#
5+
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
6+
# Source Code License included in this distribution package. See LICENSE.
7+
# By accessing, using, copying or modifying this work you indicate your
8+
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
9+
# not expressly granted therein are reserved by Shotgun Software Inc.
10+
11+
# Flake 8 PEP and lint configuration - https://gitlab.com/pycqa/flake8
12+
#
13+
# This defines the official lint and PEP8 rules for this repository
14+
#
15+
# You can run this locally by doing pep install flake8 and then
16+
# >flake8 /path/to/core
17+
#
18+
# This is also used by the hound CI - see the .hound.yml config file.
19+
#
20+
#
21+
[flake8]
22+
23+
# things we don't want to lint
24+
exclude =
25+
.tox,
26+
.git,
27+
.flake8,
28+
.gitignore,
29+
.travis.yml,
30+
.cache,
31+
.eggs,
32+
*.rst,
33+
*.yml,
34+
*.pyc,
35+
*.pyo,
36+
*.egg-info,
37+
__pycache__,
38+
# Those are our third parties, do not lint them!
39+
python/tank_vendor,
40+
# Otherwise you'll have a lot of 'xxx' imported but unused
41+
python/tank/__init__.py,
42+
python/tank/*/__init__.py,
43+
# Skip the auto-generated ui file.
44+
python/tank/authentication/ui/login_dialog.py,
45+
python/tank/authentication/ui/resources_rc.py,
46+
python/tank/platform/qt/ui_busy_dialog.py,
47+
python/tank/platform/qt/ui_item.py,
48+
python/tank/platform/qt/ui_tank_dialog.py,
49+
python/tank/authentication/sso_saml2/*,
50+
tests/python
51+
52+
# toolkit exceptions
53+
#
54+
# E203 whitespace before ':' (this is not PEP8 compliant)
55+
# E221 multiple spaces before operator
56+
# E261 two whitespaces before end of line comment.
57+
# E402 module level import not top of file
58+
# E501 line too long (112 > 79 characters)
59+
# W503 Line break occurred before a binary operator
60+
# N802 Variables should be lower case. (clashes with Qt naming conventions)
61+
# N806 Variables should be lower case. (clashes with Qt naming conventions)
62+
# E999 SyntaxError: invalid syntax (hack for hound CI which runs python 3.x)
63+
64+
ignore = E203, E221, E261, E402, E501, W503, N802, N806, E999

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ nosetests.xml
3737

3838
# Ideavim
3939
.idea
40+
41+
# IDEs and Editors
42+
*.swo
43+
*.swp
44+
*.swm
45+
*~
46+

python/tk_multi_loader/flowam/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
of the ShotGrid REST API.
1616
"""
1717

18+
# flake8: noqa
19+
1820
import sgtk
1921

2022
logger = sgtk.platform.get_logger(__name__)

python/tk_multi_loader/flowam/create.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ class CreateInputs(flowam_utils.BaseInputs):
5454
sg_pipeline_step: str
5555
#: The AM project under which the asset should be added.
5656
am_project_id: str
57-
#: The name of the current SG task.
58-
sg_task_name: str = ""
5957
#: Description of asset.
6058
description: str = ""
6159
#: Determines which initial source file to use to create the asset.
@@ -102,10 +100,6 @@ def validate(self):
102100
if self.create_mode == create.CreateMode.GENERIC and not self.source_path:
103101
msg = "No source path provided for generic asset."
104102
raise exceptions.CreateAssetError(data=self.asdict(), details=msg)
105-
# If pipeline step is provided, we expect task_name to be provided as well
106-
if self.sg_pipeline_step and not self.sg_task_name:
107-
msg = "Incomplete sg context provided. Must provide sg_task_name."
108-
raise exceptions.CreateAssetError(data=self.asdict(), details=msg)
109103
# prep_scene_callback is only applicable when create_mode is NEW or TEMPLATE
110104
if (
111105
self.create_mode == create.CreateMode.GENERIC
@@ -283,14 +277,6 @@ def in_dcc_context() -> bool:
283277
return engine.name != "tk-desktop"
284278

285279

286-
def _has_workfile_type(parent: objects.FlowAsset, type_id: str) -> bool:
287-
"""Return True if parent asset contains a child of given type."""
288-
289-
if parent.find_children(type_id=type_id):
290-
return True
291-
return False
292-
293-
294280
def _create_dcc_workfile_asset(
295281
parent: objects.FlowAsset, inputs: CreateInputs
296282
) -> sandbox.NewDraftInfo:
@@ -313,15 +299,9 @@ def _create_dcc_workfile_asset(
313299
workfile_type = flow_host().WORKFILE_TYPE
314300
type_id = schema.get_schema_id(workfile_type)
315301

316-
# Only allow one workfile of DCC type under parent
317-
if _has_workfile_type(parent, type_id):
318-
msg = f'A workfile of type "{workfile_type}" has already been created '
319-
msg += f'under pipeline step "{parent.name}". Please open the asset from '
320-
msg += "the Loader app to publish another revision of this asset."
321-
raise exceptions.CreateAssetError(data=inputs.asdict(), details=msg)
322-
323-
# By convention asset name will be the sg entity name
324-
name = inputs.sg_entity_name
302+
# By convention asset name will be the sg entity name + workfile type
303+
abbr_type = workfile_type.split(".")[-1].upper()
304+
name = f"{inputs.sg_entity_name} - {abbr_type}"
325305

326306
# Prepare the source file and save to temporary location
327307
# By convention the source file will be named after the asset

python/tk_multi_loader/flowam/flowam_actions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ def _on_build_scene_dialog_accepted(
167167
sg_pipeline_step=(task.get("step") or {}).get(
168168
"name", ""
169169
), # Layout, Animation, etc.
170-
sg_task_name=sg_publish_data["content"],
171170
am_project_id=flow_am_id,
172171
create_mode=dialog.build,
173172
source_path=template_path,

python/tk_multi_loader/flowam/template_queries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from __future__ import annotations
1414

15-
from typing import Any, Optional
15+
from typing import Optional
1616

1717
import sgtk
1818
from sgtk.flowam.create import PIPELINE_STEP_TYPE, TEMPLATE_FOLDER, TEMPLATE_TYPE

0 commit comments

Comments
 (0)