示例#1
0
    def start_workflow_create_project_headless(self, workflow_class_tuple,
                                               temp_dir):
        """Tests project file creation via the command line
        Args:
            workflow_class_tuple (tuple): tuple returned from getAvailableWorkflows
              with (workflow_class, workflow_name, workflow_class.workflowDisplayName)
        """
        workflow_class, workflow_name, display_name = workflow_class_tuple
        logger.debug(f"starting {workflow_name}")
        project_file = generate_project_file_name(temp_dir, workflow_name)

        args = [
            "--headless", f"--new_project={project_file}",
            f"--workflow={workflow_name}"
        ]
        # Clear the existing commandline args so it looks like we're starting fresh.
        sys.argv = ["ilastik.py"]
        sys.argv.extend(args)

        # Start up the ilastik.py entry script as if we had launched it from the command line
        parsed_args, workflow_cmdline_args = ilastik_main.parse_known_args()

        shell = ilastik_main.main(parsed_args=parsed_args,
                                  workflow_cmdline_args=workflow_cmdline_args,
                                  init_logging=False)

        shell.closeCurrentProject()

        # now check if the project file has been created:
        assert os.path.exists(
            project_file
        ), f"Project File {project_file} creation not successful"
示例#2
0
    def start_workflow_load_project_headless(self, workflow_class_tuple, temp_dir):
        """Tests opening project files in headless mode via the command line
        Args:
            workflow_class_tuple (tuple): tuple returned from getAvailableWorkflows
              with (workflow_class, workflow_name, workflow_class.workflowDisplayName)
        """
        workflow_class, workflow_name, display_name = workflow_class_tuple
        logger.debug(f'starting {workflow_name}')
        project_file = generate_project_file_name(temp_dir, workflow_name)

        self.create_project_file(workflow_class, project_file)
        assert os.path.exists(project_file), f"Project File {project_file} creation not successful"

        args = [
            '--headless',
            f'--project={project_file}',
        ]
        # Clear the existing commandline args so it looks like we're starting fresh.
        sys.argv = ['ilastik.py']
        sys.argv.extend(args)

        # Start up the ilastik.py entry script as if we had launched it from the command line
        parsed_args, workflow_cmdline_args = ilastik_main.parse_known_args()
        shell = ilastik_main.main(
            parsed_args=parsed_args, workflow_cmdline_args=workflow_cmdline_args, init_logging=False)

        shell.closeCurrentProject()
 def create_test_files():
     tags = vigra.defaultAxistags("zyxc")
     tags['x'].resolution = 1.0
     tags['y'].resolution = 1.0
     tags['z'].resolution = 45.0
     tags['c'].description = 'intensity'
     with h5py.File(test_data_path, 'w') as f:
         f['zeros'] = numpy.zeros( (10, 100, 200, 1), dtype=numpy.uint8 )
         f['zeros'].attrs['axistags'] = tags.toJSON()
     
     import ilastik_main
     parsed_args, workflow_cmdline_args = ilastik_main.parse_known_args()
     parsed_args.new_project = test_project_path
     parsed_args.workflow = "Pixel Classification"
     parsed_args.headless = True
 
     shell = ilastik_main.main(parsed_args, workflow_cmdline_args)    
     data_selection_applet = shell.workflow.dataSelectionApplet
     
     # To configure data selection, start with empty cmdline args and manually fill them in
     data_selection_args, _ = data_selection_applet.parse_known_cmdline_args([])
     data_selection_args.raw_data = [test_data_path + '/zeros']
     
     # Configure 
     data_selection_applet.configure_operator_with_parsed_args(data_selection_args)
     
     shell.projectManager.saveProject()        
     return data_selection_applet
