Ejemplo n.º 1
0
    def updateUpstream(self, is_input=None, path_type=None):
        global local_db, db_access

        if is_input is None:
            if not self.hasInputFromPort('value'):
                is_input = True
            else:
                # FIXME: check if the signature is the signature of
                # the value if so we know that it's an input...
                is_input = False

        self.persistent_ref = None
        self.persistent_path = None
        if not is_input:
            # can check updateUpstream
            if not hasattr(self, 'signature'):
                raise ModuleError(self, 'Module has no signature')
            if not self.hasInputFromPort('ref'):
                # create new reference with no name or tags
                ref = PersistentRef()
                ref.signature = self.signature
                debug_print('searching for signature', self.signature)
                sig_ref = db_access.search_by_signature(self.signature)
                debug_print('sig_ref:', sig_ref)
                if sig_ref:
                    debug_print('setting persistent_ref')
                    ref.id, ref.version, ref.name = sig_ref
                    self.persistent_ref = ref
                    #             else:
                    #                 ref.id = uuid.uuid1()
            else:
                # update single port
                self.updateUpstreamPort('ref')
                ref = self.getInputFromPort('ref')
                if db_access.ref_exists(ref.id, ref.version):
                    if ref.version is None:
                        ref.version = self.git_get_latest_version(ref.id)
                    signature = db_access.get_signature(ref.id, ref.version)
                    if signature == self.signature:
                        # don't need to create a new version
                        self.persistent_ref = ref

                # copy as normal
                # don't copy if equal

            # FIXME also need to check that the file actually exists here!
            if self.persistent_ref is not None:
                _, suffix = os.path.splitext(self.persistent_ref.name)
                self.persistent_path = \
                    self.git_get_path(self.persistent_ref.id, 
                                      self.persistent_ref.version,
                                      out_suffix=suffix)
                debug_print("FOUND persistent path")
                debug_print(self.persistent_path)
                debug_print(self.persistent_ref.local_path)

        if self.persistent_ref is None or self.persistent_path is None:
            debug_print("NOT FOUND persistent path")
            Module.updateUpstream(self)
Ejemplo n.º 2
0
    def updateUpstream(self, is_input=None, path_type=None):
        global local_db, db_access

        if is_input is None:
            if not self.hasInputFromPort('value'):
                is_input = True
            else:
                # FIXME: check if the signature is the signature of
                # the value if so we know that it's an input...
                is_input = False

        self.persistent_ref = None
        self.persistent_path = None
        if not is_input:
            # can check updateUpstream
            if not hasattr(self, 'signature'):
                raise ModuleError(self, 'Module has no signature')
            if not self.hasInputFromPort('ref'):
                # create new reference with no name or tags
                ref = PersistentRef()
                ref.signature = self.signature
                debug_print('searching for signature', self.signature)
                sig_ref = db_access.search_by_signature(self.signature)
                debug_print('sig_ref:', sig_ref)
                if sig_ref:
                    debug_print('setting persistent_ref')
                    ref.id, ref.version, ref.name = sig_ref
                    self.persistent_ref = ref
                    #             else:
                    #                 ref.id = uuid.uuid1()
            else:
                # update single port
                self.updateUpstreamPort('ref')
                ref = self.getInputFromPort('ref')
                if db_access.ref_exists(ref.id, ref.version):
                    if ref.version is None:
                        ref.version = self.git_get_latest_version(ref.id)
                    signature = db_access.get_signature(ref.id, ref.version)
                    if signature == self.signature:
                        # don't need to create a new version
                        self.persistent_ref = ref

                # copy as normal
                # don't copy if equal

            # FIXME also need to check that the file actually exists here!
            if self.persistent_ref is not None:
                _, suffix = os.path.splitext(self.persistent_ref.name)
                self.persistent_path = \
                    self.git_get_path(self.persistent_ref.id,
                                      self.persistent_ref.version,
                                      out_suffix=suffix)
                debug_print("FOUND persistent path")
                debug_print(self.persistent_path)
                debug_print(self.persistent_ref.local_path)

        if self.persistent_ref is None or self.persistent_path is None:
            debug_print("NOT FOUND persistent path")
            Module.updateUpstream(self)