当前位置: 首页>>代码示例>>Python>>正文


Python ProjectManager.cleanUp方法代码示例

本文整理汇总了Python中ilastik.shell.projectManager.ProjectManager.cleanUp方法的典型用法代码示例。如果您正苦于以下问题:Python ProjectManager.cleanUp方法的具体用法?Python ProjectManager.cleanUp怎么用?Python ProjectManager.cleanUp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ilastik.shell.projectManager.ProjectManager的用法示例。


在下文中一共展示了ProjectManager.cleanUp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: HeadlessShell

# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import cleanUp [as 别名]
class HeadlessShell(object):
    """
    For now, this class is just a stand-in for the GUI shell (used when running from the command line).
    """
    
    def __init__(self, workflowClass):
        self._workflowClass = workflowClass
        self.projectManager = None

    @property
    def workflow(self):
        return self.projectManager.workflow

    def createBlankProjectFile(self, projectFilePath):
        hdf5File = ProjectManager.createBlankProjectFile(projectFilePath)
        readOnly = False
        self.projectManager = ProjectManager( self._workflowClass,  headless=True )
        self.projectManager._loadProject(hdf5File, projectFilePath, readOnly)
        
    def openProjectPath(self, projectFilePath):
        try:
            # Open the project file
            hdf5File, readOnly = ProjectManager.openProjectFile(projectFilePath)
            
            # Create our project manager
            # This instantiates the workflow and applies all settings from the project.
            self.projectManager = ProjectManager( self._workflowClass, headless=True )
            self.projectManager._loadProject(hdf5File, projectFilePath, readOnly = False)
            
        except ProjectManager.ProjectVersionError:
            # Couldn't open project.  Try importing it.
            oldProjectFilePath = projectFilePath
            name, ext = os.path.splitext(oldProjectFilePath)
    
            # Create a brand new project file.
            projectFilePath = name + "_imported" + ext
            logger.info("Importing project as '" + projectFilePath + "'")
            hdf5File = ProjectManager.createBlankProjectFile(projectFilePath)

            # Create the project manager.
            # Here, we provide an additional parameter: the path of the project we're importing from. 
            self.projectManager = ProjectManager( self._workflowClass, importFromPath=oldProjectFilePath, headless=True )
            self.projectManager._importProject(importFromPath, hdf5File, projectFilePath,readOnly = False)

    def closeCurrentProject(self):
        self.projectManager._closeCurrentProject()
        self.projectManager.cleanUp()
        self.projectManager = None
开发者ID:bheuer,项目名称:ilastik,代码行数:50,代码来源:headlessShell.py

示例2: HeadlessShell

# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import cleanUp [as 别名]
class HeadlessShell(object):
    """
    For now, this class is just a stand-in for the GUI shell (used when running from the command line).
    """

    def __init__(self, workflow_cmdline_args=None):
        self._workflow_cmdline_args = workflow_cmdline_args or []
        self.projectManager = None

    @property
    def workflow(self):
        return self.projectManager.workflow

    def createAndLoadNewProject(self, newProjectFilePath, workflow_class):
        hdf5File = ProjectManager.createBlankProjectFile(newProjectFilePath)
        readOnly = False
        self.projectManager = ProjectManager(
            self, workflow_class, headless=True, workflow_cmdline_args=self._workflow_cmdline_args
        )
        self.projectManager._loadProject(hdf5File, newProjectFilePath, readOnly)

    def openProjectFile(self, projectFilePath):
        # Make sure all workflow sub-classes have been loaded,
        #  so we can detect the workflow type in the project.
        import ilastik.workflows

        try:
            # Open the project file
            hdf5File, workflow_class, _ = ProjectManager.openProjectFile(projectFilePath)

            if workflow_class is None:
                # If the project file has no known workflow, we assume pixel classification
                import ilastik.workflows

                workflow_class = ilastik.workflows.pixelClassification.PixelClassificationWorkflow
                import warnings

                warnings.warn(
                    "Your project file ({}) does not specify a workflow type.  "
                    "Assuming Pixel Classification".format(projectFilePath)
                )

            # Create our project manager
            # This instantiates the workflow and applies all settings from the project.
            self.projectManager = ProjectManager(
                self, workflow_class, headless=True, workflow_cmdline_args=self._workflow_cmdline_args
            )
            self.projectManager._loadProject(hdf5File, projectFilePath, readOnly=False)

        except ProjectManager.ProjectVersionError:
            # Couldn't open project.  Try importing it.
            oldProjectFilePath = projectFilePath
            name, ext = os.path.splitext(oldProjectFilePath)

            # Create a brand new project file.
            projectFilePath = name + "_imported" + ext
            logger.info("Importing project as '" + projectFilePath + "'")
            hdf5File = ProjectManager.createBlankProjectFile(projectFilePath)

            # For now, we assume that any imported projects are pixel classification workflow projects.
            import ilastik.workflows

            default_workflow = ilastik.workflows.pixelClassification.PixelClassificationWorkflow

            # Create the project manager.
            # Here, we provide an additional parameter: the path of the project we're importing from.
            self.projectManager = ProjectManager(
                self, default_workflow, importFromPath=oldProjectFilePath, headless=True
            )
            self.projectManager._importProject(oldProjectFilePath, hdf5File, projectFilePath, readOnly=False)

    def setAppletEnabled(self, applet, enabled):
        """
        Provided here to satisfy the ShellABC.
        For now, HeadlessShell has no concept of "enabled" or "disabled" applets.
        """
        pass

    def enableProjectChanges(self, enabled):
        """
        Provided here to satisfy the ShellABC.
        For now, HeadlessShell has no mechanism for closing projects.
        """
        pass

    def closeCurrentProject(self):
        self.projectManager._closeCurrentProject()
        self.projectManager.cleanUp()
        self.projectManager = None
