def updateCurrentTag(self, name):
     if self.mshptrail.changeTag(self.currentVersion, name, current_user(),
                              current_time()):
         self.setChanged(True)
         return True
     else:
         return False
Ejemplo n.º 2
0
 def updateCurrentTag(self, name):
     if self.mshptrail.changeTag(self.currentVersion, name, current_user(),
                                 current_time()):
         self.setChanged(True)
         return True
     else:
         return False
Ejemplo n.º 3
0
 def moveTag(self, from_version, to_version, name):
     tag = self.mshptrail.getTagForActionId(from_version)
     if tag:
         self.mshptrail.removeTagByActionId(from_version)
         self.mshptrail.addTag(to_version,
                               tag,
                               user=current_user(),
                               date=current_time())
 def createMashupVersion(self, alias_list, quiet=False):
     id = self.id_scope.getNewId('mashup')
     mashup = Mashup(id=id, name="mashup%s"%id, 
                     vtid=self.currentMashup.vtid, 
                     version=self.currentMashup.version, 
                     alias_list=alias_list)
     currVersion = self.mshptrail.addVersion(parent_id=self.currentVersion,
                                             mashup=mashup, 
                                             user=current_user(),
                                             date=current_time())
     self.mshptrail.currentVersion = currVersion
     self.currentMashup = mashup
     #print "created new mashup ", currVersion
     self.setCurrentVersion(currVersion, quiet)
     self.setChanged(True)
     return currVersion
Ejemplo n.º 5
0
 def createMashupVersion(self, alias_list, quiet=False):
     id = self.id_scope.getNewId('mashup')
     mashup = Mashup(id=id,
                     name="mashup%s" % id,
                     vtid=self.currentMashup.vtid,
                     version=self.currentMashup.version,
                     alias_list=alias_list)
     currVersion = self.mshptrail.addVersion(parent_id=self.currentVersion,
                                             mashup=mashup,
                                             user=current_user(),
                                             date=current_time())
     self.mshptrail.currentVersion = currVersion
     self.currentMashup = mashup
     #print "created new mashup ", currVersion
     self.setCurrentVersion(currVersion, quiet)
     self.setChanged(True)
     return currVersion
