Ejemplo n.º 1
0
def package_dependencies():
    import core.packagemanager
    manager = core.packagemanager.get_package_manager()

    reg = core.modules.module_registry.get_module_registry()
    conf = get_vistrails_configuration()
    if conf.check("abstractionsDirectory"):
        abstraction_dir = conf.abstractionsDirectory
    p = re.compile(r".*\.xml")
    all_packages = set()
    for abstraction in os.listdir(abstraction_dir):
        if p.match(abstraction):
            abs_fname = os.path.join(abstraction_dir, abstraction)
            try:
                vistrail = read_vistrail(abs_fname)
                dependencies = get_abstraction_dependencies(vistrail)
            except core.modules.module_registry.MissingPackage, e:
                dependencies = {e._identifier: set()}
            add_abstraction = True
            inter_depends = []
            for package, depends in dependencies.iteritems():
                if package != identifier:
                    if not manager.has_package(package):
                        add_abstraction = False
                        break
                else:
                    inter_depends.append(depends)
            if add_abstraction:
                # print 'adding', abstraction[:-4]
                all_packages.update(p for p in dependencies.iterkeys()
                                    if p != identifier)
                vistrails[abstraction[:-4]] = \
                    (vistrail, abs_fname, inter_depends)
            else:
                debug.critical(
                    ("Subworkflow '%s' is missing packages it " + "depends on")
                    % abstraction)
def package_dependencies():
    import core.packagemanager
    manager = core.packagemanager.get_package_manager()

    reg = core.modules.module_registry.get_module_registry()
    conf = get_vistrails_configuration()
    if conf.check("abstractionsDirectory"):
        abstraction_dir = conf.abstractionsDirectory
    p = re.compile(r".*\.xml")
    all_packages = set()
    for abstraction in os.listdir(abstraction_dir):
        if p.match(abstraction):
            abs_fname = os.path.join(abstraction_dir, abstraction)
            try:
                vistrail = read_vistrail(abs_fname)
                dependencies = get_abstraction_dependencies(vistrail)
            except core.modules.module_registry.MissingPackage, e:
                dependencies = {e._identifier: set()}
            add_abstraction = True
            inter_depends = []
            for package, depends in dependencies.iteritems():
                if package != identifier:
                    if not manager.has_package(package):
                        add_abstraction = False
                        break
                else:
                    inter_depends.append(depends)
            if add_abstraction:
                # print 'adding', abstraction[:-4]
                all_packages.update(p for p in dependencies.iterkeys()
                                    if p != identifier)
                vistrails[abstraction[:-4]] = \
                    (vistrail, abs_fname, inter_depends)
            else:
                debug.critical(("Subworkflow '%s' is missing packages it " +
                                "depends on") % abstraction)
def initialize(*args, **kwargs):
    import core.packagemanager
    manager = core.packagemanager.get_package_manager()

    reg = core.modules.module_registry.get_module_registry()
#     conf = get_vistrails_configuration()
#     if conf.check("userPackageDirectory"):
#         if conf.check('userPackageDirectory'):
#             abstraction_dir = os.path.join(conf.userPackageDirectory,
#                                            'abstractions')