开发者ID:JensNRAD,项目名称:ilastik_public,代码行数:91,代码来源:headlessShell.py

示例3: HeadlessShell

# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import cleanUp [as 别名]

#.........这里部分代码省略.........
            url_format = url_format.replace( field, '(?P<' + field + '>[^?/]+)' )

        match = re.match( url_format, dvid_key_url )
        if not match:
            # DVID is the only url-based format we support right now.
            # So if it looks like the user gave a URL that isn't a valid DVID node, then error.
            raise RuntimeError("Invalid URL format for DVID key-value data: {}".format(projectFilePath))

        fields = match.groupdict()            
        projectFilePath = ProjectManager.downloadProjectFromDvid( fields['hostname'],
                                                                  fields['uuid'],
                                                                  fields['kv_instance_name'],
                                                                  fields['keyname'] )
        return projectFilePath
        
    def openProjectFile(self, projectFilePath, force_readonly=False):
        # If the user gave a URL to a DVID key, then download the project file from dvid first.
        # (So far, DVID is the only type of URL access we support for project files.)
        if isUrl(projectFilePath):
            projectFilePath = HeadlessShell.downloadProjectFromDvid(projectFilePath)

        # Make sure all workflow sub-classes have been loaded,
        #  so we can detect the workflow type in the project.
        import ilastik.workflows
        try:
            # Open the project file
            hdf5File, workflow_class, readOnly = ProjectManager.openProjectFile(projectFilePath, force_readonly)

            # If there are any "creation-time" command-line args saved to the project file,
            #  load them so that the workflow can be instantiated with the same settings 
            #  that were used when the project was first created. 
            project_creation_args = []
            if "workflow_cmdline_args" in hdf5File.keys():
                if len(hdf5File["workflow_cmdline_args"]) > 0:
                    project_creation_args = map(str, hdf5File["workflow_cmdline_args"][...])

            if workflow_class is None:
                # If the project file has no known workflow, we assume pixel classification
                import ilastik.workflows
                workflow_class = ilastik.workflows.pixelClassification.PixelClassificationWorkflow
                import warnings
                warnings.warn( "Your project file ({}) does not specify a workflow type.  "
                               "Assuming Pixel Classification".format( projectFilePath ) )            
            
            # Create our project manager
            # This instantiates the workflow and applies all settings from the project.
            self.projectManager = ProjectManager( self,
                                                  workflow_class,
                                                  headless=True,
                                                  workflow_cmdline_args=self._workflow_cmdline_args,
                                                  project_creation_args=project_creation_args )
            self.projectManager._loadProject(hdf5File, projectFilePath, readOnly)

        except ProjectManager.FileMissingError:
            logger.error("Couldn't find project file: {}".format( projectFilePath ))
            raise            
        except ProjectManager.ProjectVersionError:
            # Couldn't open project.  Try importing it.
            oldProjectFilePath = projectFilePath
            name, ext = os.path.splitext(oldProjectFilePath)
    
            # Create a brand new project file.
            projectFilePath = name + "_imported" + ext
            logger.info("Importing project as '" + projectFilePath + "'")
            hdf5File = ProjectManager.createBlankProjectFile(projectFilePath)

            # For now, we assume that any imported projects are pixel classification workflow projects.
            import ilastik.workflows
            default_workflow = ilastik.workflows.pixelClassification.PixelClassificationWorkflow

            # Create the project manager.
            self.projectManager = ProjectManager( self,
                                                  default_workflow,
                                                  headless=True,
                                                  workflow_cmdline_args=self._workflow_cmdline_args,
                                                  project_creation_args=self._workflow_cmdline_args )

            self.projectManager._importProject(importFromPath, hdf5File, projectFilePath)

    def setAppletEnabled(self, applet, enabled):
        """
        Provided here to satisfy the ShellABC.
        For now, HeadlessShell has no concept of "enabled" or "disabled" applets.
        """
        pass

    def isAppletEnabled(self, applet):
        return False

    def enableProjectChanges(self, enabled):
        """
        Provided here to satisfy the ShellABC.
        For now, HeadlessShell has no mechanism for closing projects.
        """
        pass

    def closeCurrentProject(self):
        self.projectManager._closeCurrentProject()
        self.projectManager.cleanUp()
        self.projectManager = None
