This commit is contained in:
annatisch 2017-05-08 08:22:09 -07:00
Родитель 5efd9b288c
Коммит 34873a4e63
9 изменённых файлов: 41 добавлений и 119 удалений

Просмотреть файл

@ -5,13 +5,15 @@
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>f585989b-2df8-4241-8d02-948958187914</ProjectGuid>
<ProjectHome>.</ProjectHome>
<StartupFile>tests\__init__.py</StartupFile>
<StartupFile>package.py</StartupFile>
<WorkingDirectory>.</WorkingDirectory>
<OutputPath>.</OutputPath>
<Name>Maya.Client</Name>
<RootNamespace>Maya.Client</RootNamespace>
<InterpreterId>{288d073e-7bc9-4fc6-9095-44d701572fd4}</InterpreterId>
<InterpreterVersion>2.7</InterpreterVersion>
<InterpreterId>
</InterpreterId>
<InterpreterVersion>
</InterpreterVersion>
<SearchPath>azure_batch_maya\scripts\;azure_batch_maya\scripts\ui\;tests\data\;tests\data\modules\</SearchPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
@ -129,9 +131,6 @@
<Compile Include="tests\test_assets.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="tests\test_config.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="tests\test_environment.py">
<SubType>Code</SubType>
</Compile>
@ -144,9 +143,6 @@
<Compile Include="tests\test_pools.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="tests\test_shared.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="tests\test_submission.py">
<SubType>Code</SubType>
</Compile>
@ -196,19 +192,6 @@
<SubType>Code</SubType>
</Content>
</ItemGroup>
<ItemGroup>
<Interpreter Include="env\">
<Id>{288d073e-7bc9-4fc6-9095-44d701572fd4}</Id>
<BaseInterpreter>{9a7a9026-48c1-4688-9d5d-e5699d47d074}</BaseInterpreter>
<Version>2.7</Version>
<Description>env (Python 64-bit 2.7)</Description>
<InterpreterPath>Scripts\python.exe</InterpreterPath>
<WindowsInterpreterPath>Scripts\pythonw.exe</WindowsInterpreterPath>
<LibraryPath>Lib\</LibraryPath>
<PathEnvironmentVariable>PYTHONPATH</PathEnvironmentVariable>
<Architecture>Amd64</Architecture>
</Interpreter>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<PtvsTargetsFile>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets</PtvsTargetsFile>

Просмотреть файл

@ -191,9 +191,7 @@ def _add_cmd_prefix(task, os_flavor):
"""Add OS-specific command prefix to command line."""
if os_flavor == pool_utils.PoolOperatingSystemFlavor.WINDOWS:
# TODO: Do we need windows shell escaping?
print("Escape command line: ", task.command_line)
task.command_line = 'cmd /c "{}"'.format(task.command_line) #.replace('\"','\\\\\"')
print("Done: ", task.command_line)
elif os_flavor == pool_utils.PoolOperatingSystemFlavor.LINUX:
task.command_line = '/bin/bash -c {}'.format(task.command_line)
else:
@ -601,7 +599,6 @@ def _process_resource_files(request, fileutils):
if isinstance(request, list):
return [_process_resource_files(r, fileutils) for r in request if isinstance(r, Model)]
for attr, value in request.__dict__.items():
print("checking attrs: ", attr, value)
if attr in ['resource_files', 'common_resource_files']:
if value and isinstance(value, list):
new_resources = []
@ -640,8 +637,6 @@ def _parse_task_output_files(task, os_flavor, file_utils):
destination.auto_storage = None
if not output_file.upload_options.upload_condition:
raise ValueError("outputFile.upload_options must include upload_condition.")
for output_file in task.output_files:
print(output_file.file_pattern)
def _transform_sweep_str(data, parameters):

Просмотреть файл

@ -119,10 +119,12 @@ class AzureBatchPools(object):
self.selected_pool.set_target(pool.target_dedicated_nodes)
self.selected_pool.set_type(
"Auto" if pool.id.startswith("Maya_Auto_Pool") else "Provisioned")
self.selected_pool.set_state(pool.state.value)
self.selected_pool.set_state(pool.state.value, nodes)
self.selected_pool.set_tasks(pool.max_tasks_per_node)
self.selected_pool.set_allocation(pool.allocation_state.value)
self.selected_pool.set_created(pool.creation_time)
self.selected_pool.set_licenses(pool.application_licenses)
self.selected_pool.set_vm_sku(pool.vm_size)
maya.refresh()
except Exception as exp:
self._log.warning(str(exp))

Просмотреть файл

