-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
206 lines (183 loc) · 6.05 KB
/
Copy pathexample.py
File metadata and controls
206 lines (183 loc) · 6.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
"""This script is an example of how to create a basic magla ecosystem from the ground up.
All creation and deletion methods are in `r`, so this is primarily a demonstration of
using the creation methods in the optimal order.
Each creation method will return the created `MaglaEntity` or in the case that a record already
exists, creation will abort and return the found record instead. To instead return an
`EntityAlreadyExistsError`, you must call the `r.create` method directly and pass the
'return_existing=False` entity_test_fixtureeter
example:
```
r.create(magla.User, {"nickname": "foo"}, return_existing=False)
```
This functionality is demonstrated below where the name of the shot being created is set to
increment - meaning that running this script repeatedly will result in new shot and directory
tree structures under the same project.
"""
import getpass
import magla
r = magla.Root()
# Create Facility
facility = r.create_facility("test_facility",
settings={
"tool_install_directory_label": "{tool_version.tool.name}_{tool_version.string}"}
)
# Create Machine
current_machine = r.create_machine(facility.id)
# Create Project
test_project = r.create_project("test_project", "/mnt/projects/test_project",
settings={
"project_directory": "/mnt/projects/{project.name}",
"project_directory_tree": [
{"shots": []},
{"audio": []},
{"preproduction": [
{"mood": []},
{"reference": []},
{"edit": []}]
}],
# (prefix)(frame-padding)(suffix)
"frame_sequence_re": r"(\w+\W)(\#+)(.+)",
"shot_directory": "{shot.project.directory.path}/shots/{shot.name}",
"shot_directory_tree": [
{"_current": [
{"h265": []},
{"png": []},
{"webm": []}]
}],
"shot_version_directory": "{shot_version.shot.directory.path}/{shot_version.num}",
"shot_version_directory_tree": [
{"_in": [
{"plate": []},
{"subsets": []}
]},
{"_out": [
{"representations": [
{"exr": []},
{"png": []},
{"mov": []}]
}]
}],
"shot_version_bookmarks": {
"png_representation": "representations/png_sequence/_out/png/{shot_version.full_name}.####.png"
}
})
# Create 2D settings template
settings_2d = r.create(magla.Settings2D, {
"label": "Full 4K @30FPS",
"width": 4096,
"height": 2048,
"rate": 30,
"project_id": 1
})
# Create Tool, ToolVersion, ToolVersionInstallation, FileType
natron_2 = r.create_tool(
tool_name="natron",
install_dir="/opt/Natron-2.3.15",
exe_path="/opt/Natron-2.3.15/bin/natron",
version_string="2.3.15",
file_extension=".ntp")
# Create ToolConfig in order to have tool-specific subdirs and launch settings
natron_tool_config = r.create_tool_config(
tool_version_id=natron_2.id,
project_id=test_project.id,
tool_subdir="{tool_version.full_name}",
bookmarks={
"{tool_version.full_name}": "{shot_version.full_name}.ntp"
},
directory_tree=[
{"_in": [
{"plate": []},
{"subsets": []}
]},
{"_out": [
{"exr": []},
{"png": []},
{"subsets": []}]
}]
)
houdini_18 = r.create_tool(
tool_name="houdini",
install_dir="/opt/hfs18.0.532",
exe_path="/opt/hfs18.0.532/bin/houdini",
version_string="18.0.532",
file_extension=".hipnc")
houdini_tool_config = r.create_tool_config(
tool_version_id=houdini_18.id,
project_id=test_project.id,
tool_subdir="{tool_version.full_name}",
bookmarks={
"{tool_version.full_name}": "{shot_version.full_name}.hipnc"
},
directory_tree=[
{"_in": [
{"subsets": []}
]},
{"_out": [
{"subsets": []}
]}
]
)
# create modo tool
modo_14_1v1 = r.create_tool(
tool_name="modo",
install_dir="/opt/Modo14.1v1",
exe_path="/opt/Modo14.1v1/modo",
version_string="14.1v1",
file_extension=".lxo"
)
# create new modo tool version
modo_14_1v2 = r.create_tool_version(
tool_id=modo_14_1v1.tool.id,
version_string="14.1v2",
install_dir="/opt/Modo14.1v2",
exe_path="/opt/Modo14.1v2/modo"
)
modo_tool_config = r.create_tool_config(
tool_version_id=modo_14_1v1.id,
project_id=test_project.id,
tool_subdir="{tool_version.full_name}",
bookmarks={
"{tool_version.full_name}": "{shot_version.full_name}.lxo"
},
directory_tree=[
{"_in": [
{"subsets": []}
]},
{"_out": [
{"subsets": []}
]}
]
)
# Create Shot
shot = r.create_shot(
project_id=test_project.id, name="test_shot_{}".format(len(test_project.shots)))
# Create User
# `magla` user nickname must match the OS's user name
user = r.create_user(getpass.getuser())
# Create Assignment
assignment = r.create_assignment(
shot_id=shot.id,
user_id=user.id
)
# set user's assignment context
# c = user.context
# c.data.assignment_id = assignment.id
# c.data.push()
# use `all` method to retrieve list of all entity records by entity type.
# r.all(magla.User)
# r.all(magla.ShotVersion)
# r.all(magla.Directory)
# Building and exporting timelines
# t = test_project.timeline
# current process is sending list of `MaglaShot` objects to `build` method
# t.build(test_project.shots)
# `MaglaShot` objects include a 'track_index' and 'start_frame_in_parent' property which are
# external to `opentimlineio` but used by `magla` for automatic building. This implementation
# may change.
# t.otio.to_json_file("test_project.json")
# tools can be launched from `MaglaTool` or `MaglaToolVersion` instances
# houdini_18.tool.start()
# by calling `start` from the tool, version will be derrived from user's context
# modo_14_1v2.tool.start()
# alternitively, calling `start` directly from the tool version, that version will override configs
# modo_14_1v2.start()