def initialize(): zync_api = zync.Zync(application='3dsmax') zync_adapter = ZyncApiFacade(zync_api, file_select_dialog, settings, consent_dialog) model = _create_model(max_api, zync_adapter.generate_file_path, zync_adapter.is_v2()) return zync_adapter, model
def login(self): """Performs user login.""" try: if self.zync_conn is None: self.zync_conn = zync.Zync(application='houdini') if not self.zync_conn.has_user_login(): self.zync_conn.login_with_google() except zync.ZyncConnectionError as ce: hou.ui.displayMessage(text=str(ce))
def submit_dialog(): global ZYNC if ZYNC == None: try: ZYNC = zync.Zync('nuke_plugin', API_KEY) except Exception as e: nuke.message( 'Couldn\'t connect to ZYNC. Are you connected to the internet?' ) return ZyncRenderPanel().showModalDialog()
def _get_files(project, prefix, max_depth=DEFAULT_MAX_DIR_DEPTH): """Fetches data from Zync API. Args: project: str, Project name. prefix: str, File path prefix. max_depth: int, Max directory recursion. Returns: [dict], A structure describing files structure. See zync.Zync().list_files. """ return zync.Zync().list_files( _build_gcs_prefix(project, prefix), recursive=True, max_depth=max_depth)
# # Go two levels up and add that directory to the PATH, so we can find zync.py. # import sys, os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) # # Import ZYNC Python API. # import zync # # Connect to ZYNC. This will start the browser to perform an Oauth2 # authorization if needed. # z = zync.Zync() # # Path to the Maya scene. # scene_path = '/path/to/project/scenes/maya_scene_v01.mb' # # Other job parameters. # params = { # # num_instances = Number of render nodes to assign to this job. # 'num_instances': 1, #
# Go two levels up and add that directory to the PATH, so we can find zync.py. import sys, os sys.path.append( os.path.dirname( os.path.dirname( os.path.abspath(__file__) ) ) ) # Import ZYNC Python API. import zync # Connect to ZYNC. Set up a script & API token via the Admin page in the ZYNC # Web Console. z = zync.Zync( "SCRIPT_NAME", "API_TOKEN" ) # Get a list of all unseen trigger events. event_list = z.get_triggers() # Display each completed job. for event in event_list: if event["event_type"] == "job_complete": print "Job %s Completed!" % ( event["job_id"], )
# Go two levels up and add that directory to the PATH, so we can find zync.py. # import sys, os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) # # Import ZYNC Python API. # import zync # # Connect to ZYNC. Set up a script & API token via the Admin page in the ZYNC # Web Console. # z = zync.Zync('nuke_launcher', '**********************') # # Login with your ZYNC username & password. This will allow you to launch jobs. # z.login(username='******', password='******') # # Path to the Nuke script. # script_path = '/path/to/project/comp/nuke_script_v01.nk' # # A comma-separated list of Write nodes to render. "All" will render all enabled # write nodes in the script. #
def func_init(): self._zync_conn = zync.Zync(application='3dsmax')
def launch( geoData, zyncPath, instance_type='(PREEMPTIBLE) zync-16vcpu-32gb', frameRange='1-1000', verbose=0 ): '''Perform tasks necessary to deploy ZYNC render job. Consists mainly of building 'params' dict and submitting to the ZYNC object 'z'.''' # Append Zync Python API to path. sys.path.append(zyncPath) # Import Zync Python API. import zync # Connect to ZYNC. This will start the browser to perform an # Oauth2 authorization if needed. z = zync.Zync() # Path to the Maya scene. scene_path = geoData['scene_path'] objectName = geoData.keys()[0] # Define job params. params = { 'num_instances': 10, 'priority': 50, 'job_subtype': 'render', 'upload_only': 0, 'proj_name': 'cad-iot-ml', 'skip_check': 0, 'instance_type': instance_type, 'frange': frameRange, 'step': 1, 'chunk_size': 50, 'renderer': 'arnold', 'layers': 'defaultRenderLayer', 'out_path': geoData['image_dir'], 'camera': 'CAM:render_cam', 'xres': 512, 'yres': 384, 'project': geoData['base_path'], 'ignore_plugin_errors': 0, 'distributed': 0, 'use_vrscene': 0, 'use_ass': 0, 'use_mi': 0, 'vray_nightly': 0, 'scene_info': { 'files': [], 'arnold_version': '3.0.1.1', 'plugins': ['mtoa'], 'file_prefix': ['', { 'cad-iot-ml': '' }], 'padding': 4, 'vray_version': '3.60.04', 'references': [ geoData['camera_rig'], geoData['light_rig'], geoData['geo_path'], ], 'unresolved_references': [], 'render_layers': [ 'defaultRenderLayer' ], 'render_passes': {}, 'extension': 'exr', 'version': '2017' }, 'plugin_version': 'custom' } # Print assembled params, if requested. if verbose == 5: pp(params) # end if # Launch the job. submit_job() returns the ID of the new job. try: jobId = z.submit_job( 'maya', scene_path, params=params ) return jobId except zync.ZyncError, exc: raise Exception(exc)
__copyright__ = 'Copyright 2011, Atomic Fiction, Inc.' config_path = '%s/config_maya.py' % (os.path.dirname(__file__), ) if not os.path.exists(config_path): raise Exception('Could not locate config_maya.py, please create.') from config_maya import * required_config = ['API_DIR', 'API_KEY'] for key in required_config: if not key in globals(): raise Exception('config_maya.py must define a value for %s.' % (key, )) sys.path.append(API_DIR) import zync ZYNC = zync.Zync('maya_plugin', API_KEY, application='maya') UI_FILE = '%s/resources/submit_dialog.ui' % (os.path.dirname(__file__), ) import maya.cmds as cmds import maya.mel def generate_scene_path(extra_name=None): """ Returns a hash-embedded scene path with /cloud_submit/ at the end of the path, for separation from user scenes. TODO: factor out into zync python module """ scene_path = cmds.file(q=True, loc=True)
# # Go two levels up and add that directory to the PATH, so we can find zync.py. # import sys, os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) # # Import ZYNC Python API. # import zync # # Connect to ZYNC. Set up a script & API token via the Admin page in the ZYNC # Web Console. # z = zync.Zync('maya_launcher', '*******************') # # Login with your ZYNC username & password. This will allow you to launch jobs. # z.login(username='******', password='******') # # Path to the Maya scene. # scene_path = '/path/to/project/scenes/maya_scene_v01.mb' # # Other job parameters. # params = {
def __init__(self): # make sure this isn't an unsaved script if nuke.root().name() == 'Root' or nuke.modified(): msg = 'Please save your script before rendering on Zync.' raise Exception(msg) self.zync_conn = zync.Zync(application='nuke') nukescripts.panels.PythonPanel.__init__(self, 'Zync Render', 'com.google.zync') if platform.system() in ('Windows', 'Microsoft'): self.usernameDefault = os.environ['USERNAME'] else: self.usernameDefault = os.environ['USER'] #GET WRITE NODES FROM FILE self.writeDict = dict() self.update_write_dict() # CREATE KNOBS self.num_slots = nuke.Int_Knob('num_slots', 'Num. Machines:') self.num_slots.setDefaultValue((1,)) sorted_types = [t for t in self.zync_conn.INSTANCE_TYPES] sorted_types.sort(self.zync_conn.compare_instance_types) display_list = [] for inst_type in sorted_types: label = '%s (%s)' % (inst_type, self.zync_conn.INSTANCE_TYPES[inst_type]['description'].replace(', preemptible','')) inst_type_base = inst_type.split(' ')[-1] pricing_key = 'CP-ZYNC-%s-NUKE' % (inst_type_base.upper(),) if 'PREEMPTIBLE' in inst_type.upper(): pricing_key += '-PREEMPTIBLE' if (pricing_key in self.zync_conn.PRICING['gcp_price_list'] and 'us' in self.zync_conn.PRICING['gcp_price_list'][pricing_key]): label += ' $%s/hr' % ( self.zync_conn.PRICING['gcp_price_list'][pricing_key]['us'],) display_list.append(label) self.instance_type = nuke.Enumeration_Knob('instance_type', 'Type:', display_list) self.pricing_label = nuke.Text_Knob('pricing_label', '') self.pricing_label.setValue('Est. Cost per Hour: Not Available') calculator_link = nuke.Text_Knob('calculator_link', '') calculator_link.setValue('<a style="color:#ff8a00;" ' + 'href="http://zync.cloudpricingcalculator.appspot.com">' + 'Cost Calculator</a>') proj_response = self.zync_conn.get_project_list() self.existing_project = nuke.Enumeration_Knob('existing_project', 'Existing Project:', [' '] + [p['name'] for p in proj_response]) self.new_project = nuke.String_Knob('project', ' New Project:') self.new_project.clearFlag(nuke.STARTLINE) self.upload_only = nuke.Boolean_Knob('upload_only', 'Upload Only') self.upload_only.setFlag(nuke.STARTLINE) self.parent_id = nuke.String_Knob('parent_id', 'Parent ID:') self.parent_id.setValue('') # create shotgun controls - they'll only be added if shotgun integration # is enabled. self.sg_create_version = nuke.Boolean_Knob('sg_create_version', 'Create Shotgun Version') self.sg_create_version.setFlag(nuke.STARTLINE) self.sg_create_version.setValue(False) self.sg_user = nuke.String_Knob('sg_user', 'Shotgun User:'******'sg_project', 'Shotgun Project:') self.sg_project.setFlag(nuke.STARTLINE) self.sg_shot = nuke.String_Knob('sg_shot', 'Shotgun Shot:') self.sg_shot.setFlag(nuke.STARTLINE) self.sg_version_code = nuke.String_Knob('sg_version_code', 'Version Code:') self.sg_version_code.setFlag(nuke.STARTLINE) script_base, ext = os.path.splitext(os.path.basename( nuke.root().knob('name').getValue())) self.sg_version_code.setValue(script_base) self.hideSGControls() self.priority = nuke.Int_Knob('priority', 'Job Priority:') self.priority.setDefaultValue((50,)) self.skip_check = nuke.Boolean_Knob('skip_check', 'Skip File Check') self.skip_check.setFlag(nuke.STARTLINE) first = nuke.root().knob('first_frame').value() last = nuke.root().knob('last_frame').value() frange = '%d-%d' % (first, last) self.frange = nuke.String_Knob('frange', 'Frame Range:', frange) self.fstep = nuke.Int_Knob('fstep', 'Frame Step:') self.fstep.setDefaultValue((1,)) selected_write_nodes = [] for node in nuke.selectedNodes(): if node.Class() == 'Write': selected_write_nodes.append(node.name()) self.writeNodes = [] colNum = 1 for writeName in self.writeListNames: knob = nuke.Boolean_Knob(writeName, writeName) if len(selected_write_nodes) == 0: knob.setValue(True) elif writeName in selected_write_nodes: knob.setValue(True) else: knob.setValue(False) if colNum == 1: knob.setFlag(nuke.STARTLINE) if colNum > 3: colNum = 1 else: colNum += 1 knob.setTooltip(self.writeDict[writeName].knob('file').value()) self.writeNodes.append(knob) self.chunk_size = nuke.Int_Knob('chunk_size', 'Chunk Size:') self.chunk_size.setDefaultValue((10,)) # controls for logging in and out self.loginButton = nuke.Script_Knob('login', 'Login With Google') self.logoutButton = nuke.Script_Knob('logout', 'Logout') # keep everything on the same line self.logoutButton.clearFlag(nuke.STARTLINE) self.userLabel = nuke.Text_Knob('user_label', '') self.userLabel.setValue(' %s' % self.zync_conn.email) self.userLabel.clearFlag(nuke.STARTLINE) # these buttons must be named okButton and cancelButton for Nuke # to add default OK/Cancel functionality. if named something else, # Nuke will add its own default buttons. self.okButton = nuke.Script_Knob('submit', 'Submit Job') self.cancelButton = nuke.Script_Knob('cancel', 'Cancel') # ADD KNOBS self.addKnob(self.num_slots) self.addKnob(self.instance_type) self.addKnob(self.pricing_label) self.addKnob(calculator_link) self.addKnob(self.__getDivider()) self.addKnob(self.existing_project) self.addKnob(self.new_project) self.addKnob(self.parent_id) if 'shotgun' in self.zync_conn.FEATURES and self.zync_conn.FEATURES['shotgun'] == 1: self.addKnob(self.sg_create_version) self.addKnob(self.sg_user) self.addKnob(self.sg_project) self.addKnob(self.sg_shot) self.addKnob(self.sg_version_code) self.addKnob(self.upload_only) self.addKnob(self.priority) self.addKnob(self.skip_check) self.addKnob(self.frange) self.addKnob(self.fstep) for k in self.writeNodes: self.addKnob(k) self.addKnob(self.chunk_size) self.addKnob(self.__getDivider()) self.addKnob(self.loginButton) self.addKnob(self.logoutButton) self.addKnob(self.userLabel) self.addKnob(self.__getDivider()) self.addKnob(self.okButton) self.addKnob(self.cancelButton) # collect render-specific knobs for iterating on later self.render_knobs = (self.num_slots, self.instance_type, self.frange, self.fstep, self.chunk_size, self.skip_check, self.priority, self.parent_id) if 'shotgun' in self.zync_conn.FEATURES and self.zync_conn.FEATURES['shotgun'] == 1: height = 510 else: height = 410 self.setMinimumSize(600, height) self.update_pricing_label()
raise Exception('Could not locate config_nuke.py, please create.') from config_nuke import * required_config = ['API_DIR', 'API_KEY'] for key in required_config: if not key in globals(): raise Exception('config_nuke.py must define a value for %s.' % (key, )) nuke.pluginAddPath(API_DIR) import zync # Try to connect to ZYNC. If we can't that's fine for now, we'll try # again later when the user tries to launch a job. try: ZYNC = zync.Zync('nuke_plugin', API_KEY) except: ZYNC = None def generate_script_path(extra_name=None): """ Returns a hash-embedded script path with /cloud_submit/ at the end of the path, for separation from user nuke scripts. """ script_path = nuke.root().knob('name').getValue() script_dir = os.path.dirname(script_path) cloud_dir = "/".join([script_dir, 'cloud_submit']) if not os.path.exists(cloud_dir): os.makedirs(cloud_dir)
# # Go two levels up and add that directory to the PATH, so we can find zync.py. # import sys, os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) # # Import ZYNC Python API. # import zync # # Connect to ZYNC. Set up a script & API token via the Admin page in the ZYNC # Web Console. # z = zync.Zync('arnold_launcher', '********************') # # Login with your ZYNC username & password. This will allow you to launch jobs. # z.login(username='******', password='******') # # The path to your Arnold scene. Use a wildcard to indicate multiple files. # scene_path = '/path/to/project/scene.ass' #scene_path = '/path/to/project/scene.*.ass' # # Other job parameters. #