Esempio n. 1
0
    def delete_scenario(self, confirm=True):
        """Deletes scenario on server.

        :param bool confirm: prompt before each batch
        """
        # Delete entry in scenario list
        scenario_id = self._scenario_info["id"]
        self._scenario_list_manager.delete_entry(scenario_id)
        self._execute_list_manager.delete_entry(scenario_id)

        print("--> Deleting scenario input data")
        target = self._data_access.join(*server_setup.INPUT_DIR,
                                        f"{scenario_id}_*")
        self._data_access.remove(target, confirm=confirm)

        print("--> Deleting scenario output data")
        target = self._data_access.join(*server_setup.OUTPUT_DIR,
                                        f"{scenario_id}_*")
        self._data_access.remove(target, confirm=confirm)

        # Delete temporary folder enclosing simulation inputs
        print("--> Deleting temporary folder")
        tmp_dir = self._data_access.tmp_folder(scenario_id)
        self._data_access.remove(f"{tmp_dir}/**", confirm=confirm)

        print("--> Deleting input and output data on local machine")
        local_data_access = LocalDataAccess()
        target = local_data_access.join("data", "**", f"{scenario_id}_*")
        local_data_access.remove(target, confirm=confirm)

        # Delete attributes
        self._clean()
Esempio n. 2
0
def manager():
    test_csv = clone_template()
    data_access = LocalDataAccess()
    manager = ExecuteListManager(data_access)
    manager._FILE_NAME = "ExecuteList.csv.test"
    yield manager
    os.remove(test_csv)
    def get_data_access(make_fs=None):
        """Return a data access instance appropriate for the current
        environment.

        :param callable make_fs: a function that returns a filesystem instance, or
            None to use a default
        :return: (:class:`powersimdata.data_access.data_access.DataAccess`) -- a data access
            instance
        """
        if server_setup.DEPLOYMENT_MODE == DeploymentMode.Server:
            if make_fs is None:
                make_fs = lambda: None  # noqa: E731
            return SSHDataAccess(make_fs())
        return LocalDataAccess()
Esempio n. 4
0
    def get_data_access(data_loc=None):
        """Return a data access instance appropriate for the current
        environment.

        :param str data_loc: pass "disk" if using data from backup disk,
            otherwise leave the default.
        """
        if data_loc == "disk":
            root = server_setup.BACKUP_DATA_ROOT_DIR
        else:
            root = server_setup.DATA_ROOT_DIR

        mode = get_deployment_mode()
        if mode == DeploymentMode.Server:
            return SSHDataAccess(root)
        return LocalDataAccess(root)
Esempio n. 5
0
    def get_data_access(data_loc=None):
        """Return a data access instance appropriate for the current
        environment.

        :param str data_loc: pass "disk" if using data from backup disk,
            otherwise leave the default.
        :return: (:class:`powersimdata.data_access.data_access.DataAccess`) -- a data access
            instance
        """
        if data_loc == "disk":
            root = server_setup.BACKUP_DATA_ROOT_DIR
        else:
            root = server_setup.DATA_ROOT_DIR

        if server_setup.DEPLOYMENT_MODE == DeploymentMode.Server:
            return SSHDataAccess(root)
        return LocalDataAccess(root)