Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit 7c806c0

Browse files
author
David Kydd
committed
Merge of vray branch, minus support for VRay license selector on pools
2 parents 9c4c0b9 + ba1702f commit 7c806c0

File tree

66 files changed

+673
-4731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+673
-4731
lines changed

AzureBatchMaya.pyproj

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -36,48 +36,6 @@
3636
<Compile Include="azure_batch_maya\scripts\assets.py">
3737
<SubType>Code</SubType>
3838
</Compile>
39-
<Compile Include="azure_batch_maya\scripts\batch_extensions\batch_auth.py" />
40-
<Compile Include="azure_batch_maya\scripts\batch_extensions\batch_extensions_client.py" />
41-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\application_template.py" />
42-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\application_template_info.py" />
43-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\application_template_parameter.py" />
44-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\apt_package_reference.py" />
45-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\auto_pool_specification.py" />
46-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\output_file.py" />
47-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\output_file_auto_storage_destination.py" />
48-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\chocolatey_package_reference.py" />
49-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\constants.py" />
50-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\extended_job_parameter.py" />
51-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\extended_pool_parameter.py" />
52-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\extended_pool_specification.py" />
53-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\extended_resource_file.py" />
54-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\extended_task_parameter.py" />
55-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\file_collection_task_factory.py" />
56-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\file_source.py" />
57-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\job_manager_task.py" />
58-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\job_preparation_task.py" />
59-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\job_release_task.py" />
60-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\merge_task.py" />
61-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\extended_output_file_destination.py" />
62-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\package_reference_base.py" />
63-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\parameter_set.py" />
64-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\parametric_sweep_task_factory.py" />
65-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\repeat_task.py" />
66-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\start_task.py" />
67-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\task_collection_task_factory.py" />
68-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\task_factory_base.py" />
69-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\yum_package_reference.py" />
70-
<Compile Include="azure_batch_maya\scripts\batch_extensions\models\__init__.py" />
71-
<Compile Include="azure_batch_maya\scripts\batch_extensions\operations\file_operations.py" />
72-
<Compile Include="azure_batch_maya\scripts\batch_extensions\operations\job_operations.py" />
73-
<Compile Include="azure_batch_maya\scripts\batch_extensions\operations\pool_operations.py" />
74-
<Compile Include="azure_batch_maya\scripts\batch_extensions\operations\__init__.py" />
75-
<Compile Include="azure_batch_maya\scripts\batch_extensions\version.py" />
76-
<Compile Include="azure_batch_maya\scripts\batch_extensions\_file_utils.py" />
77-
<Compile Include="azure_batch_maya\scripts\batch_extensions\_job_utils.py" />
78-
<Compile Include="azure_batch_maya\scripts\batch_extensions\_pool_utils.py" />
79-
<Compile Include="azure_batch_maya\scripts\batch_extensions\_template_utils.py" />
80-
<Compile Include="azure_batch_maya\scripts\batch_extensions\__init__.py" />
8139
<Compile Include="azure_batch_maya\scripts\config.py">
8240
<SubType>Code</SubType>
8341
</Compile>
@@ -155,9 +113,6 @@
155113
<Folder Include="azure_batch_maya\" />
156114
<Folder Include="azure_batch_maya\scripts\" />
157115
<Folder Include="azure_batch_maya\plug-in\" />
158-
<Folder Include="azure_batch_maya\scripts\batch_extensions\" />
159-
<Folder Include="azure_batch_maya\scripts\batch_extensions\models\" />
160-
<Folder Include="azure_batch_maya\scripts\batch_extensions\operations\" />
161116
<Folder Include="azure_batch_maya\scripts\tools\" />
162117
<Folder Include="azure_batch_maya\scripts\ui\" />
163118
<Folder Include="azure_batch_maya\templates\" />

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2017-08-?? v0.11.0
2+
------------------
3+
- Support for V-ray for Maya
4+
- Dependency on new Batch Extensions module
5+
- Fixed asset file limitation
6+
17
2017-07-05 v0.10.0
28
------------------
39
- Exposed low priority VM allocation for pools
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
from maya import mel, cmds
7+
import maya.OpenMaya as om
8+
import maya.OpenMayaMPx as omp
9+
10+
import os
11+
import sys
12+
import gzip
13+
import glob
14+
import tempfile
15+
16+
from default import AzureBatchRenderJob, AzureBatchRenderAssets
17+
18+
19+
class VrayRenderJob(AzureBatchRenderJob):
20+
21+
render_engine = "vray"
22+
23+
def __init__(self):
24+
25+
self._renderer = "vray"
26+
self.label = "V-Ray"
27+
28+
def settings(self):
29+
if self.scene_name == '':
30+
job_name = "Untitled"
31+
else:
32+
job_name = str(os.path.splitext(os.path.basename(self.scene_name))[0])
33+
file_prefix = cmds.getAttr("defaultRenderGlobals.imageFilePrefix")
34+
if file_prefix:
35+
file_prefix = os.path.split(file_prefix)[1]
36+
else:
37+
file_prefix = "<Scene>"
38+
39+
self.job_name = self.display_string("Job Name: ", job_name)
40+
self.output_name = self.display_string("Output Prefix: ", file_prefix)
41+
42+
self.start = self.display_int("Start frame: ", self.start_frame, edit=True)
43+
self.end = self.display_int("End frame: ", self.end_frame, edit=True)
44+
self.step = self.display_int("Frame step: ", self.frame_step, edit=True)
45+
46+
def get_title(self):
47+
return str(cmds.textField(self.job_name, query=True, text=True))
48+
49+
def render_enabled(self):
50+
return True
51+
52+
def get_jobdata(self):
53+
if self.scene_name == '':
54+
raise ValueError("Current Maya scene has not been saved to disk.")
55+
56+
pending_changes = cmds.file(query=True, modified=True)
57+
if not pending_changes:
58+
return self.scene_name, [self.scene_name]
59+
options = {
60+
'save': "Save and continue",
61+
'nosave': "Continue without saving",
62+
'cancel': "Cancel"
63+
}
64+
answer = cmds.confirmDialog(title="Unsaved Changes",
65+
message="There are unsaved changes. Continue?",
66+
button=options.values(),
67+
defaultButton=options['save'],
68+
cancelButton=options['cancel'],
69+
dismissString=options['cancel'])
70+
if answer == options['cancel']:
71+
raise Exception("Submission cancelled")
72+
if answer == options['save']:
73+
cmds.SaveScene()
74+
return self.scene_name, [self.scene_name]
75+
76+
def get_params(self):
77+
params = {}
78+
params['frameStart'] = cmds.intField(self.start, query=True, value=True)
79+
params['frameEnd'] = cmds.intField(self.end, query=True, value=True)
80+
params['frameStep'] = cmds.intField(self.step, query=True, value=True)
81+
params['renderer'] = self._renderer
82+
return params
83+
84+
85+
class VrayRenderAssets(AzureBatchRenderAssets):
86+
87+
assets = []
88+
render_engine = "vray"
89+
file_nodes = {
90+
"VRayScannedMtl": ["file"],
91+
"VRayFastSSS2": ["prepassFileName"],
92+
"VRayMeshMaterial": ["fileName", "overrideFileName"],
93+
"VRayMtlGLSL": ["fileName"],
94+
"VRayMtlOSL": ["fileName"],
95+
"VRaySimbiont": ["file"],
96+
"VRayVRmatMtl": ["fileName"],
97+
"vraySettings": ["pmap_file",
98+
"pmap_file2",
99+
"causticsFile",
100+
"causticsFile2",
101+
"imap_fileName",
102+
"imap_fileName2",
103+
"lc_fileName",
104+
"opt_fileName",
105+
"shr_file_name"]
106+
}
107+
108+
def check_path(self, path):
109+
if '#' in path:
110+
return path.replace('#', '[0-9]')
111+
elif '<udim>' in path:
112+
return path.replace('<udim>', '[0-9][0-9][0-9][0-9]')
113+
elif '<tile>' in path:
114+
return path.replace('<tile>', '_u*_v*')
115+
else:
116+
return path
117+
118+
def renderer_assets(self):
119+
self.assets = []
120+
collected = []
121+
122+
for node_type, attributes in self.file_nodes.items():
123+
nodes = cmds.ls(type=node_type)
124+
for node in nodes:
125+
for attr in attributes:
126+
collected.append(cmds.getAttr(node + "." + attr))
127+
128+
for path in collected:
129+
self.assets.append(self.check_path(path))
130+
return self.assets