Ejemplo n.º 6
0
 def getParameterExploration(self):
     """ getParameterExploration() -> string
     Generates an XML string that represents the current
     parameter exploration, and which can be loaded with
     setParameterExploration().
     
     """
     # Construct xml for persisting parameter exploration
     escape_dict = {"'": "'", '"': '"', '\n': '
'}
     timestamp = current_time().strftime('%Y-%m-%d %H:%M:%S')
     # TODO: For now, we use the timestamp as the 'name' - Later, we should set 'name' based on a UI input field
     xml = '\t<paramexp dims="%s" layout="%s" date="%s" name="%s">' % (
         str(self.peWidget.table.label.getCounts()),
         str(self.virtualCell.getConfiguration()[2]), timestamp, timestamp)
     for i in xrange(self.peWidget.table.layout().count()):
         pEditor = self.peWidget.table.layout().itemAt(i).widget()
         if pEditor and type(pEditor) == QParameterSetEditor:
             firstParam = True
             for paramWidget in pEditor.paramWidgets:
                 paramInfo = paramWidget.param
                 interpolator = paramWidget.editor.stackedEditors.currentWidget(
                 )
                 intType = interpolator.exploration_name
                 # Write function tag prior to the first parameter of the function
                 if firstParam:
                     xml += '\n\t\t<function id="%s" alias="%s" name="%s">' % (
                         paramInfo.parent_id, paramInfo.is_alias,
                         pEditor.info[0])
                     firstParam = False
                 # Write parameter tag
                 xml += '\n\t\t\t<param id="%s" dim="%s" interp="%s"' % (
                     paramInfo.id, paramWidget.getDimension(), intType)
                 if intType == 'Linear Interpolation':
                     xml += ' min="%s" max="%s"' % (
                         interpolator.fromEdit.get_value(),
                         interpolator.toEdit.get_value())
                 elif intType == 'List':
                     xml += ' values="%s"' % escape(
                         str(interpolator._str_values), escape_dict)
                 elif intType == 'User-defined Function':
                     xml += ' code="%s"' % escape(interpolator.function,
                                                  escape_dict)
                 xml += '/>'
             xml += '\n\t\t</function>'
     xml += '\n\t</paramexp>'
     return xml
 def getParameterExploration(self):
     """ getParameterExploration() -> string
     Generates an XML string that represents the current
     parameter exploration, and which can be loaded with
     setParameterExploration().
     
     """
     # Construct xml for persisting parameter exploration
     escape_dict = { "'":"&apos;", '"':'&quot;', '\n':'&#xa;' }
     timestamp = current_time().strftime('%Y-%m-%d %H:%M:%S')
     palette = self.get_palette()
     # TODO: For now, we use the timestamp as the 'name' - Later, we should set 'name' based on a UI input field
     xml = '\t<paramexp dims="%s" layout="%s" date="%s" name="%s">' % (str(self.table.label.getCounts()), str(palette.virtual_cell.getConfiguration()[2]), timestamp, timestamp)
     for i in xrange(self.table.layout().count()):
         pEditor = self.table.layout().itemAt(i).widget()
         if pEditor and type(pEditor)==QParameterSetEditor:
             firstParam = True
             for paramWidget in pEditor.paramWidgets:
                 paramInfo = paramWidget.param
                 interpolator = paramWidget.editor.stackedEditors.currentWidget()
                 intType = interpolator.exploration_name
                 # Write function tag prior to the first parameter of the function
                 if firstParam:
                     xml += '\n\t\t<function id="%s" alias="%s" name="%s">' % (paramInfo.parent_id, paramInfo.is_alias, pEditor.info[0])
                     firstParam = False
                 # Write parameter tag
                 xml += '\n\t\t\t<param id="%s" dim="%s" interp="%s"' % (paramInfo.id, paramWidget.getDimension(), intType)
                 if intType in ['Linear Interpolation', 'RGB Interpolation',
                                'HSV Interpolation']:
                     xml += ' min="%s" max="%s"' % (interpolator.fromEdit.get_value(), interpolator.toEdit.get_value())
                 elif intType == 'List':
                     xml += ' values="%s"' % escape(str(interpolator._str_values), escape_dict)
                 elif intType == 'User-defined Function':
                     xml += ' code="%s"' % escape(interpolator.function, escape_dict)
                 xml += '/>'
             xml += '\n\t\t</function>'
     xml += '\n\t</paramexp>'
     return xml
 def moveTag(self, from_version, to_version, name):
     tag = self.mshptrail.getTagForActionId(from_version)
     if tag:
         self.mshptrail.removeTagByActionId(from_version)
         self.mshptrail.addTag(to_version, tag, user=current_user(),
                               date=current_time())
Ejemplo n.º 9
0
    def compute(self, is_input=None, path_type=None):
        global db_access
        if not self.hasInputFromPort('value') and \
                not self.hasInputFromPort('ref'):
            raise ModuleError(self, "Need to specify path or reference")

        if self.persistent_path is not None:
            debug_print('using persistent path')
            ref = self.persistent_ref
            path = self.persistent_path
        elif self.hasInputFromPort('ref'):
            ref = self.getInputFromPort('ref')
            if ref.id is None:
                ref.id = str(uuid.uuid1())
        else:
            # create a new reference
            ref = PersistentRef()
            ref.id = str(uuid.uuid1())

        if self.hasInputFromPort('localPath'):
            ref.local_path = self.getInputFromPort('localPath').name
            if self.hasInputFromPort('readLocal'):
                ref.local_read = self.getInputFromPort('readLocal')
            if self.hasInputFromPort('writeLocal'):
                ref.local_writeback = self.getInputFromPort('writeLocal')

        if is_input is None:
            is_input = False
            if not self.hasInputFromPort('value'):
                is_input = True
            else:
                if ref.local_path and ref.local_read:
                    debug_print('found local path with local read')
                    is_input = True
                # FIXME: check if the signature is the signature of
                # the value if so we know that it's an input...

        # if just reference, pull path from repository (get latest
        # version unless specified as specific version)
        if self.persistent_path is None and not self.hasInputFromPort('value') \
                and is_input and not (ref.local_path and ref.local_read):
            _, suffix = os.path.splitext(ref.name)
            if not db_access.ref_exists(ref.id, ref.version):
                raise ModuleError(self, "Persistent entity '%s' does not "
                                  "exist in the local repository." % ref.id)
            if ref.version is None:
                ref.version = self.git_get_latest_version(ref.id)

            # get specific ref.uuid, ref.version combo
            path = self.git_get_path(ref.id, ref.version, 
                                     out_suffix=suffix)
            
        elif self.persistent_path is None:
            # copy path to persistent directory with uuid as name
            if is_input and ref.local_path and ref.local_read:
                debug_print('using local_path')
                path = ref.local_path
            else:
                path = self.getInputFromPort('value').name
            # this is a static method so we need to add module ourselves
            try:
                new_hash = self.git_compute_hash(path, path_type)
            except ModuleError, e:
                e.module = self
                raise e
            rep_path = os.path.join(local_db, ref.id)
            do_update = True
            if os.path.exists(rep_path):
                old_hash = self.git_get_hash(ref.id, path_type=path_type)
                debug_print('old_hash:', old_hash)
                debug_print('new_hash:', new_hash)
                if old_hash == new_hash:
                    do_update = False
                    
            if do_update:
                debug_print('doing update')
                self.copypath(path, os.path.join(local_db, ref.id))

                # commit (and add to) repository
                # get commit id as version id
                # persist object-hash, commit-version to repository
                version = self.git_add_commit(ref.id)
                ref.version = version

                # write object-hash, commit-version to provenance
                if is_input:
                    signature = new_hash
                else:
                    signature = self.signature
                db_access.write_database({'id': ref.id, 
                                          'name': ref.name, 
                                          'tags': ref.tags, 
                                          'user': current_user(),
                                          'date_created': current_time(),
                                          'date_modified': current_time(),
                                          'content_hash': new_hash,
                                          'version': version, 
                                          'signature': signature,
                                          'type': path_type})
Ejemplo n.º 10
0
    def compute(self, is_input=None, path_type=None):
        global db_access
        if not self.hasInputFromPort('value') and \
                not self.hasInputFromPort('ref'):
            raise ModuleError(self, "Need to specify path or reference")

        if self.persistent_path is not None:
            debug_print('using persistent path')
            ref = self.persistent_ref
            path = self.persistent_path
        elif self.hasInputFromPort('ref'):
            ref = self.getInputFromPort('ref')
            if ref.id is None:
                ref.id = str(uuid.uuid1())
        else:
            # create a new reference
            ref = PersistentRef()
            ref.id = str(uuid.uuid1())

        if self.hasInputFromPort('localPath'):
            ref.local_path = self.getInputFromPort('localPath').name
            if self.hasInputFromPort('readLocal'):
                ref.local_read = self.getInputFromPort('readLocal')
            if self.hasInputFromPort('writeLocal'):
                ref.local_writeback = self.getInputFromPort('writeLocal')

        if is_input is None:
            is_input = False
            if not self.hasInputFromPort('value'):
                is_input = True
            else:
                if ref.local_path and ref.local_read:
                    debug_print('found local path with local read')
                    is_input = True
                # FIXME: check if the signature is the signature of
                # the value if so we know that it's an input...

        # if just reference, pull path from repository (get latest
        # version unless specified as specific version)
        if self.persistent_path is None and not self.hasInputFromPort('value') \
                and is_input and not (ref.local_path and ref.local_read):
            _, suffix = os.path.splitext(ref.name)
            if not db_access.ref_exists(ref.id, ref.version):
                raise ModuleError(
                    self, "Persistent entity '%s' does not "
                    "exist in the local repository." % ref.id)
            if ref.version is None:
                ref.version = self.git_get_latest_version(ref.id)

            # get specific ref.uuid, ref.version combo
            path = self.git_get_path(ref.id, ref.version, out_suffix=suffix)

        elif self.persistent_path is None:
            # copy path to persistent directory with uuid as name
            if is_input and ref.local_path and ref.local_read:
                debug_print('using local_path')
                path = ref.local_path
            else:
                path = self.getInputFromPort('value').name
            # this is a static method so we need to add module ourselves
            try:
                new_hash = self.git_compute_hash(path, path_type)
            except ModuleError, e:
                e.module = self
                raise e
            rep_path = os.path.join(local_db, ref.id)
            do_update = True
            if os.path.exists(rep_path):
                old_hash = self.git_get_hash(ref.id, path_type=path_type)
                debug_print('old_hash:', old_hash)
                debug_print('new_hash:', new_hash)
                if old_hash == new_hash:
                    do_update = False

            if do_update:
                debug_print('doing update')
                self.copypath(path, os.path.join(local_db, ref.id))

                # commit (and add to) repository
                # get commit id as version id
                # persist object-hash, commit-version to repository
                version = self.git_add_commit(ref.id)
                ref.version = version

                # write object-hash, commit-version to provenance
                if is_input:
                    signature = new_hash
                else:
                    signature = self.signature
                db_access.write_database({
                    'id': ref.id,
                    'name': ref.name,
                    'tags': ref.tags,
                    'user': current_user(),
                    'date_created': current_time(),
                    'date_modified': current_time(),
                    'content_hash': new_hash,
                    'version': version,
                    'signature': signature,
                    'type': path_type
                })