开发者ID:JaimeIvanCervantes,项目名称:ilastik,代码行数:104,代码来源:headlessShell.py

示例4: HeadlessShell

# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import cleanUp [as 别名]
class HeadlessShell(object):
    """
    For now, this class is just a stand-in for the GUI shell (used when running from the command line).
    """
    
    def __init__(self, workflow_cmdline_args=None):
        self._workflow_cmdline_args = workflow_cmdline_args or []
        self.projectManager = None

    @property
    def workflow(self):
        return self.projectManager.workflow

    def createAndLoadNewProject(self, newProjectFilePath, workflow_class):
        hdf5File = ProjectManager.createBlankProjectFile(newProjectFilePath)
        readOnly = False
        self.projectManager = ProjectManager( workflow_class,
                                              headless=True,
                                              workflow_cmdline_args=self._workflow_cmdline_args  )
        self.projectManager._loadProject(hdf5File, newProjectFilePath, readOnly)
        
    def openProjectFile(self, projectFilePath):
        # Make sure all workflow sub-classes have been loaded,
        #  so we can detect the workflow type in the project.
        import ilastik.workflows
        try:
            # Open the project file
            hdf5File, workflow_class, _ = ProjectManager.openProjectFile(projectFilePath)
            
            # Create our project manager
            # This instantiates the workflow and applies all settings from the project.
            self.projectManager = ProjectManager( workflow_class,
                                                  headless=True,
                                                  workflow_cmdline_args=self._workflow_cmdline_args )
            self.projectManager._loadProject(hdf5File, projectFilePath, readOnly = False)
            
        except ProjectManager.ProjectVersionError:
            # Couldn't open project.  Try importing it.
            oldProjectFilePath = projectFilePath
            name, ext = os.path.splitext(oldProjectFilePath)
    
            # Create a brand new project file.
            projectFilePath = name + "_imported" + ext
            logger.info("Importing project as '" + projectFilePath + "'")
            hdf5File = ProjectManager.createBlankProjectFile(projectFilePath)

            # For now, we assume that any imported projects are pixel classification workflow projects.
            import ilastik.workflows
            default_workflow = ilastik.workflows.pixelClassification.PixelClassificationWorkflow

            # Create the project manager.
            # Here, we provide an additional parameter: the path of the project we're importing from. 
            self.projectManager = ProjectManager( default_workflow,
                                                  importFromPath=oldProjectFilePath,
                                                  headless=True )
            self.projectManager._importProject(oldProjectFilePath, hdf5File, projectFilePath,readOnly = False)

    def closeCurrentProject(self):
        self.projectManager._closeCurrentProject()
        self.projectManager.cleanUp()
        self.projectManager = None
开发者ID:christophdecker,项目名称:ilastik,代码行数:63,代码来源:headlessShell.py


注:本文中的ilastik.shell.projectManager.ProjectManager.cleanUp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。