sqi-submitter 0.1.0.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. sqi_submitter/__init__.py +6 -0
  2. sqi_submitter/_version.py +4 -0
  3. sqi_submitter/core/__init__.py +34 -0
  4. sqi_submitter/core/adapter.py +35 -0
  5. sqi_submitter/core/context.py +38 -0
  6. sqi_submitter/core/errors.py +49 -0
  7. sqi_submitter/core/mapping.py +80 -0
  8. sqi_submitter/core/schema.py +152 -0
  9. sqi_submitter/core/session.py +123 -0
  10. sqi_submitter/core/submit.py +64 -0
  11. sqi_submitter/hosts/__init__.py +2 -0
  12. sqi_submitter/hosts/blender/__init__.py +8 -0
  13. sqi_submitter/hosts/blender/adapter.py +53 -0
  14. sqi_submitter/hosts/blender/addon.py +561 -0
  15. sqi_submitter/hosts/houdini/__init__.py +9 -0
  16. sqi_submitter/hosts/houdini/adapter.py +84 -0
  17. sqi_submitter/hosts/houdini/menu.py +21 -0
  18. sqi_submitter/hosts/houdini/startup/sqi_submitter.json +3 -0
  19. sqi_submitter/hosts/maya/__init__.py +9 -0
  20. sqi_submitter/hosts/maya/adapter.py +58 -0
  21. sqi_submitter/hosts/maya/menu.py +22 -0
  22. sqi_submitter/hosts/maya/startup/sqi.mod +2 -0
  23. sqi_submitter/hosts/maya/startup/userSetup.py +6 -0
  24. sqi_submitter/hosts/nuke/__init__.py +9 -0
  25. sqi_submitter/hosts/nuke/adapter.py +60 -0
  26. sqi_submitter/hosts/nuke/menu.py +17 -0
  27. sqi_submitter/hosts/nuke/startup/menu.py +6 -0
  28. sqi_submitter/py.typed +0 -0
  29. sqi_submitter/qt/__init__.py +2 -0
  30. sqi_submitter/qt/_compat.py +44 -0
  31. sqi_submitter/qt/dialog.py +507 -0
  32. sqi_submitter/qt/widgets.py +224 -0
  33. sqi_submitter-0.1.0.dev0.dist-info/METADATA +78 -0
  34. sqi_submitter-0.1.0.dev0.dist-info/RECORD +37 -0
  35. sqi_submitter-0.1.0.dev0.dist-info/WHEEL +4 -0
  36. sqi_submitter-0.1.0.dev0.dist-info/entry_points.txt +2 -0
  37. sqi_submitter-0.1.0.dev0.dist-info/licenses/LICENSE +661 -0