azure_batch_maya/plug-in/AzureBatch.py

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import webbrowser
1818
import subprocess
1919
from distutils.version import StrictVersion
20+
from distutils import dir_util
2021

2122
from maya import mel
2223
from maya import cmds
@@ -31,17 +32,20 @@
3132
os.path.join(cmds.internalVar(userScriptDir=True), 'azure-batch-libs'))
3233
sys.path.append(INSTALL_DIR)
3334

34-
REQUIREMENTS = [
35-
"pathlib==1.0.1",
36-
]
37-
38-
NAMESPACE_PACKAGES = [
39-
"azure-mgmt-batch==4.0.0",
40-
"azure-mgmt-storage==1.0.0",
41-
"azure-common==1.1.5",
42-
"azure-batch==3.0.0",
43-
"azure-storage==0.32.0",
44-
]
35+
REQUIREMENTS = {
36+
"pathlib==1.0.1": "pathlib",
37+
"msrestazure==0.4.11": "msrestazure",
38+
"azure-common==1.1.8": "azure.common",
39+
}
40+
41+
NAMESPACE_PACKAGES = {
42+
"azure-mgmt-batch==4.0.0": "azure.mgmt.batch",
43+
"azure-mgmt-storage==1.0.0": "azure.mgmt.storage",
44+
"azure-batch==3.0.0": "azure.batch",
45+
"azure-storage==0.32.0": "azure.storage",
46+
"azure-batch-extensions==0.2.0": "azure.batch_extensions",
47+
"futures==3.1.1": "concurrent.futures"
48+
}
4549

