def test_houdini_factory_calls_constructor(self, mock_data_block):
     db.for_houdini()
     mock_data_block.assert_called_with(product="houdini", force=False)
     db.for_houdini(force=True)
     mock_data_block.assert_called_with(product="houdini", force=True)
     # Use self in this test in order to keep codacy quiet.
     self.assertTrue(True)
 def test_houdini_factory_calls_constructor(
         self, mock_data_block):
     db.for_houdini()
     mock_data_block.assert_called_with(product="houdini", force=False)
     db.for_houdini(force=True)
     mock_data_block.assert_called_with(product="houdini", force=True)
     # Use self in this test in order to keep codacy quiet.
     self.assertTrue(True)
def get_package_tree():
    """Get the package tree object from shared data.

    Note, the product keyword is only used when the
    singleton is first instantiated. Its probably redundant
    here.
    """
    return data_block.for_houdini().package_tree()
Example #4
0
def force_update(node, **_):
    """Update was called from the job node UI."""
    db = data_block.for_houdini(force=True)

    for job in _all_job_nodes():
        _update_job_node(job)

    for submitter in _all_submitter_nodes():
        _update_submitter_node(submitter)
Example #5
0
def populate_menu(node):
    """Populate instance type menu.

    Get list of items from the shared data_block where they have been
    cached. The menu needs a flat array: [k, v, k, v ....]
    """
    instance_types = data_block.for_houdini().instance_types()
    selected = node.parm('machine_type').eval()
    if selected not in (_to_menu_item(item)[0] for item in instance_types):
        node.parm('machine_type').set(_to_menu_item(instance_types[0])[0])

    return [k for i in instance_types for k in _to_menu_item(i)]
def has_valid_project(node):
    """Is the project is valid.

    This will be false if the project is set to Not Set, or
    if for some reason it is set to a project name that is
    no longer in the list from Conductor, which could occur
    if a project has been deleted.
    """
    projects = data_block.for_houdini().projects()
    selected = node.parm('project').eval()
    return not (selected == "notset" or selected not in (
        project["id"] for project in projects))
Example #7
0
def has_valid_project(node):
    """Is the project is valid.

    This will be false if the project is set to Not Set, or
    if for some reason it is set to a project name that is
    no longer in the list from Conductor, which could occur
    if a project has been deleted.
    """
    projects = data_block.for_houdini().projects()
    selected = node.parm('project').eval()
    return not (selected == "notset"
                or selected not in (project["id"] for project in projects))
def populate_menu(node):
    """Populate project menu.

    Get list of items from the shared data_block where they
    have been cached. The menu needs a flat array: [k, v, k,
    v ....]
    """
    projects = data_block.for_houdini().projects()
    selected = node.parm('project').eval()
    if selected not in (project["id"] for project in projects):
        node.parm('project').set(projects[0]["id"])
    res = [k for i in projects for k in (i["id"], i["name"])]
    return res
    def _get_project(self):
        """Get the project name by looking up its ID.

        In case the current project is no longer in the list
        of projects, throw an error.
        """
        project_id = self._node.parm('project').eval()
        projects = data_block.for_houdini().projects()
        project_names = [project["name"]
                         for project in projects if project['id'] == project_id]
        if not project_names:
            raise hou.InvalidInput(
                "%s %s is an invalid project." %
                self._node.name(), project_id)
        return {
            "id": project_id,
            "name": project_names[0]
        }
Example #10
0
    def _get_instance(self):
        """Get everything related to the instance.

        Get the machine type, preemptible flag, and number of retries if
        preemptible. We use the key from the instance_type menu and look
        up the machine spec in the shared data where the full list of
        instance_types is stored.
        """
        result = {
            "preemptible": bool(self._node.parm('preemptible').eval()),
            "retries": self._node.parm("retries").eval()
        }
        flavor, cores = self._node.parm(
            'machine_type').eval().split("_")

        instance_types = data_block.for_houdini().instance_types()
        found = [it for it in instance_types if it['cores'] ==
                 int(cores) and it['flavor'] == flavor]
        if found:
            result.update(found[0])

        return result
 def test_houdini_factory_method(self):
     db.ConductorDataBlock.clear()
     d = db.for_houdini()
     self.assertIsInstance(d, db.ConductorDataBlock)
 def test_houdini_factory_method(self):
     db.ConductorDataBlock.clear()
     d = db.for_houdini()
     self.assertIsInstance(d, db.ConductorDataBlock)