@@ -0,0 +1,6 @@
1
+ # SPDX-License-Identifier: AGPL-3.0-or-later
2
+ """sqi-submitter: DCC submitter framework on top of sqi-sdk."""
3
+
4
+ from sqi_submitter._version import __version__
5
+
6
+ __all__ = ["__version__"]
@@ -0,0 +1,4 @@
1
+ # SPDX-License-Identifier: AGPL-3.0-or-later
2
+ """Single-source package version (read by hatchling and the package)."""
3
+
4
+ __version__ = "0.1.0.dev0"
@@ -0,0 +1,34 @@
1
+ # SPDX-License-Identifier: AGPL-3.0-or-later
2
+ """No-Qt, no-DCC core: everything a submitter UI or headless tool needs."""
3
+
4
+ from sqi_submitter.core.adapter import HostAdapter
5
+ from sqi_submitter.core.context import RenderTarget, SceneContext, frame_range_str
6
+ from sqi_submitter.core.errors import FormInvalidError, SubmitterError
7
+ from sqi_submitter.core.mapping import is_output_path_param, is_scene_path_param, prefill
8
+ from sqi_submitter.core.schema import FormField, FormModel
9
+ from sqi_submitter.core.session import (
10
+ Settings,
11
+ SubmitterSession,
12
+ group_products,
13
+ resolve_server_url,
14
+ )
15
+ from sqi_submitter.core.submit import submit_form
16
+
17
+ __all__ = [
18
+ "FormField",
19
+ "FormInvalidError",
20
+ "FormModel",
21
+ "HostAdapter",
22
+ "RenderTarget",
23
+ "SceneContext",
24
+ "Settings",
25
+ "SubmitterError",
26
+ "SubmitterSession",
27
+ "frame_range_str",
28
+ "group_products",
29
+ "is_output_path_param",
30
+ "is_scene_path_param",
31
+ "prefill",
32
+ "resolve_server_url",
33
+ "submit_form",
34
+ ]
@@ -0,0 +1,35 @@
1
+ # SPDX-License-Identifier: AGPL-3.0-or-later
2
+ """HostAdapter: the one interface a new Python tool implements to plug in."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import abc
7
+
8
+ from sqi_submitter.core.context import RenderTarget, SceneContext
9
+
10
+
11
+ class HostAdapter(abc.ABC):
12
+ """Scene extraction contract; everything else is shared core code.
13
+
14
+ ``host_name`` is the lowercase token used for suggested-product grouping
15
+ and per-host settings keys (e.g. "maya").
16
+ """
17
+
18
+ host_name: str = ""
19
+ display_name: str = ""
20
+
21
+ @abc.abstractmethod
22
+ def scene_context(self) -> SceneContext:
23
+ """Best-effort facts about the open scene (None = unknown)."""
24
+
25
+ @abc.abstractmethod
26
+ def render_targets(self) -> list[RenderTarget]:
27
+ """Renderable units to offer in the target picker (may be empty)."""
28
+
29
+ def is_scene_modified(self) -> bool:
30
+ """Whether the scene has unsaved changes (default: assume saved)."""
31
+ return False
32
+
33
+ def save_scene(self) -> bool:
34
+ """Save the scene; return False when it cannot be saved (no path)."""
35
+ return True
@@ -0,0 +1,38 @@
1
+ # SPDX-License-Identifier: AGPL-3.0-or-later
2
+ """What a host adapter can tell us about the open scene."""
3
+
4
+ from __future__ import annotations
5
+
6
+ from collections.abc import Mapping
7
+ from dataclasses import dataclass, field
8
+
9
+
10
+ @dataclass(frozen=True)
11
+ class SceneContext:
12
+ """Best-effort scene facts; ``None`` means the host cannot cheaply know."""
13
+
14
+ scene_path: str | None = None
15
+ frame_range: str | None = None
16
+ output_path: str | None = None
17
+ renderer: str | None = None
18
+
19
+
20
+ @dataclass(frozen=True)
21
+ class RenderTarget:
22
+ """One renderable unit (ROP, Write node, render layer, view layer).
23
+
24
+ ``extra`` maps exact product-parameter names (e.g. ``RopPath``) to values;
25
+ ``frame_range``/``output_path`` override the scene-level values when set.
26
+ """
27
+
28
+ name: str
29
+ kind: str
30
+ frame_range: str | None = None
31
+ output_path: str | None = None
32
+ extra: Mapping[str, str] = field(default_factory=dict)
33
+
34
+
35
+ def frame_range_str(start: float, end: float) -> str:
36
+ """Format a start/end pair using the ``Frames`` convention ("1-100", "5")."""
37
+ lo, hi = int(start), int(end)
38
+ return str(lo) if lo == hi else f"{lo}-{hi}"
@@ -0,0 +1,49 @@
1
+ # SPDX-License-Identifier: AGPL-3.0-or-later
2
+ """One error translation layer so Qt and bpy UIs share identical error text."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import contextlib
7
+ from collections.abc import Iterator
8
+
9
+ from sqi_client.errors import (
10
+ APIError,
11
+ NotFoundError,
12
+ SqiConnectionError,
13
+ SqiError,
14
+ SqiTimeoutError,
15
+ ValidationError,
16
+ )
17
+
18
+
19
+ class SubmitterError(Exception):
20
+ """An error with a message fit to show an artist."""
21
+
22
+ def __init__(self, user_message: str) -> None:
23
+ super().__init__(user_message)
24
+ self.user_message = user_message
25
+
26
+
27
+ class FormInvalidError(SubmitterError):
28
+ """Client-side validation failed; per-field messages in ``errors``."""
29
+
30
+ def __init__(self, errors: dict[str, str]) -> None:
31
+ super().__init__("Please fix the highlighted fields.")
32
+ self.errors = errors
33
+
34
+
35
+ @contextlib.contextmanager
36
+ def translate_errors(server_url: str) -> Iterator[None]:
37
+ """Map sqi-sdk exceptions to SubmitterError with artist-facing text."""
38
+ try:
39
+ yield
40
+ except (SqiConnectionError, SqiTimeoutError) as exc:
41
+ raise SubmitterError(
42
+ f"Cannot reach the sqi server at {server_url}. Check the server URL in Settings."
43
+ ) from exc
44
+ except ValidationError as exc:
45
+ raise SubmitterError(str(exc)) from exc
46
+ except NotFoundError as exc:
47
+ raise SubmitterError(f"{exc} — it no longer exists on the server.") from exc
48
+ except (APIError, SqiError) as exc:
49
+ raise SubmitterError(str(exc)) from exc
@@ -0,0 +1,80 @@
1
+ # SPDX-License-Identifier: AGPL-3.0-or-later
2
+ """Name-convention pre-fill: SceneContext/RenderTarget → product parameters.
3
+
4
+ The convention is a documented, additive-only contract (docs/dcc-submitters.md):
5
+ pre-fill binds ONLY by parameter name, never by product identity.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from collections.abc import Sequence
11
+
12
+ from sqi_client.models import ProductParameter
13
+ from sqi_submitter.core.context import RenderTarget, SceneContext
14
+
15
+ CONVENTION_ALIASES: dict[str, frozenset[str]] = {
16
+ # "scene" is deliberately NOT an alias: hosts/blender/adapter.py emits a
17
+ # target extra key "Scene" holding the Blender scene NAME (not a path),
18
+ # and extras beat convention aliases in prefill() below. Keeping "scene"
19
+ # here would silently overwrite a scene-name extra with a scene path for
20
+ # any product parameter literally named "Scene".
21
+ "scene_path": frozenset({"scenefile", "scenepath"}),
22
+ "frame_range": frozenset({"frames", "framerange"}),
23
+ "output_path": frozenset({"outputdir", "outputpath"}),
24
+ "renderer": frozenset({"renderer"}),
25
+ }
26
+
27
+
28
+ def _norm(name: str) -> str:
29
+ return name.lower().replace("_", "").replace("-", "")
30
+
31
+
32
+ def is_scene_path_param(name: str) -> bool:
33
+ """True when a parameter name is the scene-file field by convention.
34
+
35
+ Reuses CONVENTION_ALIASES["scene_path"] so hosts and UIs share one
36
+ definition of "which field is the scene path".
37
+ """
38
+ return _norm(name) in CONVENTION_ALIASES["scene_path"]
39
+
40
+
41
+ def is_output_path_param(name: str) -> bool:
42
+ """True when a parameter name is the output-path field by convention.
43
+
44
+ Reuses CONVENTION_ALIASES["output_path"] so the "default output from the
45
+ scene when left blank" rule shares one definition with prefill.
46
+ """
47
+ return _norm(name) in CONVENTION_ALIASES["output_path"]
48
+
49
+
50
+ def prefill(
51
+ parameters: Sequence[ProductParameter],
52
+ context: SceneContext,
53
+ target: RenderTarget | None = None,
54
+ ) -> dict[str, str]:
55
+ """Return {product parameter name: value} for every convention match."""
56
+ values: dict[str, str] = {}
57
+ facts = {
58
+ "scene_path": context.scene_path,
59
+ "frame_range": context.frame_range,
60
+ "output_path": context.output_path,
61
+ "renderer": context.renderer,
62
+ }
63
+ if target is not None:
64
+ if target.frame_range is not None:
65
+ facts["frame_range"] = target.frame_range
66
+ if target.output_path is not None:
67
+ facts["output_path"] = target.output_path
68
+ extras = {_norm(k): v for k, v in (target.extra if target else {}).items()}
69
+
70
+ for param in parameters:
71
+ key = _norm(param.name)
72
+ if key in extras:
73
+ values[param.name] = extras[key]
74
+ continue
75
+ for fact, aliases in CONVENTION_ALIASES.items():
76
+ value = facts[fact]
77
+ if value is not None and key in aliases:
78
+ values[param.name] = value
79
+ break
80
+ return values
@@ -0,0 +1,152 @@
1
+ # SPDX-License-Identifier: AGPL-3.0-or-later
2
+ """UI-agnostic form model built from a product's parameter schema.
3
+
4
+ Mirrors the web submission form's widget/validation semantics (B2): explicit
5
+ userInterface control wins, otherwise a type-driven fallback; validation covers
6
+ required, numeric parsing, min/max, length limits, and allowed values.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from collections.abc import Mapping, Sequence
12
+ from dataclasses import dataclass, field
13
+
14
+ from sqi_client.models import ProductParameter
15
+ from sqi_submitter.core.mapping import is_scene_path_param
16
+
17
+
18
+ @dataclass
19
+ class FormField:
20
+ """One parameter's presentation + editing state."""
21
+
22
+ parameter: ProductParameter
23
+ value: str | None = None
24
+ error: str | None = None
25
+ prefilled: bool = False
26
+
27
+ @property
28
+ def widget(self) -> str:
29
+ ui = self.parameter.user_interface
30
+ control = ui.control if (ui is not None and ui.control) else ""
31
+ t = self.parameter.type
32
+ # PATH is type-first: OpenJD has no picker control, so LINE_EDIT (the
33
+ # only legal control that can carry a label on a path) must not suppress
34
+ # the derived picker. An explicit non-LINE_EDIT control (e.g. HIDDEN)
35
+ # still wins. See docs/dcc-submitters.md.
36
+ if t == "PATH" and control in ("", "LINE_EDIT"):
37
+ if self.parameter.object_type == "DIRECTORY":
38
+ return "CHOOSE_DIRECTORY"
39
+ if self.parameter.data_flow == "OUT":
40
+ return "CHOOSE_OUTPUT_FILE"
41
+ return "CHOOSE_INPUT_FILE"
42
+ if control:
43
+ return control
44
+ if t in ("INT", "FLOAT"):
45
+ return "SPIN_BOX"
46
+ if self.parameter.allowed_values:
47
+ return "DROPDOWN_LIST"
48
+ return "LINE_EDIT"
49
+
50
+ @property
51
+ def label(self) -> str:
52
+ ui = self.parameter.user_interface
53
+ return ui.label if ui is not None and ui.label else self.parameter.name
54
+
55
+ @property
56
+ def group(self) -> str:
57
+ ui = self.parameter.user_interface
58
+ return ui.group_label if ui is not None else ""
59
+
60
+ @property
61
+ def hidden(self) -> bool:
62
+ return self.widget == "HIDDEN"
63
+
64
+ @property
65
+ def required(self) -> bool:
66
+ return self.parameter.default is None
67
+
68
+ @property
69
+ def is_scene_path(self) -> bool:
70
+ return is_scene_path_param(self.parameter.name)
71
+
72
+
73
+ @dataclass
74
+ class FormModel:
75
+ """Ordered fields + values + validation; UIs bind to this, never to params."""
76
+
77
+ fields: list[FormField] = field(default_factory=list)
78
+
79
+ @classmethod
80
+ def from_parameters(cls, parameters: Sequence[ProductParameter]) -> FormModel:
81
+ return cls(fields=[FormField(parameter=p, value=p.default) for p in parameters])
82
+
83
+ def _field(self, name: str) -> FormField:
84
+ for f in self.fields:
85
+ if f.parameter.name == name:
86
+ return f
87
+ raise KeyError(name)
88
+
89
+ def set_value(self, name: str, value: str) -> None:
90
+ f = self._field(name)
91
+ f.value = value
92
+ f.prefilled = False
93
+
94
+ def apply_prefill(self, values: Mapping[str, str]) -> None:
95
+ for f in self.fields:
96
+ if f.hidden:
97
+ continue
98
+ if f.parameter.name in values:
99
+ f.value = values[f.parameter.name]
100
+ f.prefilled = True
101
+
102
+ def validate(self) -> bool:
103
+ ok = True
104
+ for f in self.fields:
105
+ f.error = _validate_field(f)
106
+ ok = ok and f.error is None
107
+ return ok
108
+
109
+ def errors(self) -> dict[str, str]:
110
+ return {f.parameter.name: f.error for f in self.fields if f.error}
111
+
112
+ def values(self) -> dict[str, str]:
113
+ return {f.parameter.name: f.value for f in self.fields if f.value is not None}
114
+
115
+ def groups(self) -> list[tuple[str, list[FormField]]]:
116
+ out: list[tuple[str, list[FormField]]] = []
117
+ for f in self.fields:
118
+ if f.hidden:
119
+ continue
120
+ if out and out[-1][0] == f.group:
121
+ out[-1][1].append(f)
122
+ else:
123
+ out.append((f.group, [f]))
124
+ return out
125
+
126
+
127
+ def _validate_field(f: FormField) -> str | None:
128
+ p, v = f.parameter, f.value
129
+ if v is None or v == "":
130
+ return "Required" if f.required else None
131
+ if p.type == "INT":
132
+ try:
133
+ num: float = int(v)
134
+ except ValueError:
135
+ return "Must be an integer"
136
+ elif p.type == "FLOAT":
137
+ try:
138
+ num = float(v)
139
+ except ValueError:
140
+ return "Must be a number"
141
+ if p.type in ("INT", "FLOAT"):
142
+ if p.min_value is not None and num < float(p.min_value):
143
+ return f"Must be at least {p.min_value}"
144
+ if p.max_value is not None and num > float(p.max_value):
145
+ return f"Must be at most {p.max_value}"
146
+ if p.min_length is not None and len(v) < p.min_length:
147
+ return f"Must be at least {p.min_length} characters"
148
+ if p.max_length is not None and len(v) > p.max_length:
149
+ return f"Must be at most {p.max_length} characters"
150
+ if p.allowed_values and v not in p.allowed_values:
151
+ return "Not an allowed value"
152
+ return None
@@ -0,0 +1,123 @@
1
+ # SPDX-License-Identifier: AGPL-3.0-or-later
2
+ """Server session, per-user settings, and product grouping for submitter UIs."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import json
7
+ import os
8
+ from collections.abc import Sequence
9
+ from pathlib import Path
10
+ from typing import Any
11
+
12
+ from sqi_client import SqiClient
13
+ from sqi_client.models import Farm, Job, Product, ProductParameter, Queue
14
+ from sqi_submitter.core.errors import translate_errors
15
+
16
+ DEFAULT_SERVER_URL = "http://localhost:8080"
17
+
18
+
19
+ class Settings:
20
+ """Tiny JSON key-value store at ~/.sqi/submitter.json (env-overridable)."""
21
+
22
+ def __init__(self, path: str | None = None) -> None:
23
+ self._path = Path(
24
+ path
25
+ or os.environ.get("SQI_SUBMITTER_SETTINGS")
26
+ or Path.home() / ".sqi" / "submitter.json"
27
+ )
28
+
29
+ def _load(self) -> dict[str, Any]:
30
+ try:
31
+ data = json.loads(self._path.read_text(encoding="utf-8"))
32
+ return data if isinstance(data, dict) else {}
33
+ except (OSError, ValueError):
34
+ return {}
35
+
36
+ def get(self, key: str, default: Any = None) -> Any:
37
+ return self._load().get(key, default)
38
+
39
+ def set(self, key: str, value: Any) -> None:
40
+ data = self._load()
41
+ data[key] = value
42
+ self._path.parent.mkdir(parents=True, exist_ok=True)
43
+ self._path.write_text(json.dumps(data, indent=2), encoding="utf-8")
44
+
45
+
46
+ def resolve_server_url(explicit: str | None, settings: Settings) -> str:
47
+ """explicit arg → $SQI_SERVER_URL → settings → default."""
48
+ if explicit:
49
+ return explicit
50
+ env = os.environ.get("SQI_SERVER_URL")
51
+ if env:
52
+ return env
53
+ stored = settings.get("server_url")
54
+ if stored:
55
+ return str(stored)
56
+ return DEFAULT_SERVER_URL
57
+
58
+
59
+ class SubmitterSession:
60
+ """Everything a submitter UI needs from the server, error-translated."""
61
+
62
+ def __init__(
63
+ self,
64
+ server_url: str | None = None,
65
+ client: SqiClient | None = None,
66
+ settings: Settings | None = None,
67
+ ) -> None:
68
+ self.settings = settings or Settings()
69
+ self.server_url = resolve_server_url(server_url, self.settings)
70
+ self.client = client or SqiClient(self.server_url)
71
+
72
+ def products(self) -> list[Product]:
73
+ with translate_errors(self.server_url):
74
+ return self.client.list_products()
75
+
76
+ def parameters(self, name: str) -> list[ProductParameter]:
77
+ with translate_errors(self.server_url):
78
+ return self.client.get_product_parameters(name)
79
+
80
+ def farms(self) -> list[Farm]:
81
+ with translate_errors(self.server_url):
82
+ return self.client.list_farms()
83
+
84
+ def queues(self, farm_id: str) -> list[Queue]:
85
+ with translate_errors(self.server_url):
86
+ return list(self.client.iter_queues(farm_id=farm_id))
87
+
88
+ def submit(
89
+ self,
90
+ product_name: str,
91
+ *,
92
+ parameters: dict[str, str],
93
+ farm_id: str,
94
+ queue_id: str,
95
+ job_name: str | None = None,
96
+ ) -> Job:
97
+ with translate_errors(self.server_url):
98
+ return self.client.submit_product_job(
99
+ product_name,
100
+ farm_id=farm_id,
101
+ queue_id=queue_id,
102
+ job_name=job_name,
103
+ parameters=parameters,
104
+ )
105
+
106
+
107
+ def group_products(
108
+ products: Sequence[Product], host_token: str
109
+ ) -> tuple[list[Product], list[Product]]:
110
+ """Split into (suggested, rest) by a cosmetic host-token match.
111
+
112
+ Nothing is ever hidden: ordering only. Pre-fill is independent of this.
113
+ """
114
+ token = host_token.lower()
115
+ if not token:
116
+ return [], list(products)
117
+ suggested = [
118
+ p
119
+ for p in products
120
+ if token in p.name.lower() or token in p.title.lower() or token in p.description.lower()
121
+ ]
122
+ rest = [p for p in products if p not in suggested]
123
+ return suggested, rest
@@ -0,0 +1,64 @@
1
+ # SPDX-License-Identifier: AGPL-3.0-or-later
2
+ """The one submit flow shared by every UI (Qt dialog, bpy panel, headless)."""
3
+
4
+ from __future__ import annotations
5
+
6
+ from sqi_client.models import Job
7
+ from sqi_submitter.core.adapter import HostAdapter
8
+ from sqi_submitter.core.errors import FormInvalidError, SubmitterError
9
+ from sqi_submitter.core.mapping import is_output_path_param, is_scene_path_param
10
+ from sqi_submitter.core.schema import FormModel
11
+ from sqi_submitter.core.session import SubmitterSession
12
+
13
+
14
+ def submit_form(
15
+ session: SubmitterSession,
16
+ product_name: str,
17
+ model: FormModel,
18
+ *,
19
+ farm_id: str,
20
+ queue_id: str,
21
+ job_name: str | None = None,
22
+ adapter: HostAdapter | None = None,
23
+ save_scene: bool = True,
24
+ ) -> Job:
25
+ """Save-if-needed → validate → submit. Raises SubmitterError variants."""
26
+ if adapter is not None:
27
+ ctx = adapter.scene_context()
28
+ if not ctx.scene_path:
29
+ raise SubmitterError(
30
+ "Save your scene before submitting — the farm renders the file on disk."
31
+ )
32
+ for f in model.fields:
33
+ if is_scene_path_param(f.parameter.name):
34
+ # Scene path is host-authoritative: always the open file.
35
+ model.set_value(f.parameter.name, ctx.scene_path)
36
+ elif is_output_path_param(f.parameter.name) and not f.value:
37
+ # Output left blank defaults to the scene's own output setting.
38
+ # If the scene has none either, fail fast rather than render to
39
+ # an unpredictable relative path in the worker's working dir.
40
+ if not ctx.output_path:
41
+ raise SubmitterError(
42
+ "No output path set. Enter an output path, or set an "
43
+ "output location in your scene's render settings."
44
+ )
45
+ model.set_value(f.parameter.name, ctx.output_path)
46
+ if (
47
+ adapter is not None
48
+ and save_scene
49
+ and adapter.is_scene_modified()
50
+ and not adapter.save_scene()
51
+ ):
52
+ raise SubmitterError(
53
+ "The scene could not be saved. Save it manually, then submit "
54
+ "(the farm renders the file on disk)."
55
+ )
56
+ if not model.validate():
57
+ raise FormInvalidError(model.errors())
58
+ return session.submit(
59
+ product_name,
60
+ parameters=model.values(),
61
+ farm_id=farm_id,
62
+ queue_id=queue_id,
63
+ job_name=job_name,
64
+ )
@@ -0,0 +1,2 @@
1
+ # SPDX-License-Identifier: AGPL-3.0-or-later
2
+ """DCC host adapters (Maya, Houdini, Nuke, Blender)."""
@@ -0,0 +1,8 @@
1
+ # SPDX-License-Identifier: AGPL-3.0-or-later
2
+ """Blender submitter adapter (the native add-on is registered separately)."""
3
+
4
+ from __future__ import annotations
5
+
6
+ from sqi_submitter.hosts.blender.adapter import BlenderAdapter
7
+
8
+ __all__ = ["BlenderAdapter"]
@@ -0,0 +1,53 @@
1
+ # SPDX-License-Identifier: AGPL-3.0-or-later
2
+ """Blender scene extraction (bpy imported lazily; never at module import)."""
3
+
4
+ from __future__ import annotations
5
+
6
+ from sqi_submitter.core import HostAdapter, RenderTarget, SceneContext, frame_range_str
7
+
8
+
9
+ class BlenderAdapter(HostAdapter):
10
+ host_name = "blender"
11
+ display_name = "Blender"
12
+
13
+ def scene_context(self) -> SceneContext:
14
+ import bpy
15
+
16
+ scene = bpy.context.scene
17
+ return SceneContext(
18
+ scene_path=bpy.data.filepath or None,
19
+ frame_range=frame_range_str(scene.frame_start, scene.frame_end),
20
+ output_path=scene.render.filepath,
21
+ renderer=scene.render.engine,
22
+ )
23
+
24
+ def render_targets(self) -> list[RenderTarget]:
25
+ import bpy
26
+
27
+ targets: list[RenderTarget] = []
28
+ for scene in bpy.data.scenes:
29
+ frame_range = frame_range_str(scene.frame_start, scene.frame_end)
30
+ for layer in scene.view_layers:
31
+ targets.append(
32
+ RenderTarget(
33
+ name=f"{scene.name} / {layer.name}",
34
+ kind="view_layer",
35
+ frame_range=frame_range,
36
+ output_path=scene.render.filepath,
37
+ extra={"Scene": scene.name, "ViewLayer": layer.name},
38
+ )
39
+ )
40
+ return targets
41
+
42
+ def is_scene_modified(self) -> bool:
43
+ import bpy
44
+
45
+ return bool(bpy.data.is_dirty)
46
+
47
+ def save_scene(self) -> bool:
48
+ import bpy
49
+
50
+ if not bpy.data.filepath:
51
+ return False # never saved; the artist must save-as first
52
+ bpy.ops.wm.save_mainfile()
53
+ return True