#     abs_fnames = []
#     p = re.compile(r".*\.vt")
#     for abstraction in os.listdir(abstraction_dir):
#         if p.match(abstraction):
#             abs_fnames.append(os.path.join(abstraction_dir, abstraction))
    abs_vistrails = vistrails
    last_count = len(vistrails) + 1

    cannot_load = {}
    while len(abs_vistrails) > 0 and len(abs_vistrails) < last_count:
        new_vistrails = {}
        for (abs_name, abs_info) in abs_vistrails.iteritems():
            (abs_vistrail, abs_fname, abs_depends) = abs_info
            packages = get_abstraction_dependencies(abs_vistrail)
            add_abstraction = True
            for package, inter_depends in packages.iteritems():
                if package != identifier:
                    if not manager.has_package(package):
                        add_abstraction = False
                        cannot_load[abs_name] = abs_vistrail
                        break
                else:
                    for descriptor_info in inter_depends:
                        if not reg.has_descriptor_with_name(*descriptor_info):
                            add_abstraction = False
                            new_vistrails[abs_name] = abs_info
                            break
            if add_abstraction:
                abstraction = None
                try:
                    abstraction = \
                        new_abstraction(abs_name, abs_vistrail, abs_fname)
                except InvalidPipeline, e:
                    # handle_invalid_pipeline will raise it's own InvalidPipeline
                    # exception if it fails
                    try:
                        import core.vistrail.controller
                        module_version = abs_vistrail.get_latest_version()
                        # Use a "dummy" controller to handle the upgrade
                        controller = core.vistrail.controller.VistrailController(abs_vistrail)
                        (new_version, new_pipeline) = \
                            controller.handle_invalid_pipeline(e, long(module_version), 
                                                               abs_vistrail, False, True)
                        del controller
                        save_abstraction(abs_vistrail, abs_fname)
                        abstraction = new_abstraction(abs_name, abs_vistrail, abs_fname,
                                                      new_version, new_pipeline)
                    except Exception, _e:
                        cannot_load[abs_name] = (abs_vistrail, _e)
                except Exception, e:
                    cannot_load[abs_name] = (abs_vistrail, e)
                if abstraction is not None:
                    options = {'namespace': abstraction.uuid,
                               'hide_namespace': True,
                               'version': str(abstraction.internal_version)}
                    reg.auto_add_module((abstraction, options))
                    reg.auto_add_ports(abstraction)
                    # print "Added subworkflow", abs_name, abstraction.uuid
                elif abs_name not in cannot_load:
                    cannot_load[abs_name] = (abs_vistrail, '')
Ejemplo n.º 4
0
def initialize(*args, **kwargs):
    import core.packagemanager
    manager = core.packagemanager.get_package_manager()

    reg = core.modules.module_registry.get_module_registry()
    #     conf = get_vistrails_configuration()
    #     if conf.check("userPackageDirectory"):
    #         if conf.check('userPackageDirectory'):
    #             abstraction_dir = os.path.join(conf.userPackageDirectory,
    #                                            'abstractions')

    #     abs_fnames = []
    #     p = re.compile(r".*\.vt")
    #     for abstraction in os.listdir(abstraction_dir):
    #         if p.match(abstraction):
    #             abs_fnames.append(os.path.join(abstraction_dir, abstraction))
    abs_vistrails = vistrails
    last_count = len(vistrails) + 1

    cannot_load = {}
    while len(abs_vistrails) > 0 and len(abs_vistrails) < last_count:
        new_vistrails = {}
        for (abs_name, abs_info) in abs_vistrails.iteritems():
            (abs_vistrail, abs_fname, abs_depends) = abs_info
            packages = get_abstraction_dependencies(abs_vistrail)
            add_abstraction = True
            for package, inter_depends in packages.iteritems():
                if package != identifier:
                    if not manager.has_package(package):
                        add_abstraction = False
                        cannot_load[abs_name] = abs_vistrail
                        break
                else:
                    for descriptor_info in inter_depends:
                        if not reg.has_descriptor_with_name(*descriptor_info):
                            add_abstraction = False
                            new_vistrails[abs_name] = abs_info
                            break
            if add_abstraction:
                abstraction = None
                try:
                    abstraction = \
                        new_abstraction(abs_name, abs_vistrail, abs_fname)
                except InvalidPipeline, e:
                    # handle_invalid_pipeline will raise it's own InvalidPipeline
                    # exception if it fails
                    try:
                        import core.vistrail.controller
                        module_version = abs_vistrail.get_latest_version()
                        # Use a "dummy" controller to handle the upgrade
                        controller = core.vistrail.controller.VistrailController(
                            abs_vistrail)
                        (new_version, new_pipeline) = \
                            controller.handle_invalid_pipeline(e, long(module_version),
                                                               abs_vistrail, False, True)
                        del controller
                        save_abstraction(abs_vistrail, abs_fname)
                        abstraction = new_abstraction(abs_name, abs_vistrail,
                                                      abs_fname, new_version,
                                                      new_pipeline)
                    except Exception, _e:
                        cannot_load[abs_name] = (abs_vistrail, _e)
                except Exception, e:
                    cannot_load[abs_name] = (abs_vistrail, e)
                if abstraction is not None:
                    options = {
                        'namespace': abstraction.uuid,
                        'hide_namespace': True,
                        'version': str(abstraction.internal_version)
                    }
                    reg.auto_add_module((abstraction, options))
                    reg.auto_add_ports(abstraction)
                    # print "Added subworkflow", abs_name, abstraction.uuid
                elif abs_name not in cannot_load:
                    cannot_load[abs_name] = (abs_vistrail, '')