示例#4
0
    def create_test_files():
        tags = vigra.defaultAxistags("zyxc")
        tags['x'].resolution = 1.0
        tags['y'].resolution = 1.0
        tags['z'].resolution = 45.0
        tags['c'].description = 'intensity'
        with h5py.File(test_data_path, 'w') as f:
            f['zeros'] = numpy.zeros((10, 100, 200, 1), dtype=numpy.uint8)
            f['zeros'].attrs['axistags'] = tags.toJSON()

        import ilastik_main
        parsed_args, workflow_cmdline_args = ilastik_main.parse_known_args()
        parsed_args.new_project = test_project_path
        parsed_args.workflow = "Pixel Classification"
        parsed_args.headless = True

        shell = ilastik_main.main(parsed_args, workflow_cmdline_args)
        data_selection_applet = shell.workflow.dataSelectionApplet

        # To configure data selection, start with empty cmdline args and manually fill them in
        data_selection_args, _ = data_selection_applet.parse_known_cmdline_args(
            [])
        data_selection_args.raw_data = [test_data_path + '/zeros']

        # Configure
        data_selection_applet.configure_operator_with_parsed_args(
            data_selection_args)

        shell.projectManager.saveProject()
        return data_selection_applet
 def open_test_files():
     import ilastik_main
     parsed_args, workflow_cmdline_args = ilastik_main.parse_known_args()
     parsed_args.project = test_project_path
     parsed_args.headless = True
 
     shell = ilastik_main.main(parsed_args, workflow_cmdline_args)    
     return shell.workflow.dataSelectionApplet
示例#6
0
    def open_test_files():
        import ilastik_main
        parsed_args, workflow_cmdline_args = ilastik_main.parse_known_args()
        parsed_args.project = test_project_path
        parsed_args.headless = True

        shell = ilastik_main.main(parsed_args, workflow_cmdline_args)
        return shell.workflow.dataSelectionApplet
示例#7
0
def test_133_pc_oc_loading(project_path: pathlib.Path):
    args = ["--headless", f"--project={project_path}"]
    # Clear the existing commandline args so it looks like we're starting fresh.
    sys.argv = ["ilastik.py"]
    sys.argv.extend(args)

    # Start up the ilastik.py entry script as if we had launched it from the command line
    parsed_args, workflow_cmdline_args = ilastik_main.parse_known_args()

    shell = ilastik_main.main(parsed_args=parsed_args,
                              workflow_cmdline_args=workflow_cmdline_args,
                              init_logging=False)

    shell.closeCurrentProject()
示例#8
0
def main():
    if '--clean_paths' in sys.argv:
        script_dir = pathlib.Path(__file__).parent
        ilastik_root = script_dir.parent.parent
        _clean_paths(ilastik_root)

    # Allow to start-up by double-clicking a project file.
    if len(sys.argv) == 2 and sys.argv[1].endswith('.ilp'):
        sys.argv.insert(1, '--project')

    arg_opts, env_vars = _parse_internal_config("internal-startup-options.cfg")
    sys.argv[1:1] = arg_opts
    os.environ.update(env_vars)

    import ilastik_main
    parsed_args, workflow_cmdline_args = ilastik_main.parse_known_args()

    hShell = ilastik_main.main(parsed_args, workflow_cmdline_args)
    # in headless mode the headless shell is returned and its project manager still has an open project file
    hShell.closeCurrentProject()
示例#9
0
def main():
    if '--clean_paths' in sys.argv:
        script_dir = pathlib.Path(__file__).parent
        ilastik_root = script_dir.parent.parent
        _clean_paths(ilastik_root)

    # Allow to start-up by double-clicking a project file.
    if len(sys.argv) == 2 and sys.argv[1].endswith('.ilp'):
        sys.argv.insert(1, '--project')

    arg_opts, env_vars = _parse_internal_config("internal-startup-options.cfg")
    sys.argv[1:1] = arg_opts
    os.environ.update(env_vars)

    import ilastik_main
    parsed_args, workflow_cmdline_args = ilastik_main.parse_known_args()

    hShell = ilastik_main.main(parsed_args, workflow_cmdline_args)
    # in headless mode the headless shell is returned and its project manager still has an open project file
    hShell.closeCurrentProject()