4650
VERSION = "0.10.0"
4751
EULA_PREF = "AzureBatch_EULA"
@@ -327,20 +331,21 @@ def remove_ui(clientData):
327331
print("Failed to load", (str(e)))
328332

329333

330-
def dependency_installed(package):
334+
def dependency_installed(package, namespace):
331335
"""Check if the specified package is installed and up-to-date.
332336
:param str package: A pip-formatted package reference.
333337
"""
334338
try:
335339
package_ref = package.split('==')
336-
module = importlib.import_module(package_ref[0].replace('-', '.'))
340+
module = importlib.import_module(namespace)
337341
if hasattr(module, '__version__') and len(package_ref) > 1:
338342
if StrictVersion(package_ref[1]) > StrictVersion(getattr(module, '__version__')):
339343
raise ImportError("Installed package out of date")
340-
except ImportError:
341-
print("Unable to load {}".format(package))
344+
except ImportError as error:
345+
print("Unable to load {}: {}".format(package, error))
342346
return False
343347
else:
348+
print("Successfully loaded {} from path: {}".format(package, module.__file__))
344349
return True
345350

346351

@@ -351,15 +356,19 @@ def install_pkg(package):
351356
TODO: Check if there's a better way to bypass the verification error.
352357
TODO: Check if this works for package upgrades
353358
"""
359+
if not os.path.isdir(INSTALL_DIR):
360+
os.makedirs(INSTALL_DIR)
354361
pip_cmds = ['mayapy', os.path.join(INSTALL_DIR, 'pip'),
355362
'install', package,
356363
'--target', INSTALL_DIR,
357364
'--index-url', 'http://pypi.python.org/simple/',
358365
'--trusted-host', 'pypi.python.org']
359366
print(pip_cmds)
360-
installer = subprocess.Popen(pip_cmds)
367+
installer = subprocess.Popen(pip_cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
361368
installer.wait()
362369
if installer.returncode != 0:
370+
print(installer.stdout.read())
371+
print(installer.stderr.read())
363372
raise RuntimeError("Failed to install package: {}".format(package))
364373

365374

@@ -372,23 +381,30 @@ def install_namespace_pkg(package, namespace):
372381
:param str namespace: The package namespace to unpack to.
373382
"""
374383
temp_target = os.path.join(INSTALL_DIR, 'temp-target')
384+
if not os.path.isdir(temp_target):
385+
os.makedirs(temp_target)
375386
pip_cmds = ['mayapy', os.path.join(INSTALL_DIR, 'pip'),
376387
'install', package,
377388
'--no-deps',
378389
'--target', temp_target,
379390
'--index-url', 'http://pypi.python.org/simple/',
380391
'--trusted-host', 'pypi.python.org']
381-
installer = subprocess.Popen(pip_cmds)
392+
print(pip_cmds)
393+
installer = subprocess.Popen(pip_cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
382394
installer.wait()
383395
if installer.returncode == 0:
384396
try:
385-
shutil.copytree(os.path.join(temp_target, namespace), os.path.join(INSTALL_DIR, namespace))
386-
except Exception as e:
387-
print(e)
397+
dir_util.copy_tree(os.path.join(temp_target, namespace), os.path.join(INSTALL_DIR, namespace))
398+
except Exception as exp:
399+
print(exp)
388400
try:
389401
shutil.rmtree(temp_target)
390-
except Exception as e:
391-
print(e)
402+
except Exception as exp:
403+
print(exp)
404+
else:
405+
print(installer.stdout.read())
406+
print(installer.stderr.read())
407+
raise RuntimeError("Failed to install package: {}".format(package))
392408

393409

394410
def initializePlugin(obj):
@@ -410,11 +426,13 @@ def initializePlugin(obj):
410426

411427
print("Checking for dependencies...")
412428
missing_libs = []
429+
python_path = os.environ['PYTHONPATH'].lstrip(os.pathsep)
430+
os.environ['PYTHONPATH'] = INSTALL_DIR + os.pathsep + python_path
413431
for package in REQUIREMENTS:
414-
if not dependency_installed(package):
432+
if not dependency_installed(package, REQUIREMENTS[package]):
415433
missing_libs.append(package)
416434
for package in NAMESPACE_PACKAGES:
417-
if not dependency_installed(package):
435+
if not dependency_installed(package, NAMESPACE_PACKAGES[package]):
418436
missing_libs.append(package)
419437
if missing_libs:
420438
message = ("One or more dependencies are missing or out-of-date."
@@ -433,22 +451,26 @@ def initializePlugin(obj):
433451

434452
print("Attempting to install dependencies via Pip.")
435453
try:
436-
os.environ['PYTHONPATH'] = INSTALL_DIR + os.pathsep + os.environ['PYTHONPATH']
437454
install_script = os.path.normpath(os.path.join( os.environ['AZUREBATCH_TOOLS'], 'install_pip.py'))
438-
installer = subprocess.Popen(["mayapy", install_script, '--target', INSTALL_DIR])
455+
installer = subprocess.Popen(["mayapy", install_script, '--target', INSTALL_DIR],
456+
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
439457
installer.wait()
440458
if installer.returncode != 0:
459+
print(installer.stdout.read())
460+
print(installer.stderr.read())
441461
raise RuntimeError("Failed to install pip")
442462
except BaseException as exp:
443463
print("Failed to install Pip. Please install dependencies manually to continue.")
444464
raise
445465
try:
446466
print("Installing dependencies")
447467
for package in missing_libs:
448-
install_pkg(package)
449468
if package in NAMESPACE_PACKAGES:
450-
package_path = package.split('==')[0].split('-')
469+
package_path = NAMESPACE_PACKAGES[package].split('.')
451470
install_namespace_pkg(package, os.path.join(*package_path))
471+
else:
472+
install_pkg(package)
473+
shutil.copy(os.path.join(INSTALL_DIR, 'azure', '__init__.py'), os.path.join(INSTALL_DIR, 'azure', 'mgmt', '__init__.py'))
452474
except:
453475
error = "Failed to install dependencies - please install manually"
454476
cmds.confirmDialog(message=error, button='OK')

azure_batch_maya/scripts/assets.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import pathlib
1717
from Queue import Queue
1818

19+
from azure.batch_extensions import _file_utils as fileutils
20+
1921
from api import MayaAPI as maya
2022
from api import MayaCallbacks as callback
2123

@@ -256,6 +258,18 @@ def configure(self, session):
256258
self._set_searchpaths()
257259
self._assets = Assets(self.batch)
258260

261+
def generate_sas_token(self, file_group):
262+
"""Generate SAS token for file group container with read and list
263+
permissions.
264+
TODO: Move this into BatchExtensions file utils.
265+
"""
266+
container_name = fileutils.get_container_name(file_group)
267+
container_url = fileutils.generate_container_sas_token(
268+
container_name,
269+
self.batch.file.get_storage_client(),
270+
permission='rl')
271+
return container_url
272+
259273
def set_assets(self):
260274
"""Gather the asset references of the scene for display in the
261275
asset tab. Called on loading and refreshing the asset tab.

0 commit comments

Comments
 (0)