@ -261,7 +261,7 @@ class AzureBatchSubmission(object):
batch_parameters['displayName'] = self.renderer.get_title()
batch_parameters['metadata'] = [{"name": "JobType", "value": "Maya"}]
template_file = os.path.join(
os.environ['AZUREBATCH_TEMPLATES'], 'arnold-basic-{}.json'.format(pool_os))
os.environ['AZUREBATCH_TEMPLATES'], 'arnold-basic-{}.json'.format(pool_os.lower()))
batch_parameters['applicationTemplateInfo'] = {'filePath': template_file}
application_params = {}
batch_parameters['applicationTemplateInfo']['parameters'] = application_params
@ -308,10 +308,7 @@ class AzureBatchSubmission(object):
except Exception as exp:
self._log.error(exp)
exc_type, exc_value, exc_traceback = sys.exc_info()
print "*** print_tb:"
traceback.print_tb(exc_traceback)
print "*** print_exception:"
traceback.print_exception(exc_type, exc_value, exc_traceback)
self._log.debug("".join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
finally:
if progress:
progress.end()

Просмотреть файл

@ -180,7 +180,6 @@ class ConfigUI(object):
"""Called when the plug-in is authenticated. Sets heading text."""
maya.text(
self.heading, edit=True, label="Authentication Configuration")
print("x")
maya.form_layout(self.page, edit=True, enable=True)
def is_logged_out(self):

Просмотреть файл

@ -186,15 +186,23 @@ class AzureBatchPoolInfo(object):
"""Set the date/time the pool was created.
:param str value: The datetime string of the pool creation.
"""
#datetime = value.split('T')
#datetime[1] = datetime[1].split('.')[0]
label = str(value)#' '.join(datetime)
maya.text(self._created, edit=True, label=" {0}".format(label))
datetime = str(value).split('.')[0]
maya.text(self._created, edit=True, label=" {0}".format(datetime))
def set_state(self, value):
def set_state(self, value, nodes):
"""Set the state of the pool.
:param str value: The pool state.
"""
node_states = {}
for node in nodes:
if node.state in node_states:
node_states[node.state] += 1
else:
node_states[node.state] = 1
if node_states:
value += " : "
for state in node_states:
value += "{} nodes {} ".format(node_states[state], state.value)
maya.text(self._state, edit=True, label=" {0}".format(value))
def set_tasks(self, value):
@ -209,6 +217,19 @@ class AzureBatchPoolInfo(object):
"""
maya.text(self._allocation, edit=True, label=" {0}".format(value))
def set_licenses(self, value):
"""Set the licenses available on the pool.
:param list value: The available application licenses.
"""
licenses = ', '.join([l.title() for l in value]) if value else ""
maya.text(self._licenses, edit=True, label=" {0}".format(licenses))
def set_vm_sku(self, value):
"""Set the VM instance type of the pool.
:param str value: The VM type.
"""
maya.text(self._vm_sku, edit=True, label=" {0}".format(value))
def on_expand(self):
"""Command for the expanding of the pool reference frame layout.
Loads latest details for the specified pool and populates UI.
@ -220,6 +241,8 @@ class AzureBatchPoolInfo(object):
self._state = self.display_info("State: ")
self._tasks = self.display_info("Tasks per VM: ")
self._allocation = self.display_info("Allocation State: ")
self._licenses = self.display_info("Licenses: ")
self._vm_sku = self.display_info("VM type: ")
self.base.pool_selected(self)
auto = self.base.is_auto_pool()
if not auto:

Просмотреть файл

@ -32,7 +32,7 @@ import subprocess
import shutil
import zipfile
VERSION = "0.8.1"
VERSION = "0.9.0"
def main():
"""Build Maya Plug-in package"""
@ -48,7 +48,7 @@ def main():
return
package = os.path.join(package_dir, "AzureBatch_Maya_Plugin-v{0}.zip".format(VERSION))
source = os.path.abspath("batchapps_maya")
source = os.path.abspath("azure_batch_maya")
with zipfile.ZipFile(package, mode='w') as maya_zip:
for root, dirs, files in os.walk(source):
@ -56,7 +56,7 @@ def main():
continue
for file in files:
if os.path.splitext(file)[1] in ['.png', '.mel', '.py', '.html']:
if os.path.splitext(file)[1] in ['.png', '.mel', '.py', '.html', '.json']:
maya_zip.write(os.path.relpath(os.path.join(root, file)))
print("Package complete!")

Просмотреть файл

Просмотреть файл

@ -1,77 +0,0 @@
#-------------------------------------------------------------------------
#
# Batch Apps Maya Plugin
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the ""Software""), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
#--------------------------------------------------------------------------
import sys
import os
import logging
import datetime
try:
import unittest2 as unittest
except ImportError:
import unittest
try:
from unittest import mock
except ImportError:
import mock
from ui_shared import BatchAppsUI
from shared import BatchAppsSettings
class TestBatchAppsShared(unittest.TestCase):
def setUp(self):
self.mock_self = mock.create_autospec(BatchAppsSettings)
self.mock_self._log = logging.getLogger("TestShared")
return super(TestBatchAppsShared, self).setUp()
#@mock.patch("shared.maya")
#def test_check_version(self, mock_maya):
# self.mock_self.supported_versions = [2015]
# mock_maya.mel.return_value = 2015
# self.mock_self.check_version = lambda a: BatchAppsSettings.check_version(self.mock_self, a)
# ver = BatchAppsSettings.check_maya_version(self.mock_self)
# self.assertEqual(ver, 2015)
# self.assertFalse(mock_maya.warning.call_count)
# mock_maya.mel.return_value = 2016
# ver = BatchAppsSettings.check_maya_version(self.mock_self)
# self.assertEqual(ver, 2015)
# self.assertTrue(mock_maya.warning.call_count)
# mock_maya.mel.return_value = 2014
# ver = BatchAppsSettings.check_maya_version(self.mock_self)
# self.assertEqual(ver, 2015)
# self.assertEqual(mock_maya.warning.call_count, 2)