llmtuner.store ============== .. py:module:: llmtuner.store .. autoapi-nested-parse:: Storing information on datasets and workflows in local database .. !! processed by numpydoc !! Classes ------- .. autoapisummary:: llmtuner.store.LLMTunerStore Functions --------- .. autoapisummary:: llmtuner.store.map_json_type_to_sqlite Module Contents --------------- .. py:function:: map_json_type_to_sqlite(json_type) .. py:class:: LLMTunerStore(filename='llmtuner.db', datapath='local', keepopen=False) Small DB to hold data sets and processing info for model development .. !! processed by numpydoc !! .. py:attribute:: filename :value: 'llmtuner.db' .. py:attribute:: datapath :value: 'local' .. py:attribute:: keepopen :value: False .. py:attribute:: connection .. py:attribute:: cursor .. py:attribute:: schemas .. py:method:: _open() Open connection to the DB .. !! processed by numpydoc !! .. py:method:: _close(confirm=False) Set confirm = True to force closing of connection .. !! processed by numpydoc !! .. py:method:: _keep_open(keepopen=True) Set to false if connection should be closed after each operation .. !! processed by numpydoc !! .. py:method:: _query_create_table_from_schema(schema, table_name='') :staticmethod: Extract table name and properties .. !! processed by numpydoc !! .. py:method:: _check_metadata_agreement(dictref, dictcomp) :staticmethod: Compare metadata of object .. !! processed by numpydoc !! .. py:method:: format_data_to_sql(schema, data) :staticmethod: Reformat the entries of the dictionary 'data' according to the JSON schema 'schema' to fit into SQL tables. Arrays and objects are converted to JSON strings, and booleans are converted to integers. Parameters: schema (dict): The JSON schema defining the structure and types of 'data'. data (dict): The data dictionary to be formatted. Returns: dict: A new dictionary with the values reformatted according to the schema. .. !! processed by numpydoc !! .. py:method:: list_tables() Return list of available tables .. !! processed by numpydoc !! .. py:method:: get_table_metadata(table_name) Get information for table 'table_name'. Returns dictionary with column names, column info and number of rows. .. !! processed by numpydoc !! .. py:method:: create_table(schema, table_name='') Creates a DB table from a json schema .. !! processed by numpydoc !! .. py:method:: delete_table(table_name) Delete a table with 'table_name' from the database .. !! processed by numpydoc !! .. py:method:: add_data_to_table(table_name, data_dict, uniquekeys=[], update=False, mergekeys=[]) Add data from dictionary to a table in sqlite connection. If 'uniquekey' is provided, the entry is only added if not another entry with the same value for the key is present in the table. If 'update' is True, an existing entry is updated. .. !! processed by numpydoc !! .. py:method:: delete_data_from_table(table_name, key_values={}) Delete data from table, providing a table name and keys and values of entries to delete as dictionary .. !! processed by numpydoc !! .. py:method:: get_data_from_table(table_name, key_values={}, asdicts=False) Getting rows from a table, if key_values = {"column1": "value1"} is passed, only entries matching the criteria are selected. If the column contains arrays, if value is 'select:XXX', only rows with XXX will be selected. .. !! processed by numpydoc !!