Esempio n. 1
0
    def save_project(self, directory, workspace_to_save=None):
        """
        The method that will actually save the project and call relevant savers for workspaces, plots, interfaces etc.
        :param directory: String; The directory of the
        :param workspace_to_save: List; of Strings that will have workspace names in it, if None will save all
        :return: None; If the method cannot be completed.
        """
        # Check if the directory doesn't exist
        if directory is None:
            logger.warning("Can not save to empty directory")
            return

        # Check this isn't saving a blank project file
        if workspace_to_save is None:
            logger.warning("Can not save an empty project")
            return

        # Save workspaces to that location
        workspace_saver = workspacesaver.WorkspaceSaver(directory=directory)
        workspace_saver.save_workspaces(workspaces_to_save=workspace_to_save)

        # Pass dicts to Project Writer
        writer = ProjectWriter(directory, workspace_saver.get_output_list(),
                               self.project_file_ext)
        writer.write_out()
Esempio n. 2
0
    def test_saving_single_workspace(self):
        ws_saver = workspacesaver.WorkspaceSaver(self.working_directory)
        ws1 = CreateSampleWorkspace()
        ws1_name = "ws1"

        ADS.addOrReplace(ws1_name, ws1)
        ws_saver.save_workspaces([ws1_name])

        list_of_files = listdir(self.working_directory)
        self.assertEqual(len(list_of_files), 1)
        self.assertTrue(ws1_name + ".nxs" in list_of_files)
Esempio n. 3
0
    def test_when_MDWorkspace_is_in_ADS(self):
        ws_saver = workspacesaver.WorkspaceSaver(self.working_directory)
        ws1 = CreateMDHistoWorkspace(SignalInput='1,2,3,4,5,6,7,8,9', ErrorInput='1,1,1,1,1,1,1,1,1',
                                     Dimensionality='2', Extents='-1,1,-1,1', NumberOfBins='3,3', Names='A,B',
                                     Units='U,T')
        ws1_name = "ws1"

        ADS.addOrReplace(ws1_name, ws1)
        ws_saver.save_workspaces([ws1_name])

        list_of_files = listdir(self.working_directory)
        self.assertEqual(len(list_of_files), 1)
        self.assertTrue(ws1_name + ".nxs" in list_of_files)
        self._load_MDWorkspace_and_test_it(ws1_name)
Esempio n. 4
0
    def test_when_nested_workspaces_are_being_saved_from_the_ADS(self, logger):
        CreateSampleWorkspace(OutputWorkspace="ws1")
        CreateSampleWorkspace(OutputWorkspace="ws2")
        CreateSampleWorkspace(OutputWorkspace="ws3")
        CreateSampleWorkspace(OutputWorkspace="ws4")
        GroupWorkspaces(InputWorkspaces="ws1,ws2", OutputWorkspace="group1")
        GroupWorkspaces(InputWorkspaces="ws4,ws3", OutputWorkspace="group2")
        ADS.addToGroup("group2", "group1")
        ws_saver = workspacesaver.WorkspaceSaver(self.working_directory)

        ws_saver.save_workspaces(["group2"])

        self.assertListEqual(["group1", "group2", "ws1", "ws2", "ws3", "ws4"], ADS.getObjectNames())
        logger.warning.assert_called_with(u'Couldn\'t save workspace in project: "group2" because SaveNexusProcessed: '
                                          u'NeXus files do not support nested groups of groups')