dvc.core package#
Subpackages#
Submodules#
dvc.core.config module#
- class dvc.core.config.ConfigDefault[source]#
Bases:
object
- KEY__DATABASE_REVISION_SQL_FILES_FOLDER = 'DVC__DATABASE_REVISION_SQL_FILES_FOLDER'#
- KEY__DBFLAVOUR = 'DVC__DBFLAVOUR'#
- KEY__DBNAME = 'DVC__DBNAME'#
- KEY__HOST = 'DVC__HOST'#
- KEY__PASSWORD = 'DVC__PASSWORD'#
- KEY__PORT = 'DVC__PORT'#
- KEY__USER = 'DVC__USER'#
- VAL__DATABASE_REVISION_SQL_FILES_FOLDER = 'sample_revision_sql_files'#
- VAL__DBFLAVOUR = 'postgres'#
- VAL__DBNAME = ''#
- VAL__FILE_PATH: pathlib.Path = PosixPath('config.yaml')#
- VAL__FilE_NAME: str = 'config.yaml'#
- VAL__HOST = ''#
- VAL__PASSWORD = ''#
- VAL__PORT = 5432#
- VAL__USER = ''#
- class dvc.core.config.ConfigFileWriter(config_file_path: pathlib.Path = PosixPath('config.yaml'))[source]#
Bases:
object
Read Config Files (in different formats) to Python Dictionary
- class dvc.core.config.ConfigReader(config_file_path: pathlib.Path = PosixPath('config.yaml'))[source]#
Bases:
object
Read Config (in different formats) to Python Dictionary
Precedence in descending order 1. Config File 2. Environment Variable
- property requested_db_flavour: str#
Read requested_db_flavour from user_config
- property user_config: Dict#
Initialise user config
Precedence in descending order 1. Config File 2. Environment Variable
- class dvc.core.config.DatabaseConnectionFactory(config_reader: dvc.core.config.ConfigReader)[source]#
Bases:
object
Return connections for various databases
- MAPPING = {SupportedDatabaseFlavour.Postgres: 'self.pgconn'}#
- property conn: psycopg2.extensions.connection#
Return the expected connection object for different database flavours :return:
- property pgconn: psycopg2.extensions.connection#
Return Postgres Database Connection
- Returns
- validate_requested_database_flavour() dvc.core.database.SupportedDatabaseFlavour [source]#
Validate if requested database flavour is supported
- Returns
- class dvc.core.config.DatabaseRevisionFilesManager(config_file_reader: dvc.core.config.ConfigReader)[source]#
Bases:
object
Manager all Database Revision Files
- property all_database_revision_files: List[dvc.core.struct.DatabaseRevisionFile]#
Return all the available database revision files :return:
- property database_revision_files_folder: pathlib.Path#
- get_target_database_revision_files_by_pointer(current_database_version: dvc.core.struct.DatabaseVersion, candidate_database_revision_files: List[dvc.core.struct.DatabaseRevisionFile], pointer: dvc.core.config.DatabaseRevisionFilesManager.Pointer)[source]#
Given current database version and pointer, filter for target database revision files in the folder
- Parameters
current_database_version –
candidate_database_revision_files –
- Returns
- get_target_database_revision_files_by_steps(current_database_version: dvc.core.struct.DatabaseVersion, steps: int, candidate_database_revision_files: List[dvc.core.struct.DatabaseRevisionFile]) List[dvc.core.struct.DatabaseRevisionFile] [source]#
Given current database version and number of steps, filter for target database revision files in the folder.
- Returns
dvc.core.exception module#
- exception dvc.core.exception.DatabaseConnectionFailureException[source]#
Bases:
Exception
Exception raised when connection to the database fails
- exception dvc.core.exception.EnvironmentVariableNotSetException(missing_env_var: str)[source]#
Bases:
Exception
Exception raised when required environment variables are not found
- exception dvc.core.exception.InvalidDatabaseRevisionFilesException(status: dvc.core.exception.InvalidDatabaseRevisionFilesException.Status, config_file_path: Optional[pathlib.Path], database_revision_file_paths: List[pathlib.Path])[source]#
Bases:
Exception
Exception Raised when something is wrong with the DatabaseRevisionFiles
- class Status(value)[source]#
Bases:
enum.Enum
List of all reasons
- FEWER_REVISION_SQL_FILES_FOUND_THAN_REQUIRED_STEPS_SPECIFIED = 103#
- MORE_REVISION_SQL_FILES_FOUND_THAN_REQUIRED_STEPS_SPECIFIED = 102#
- NONCONSECUTIVE_REVISION_SQL_FILES_FOR_HEAD_OR_BASE_POINTER = 104#
- NON_CONFORMANT_REVISION_FILE_NAME_EXISTS = 101#
- exception dvc.core.exception.InvalidDatabaseVersionException(database_version: str)[source]#
Bases:
Exception
Exception raised when format of Database Version is wrong
dvc.core.file module#
dvc.core.hash module#
dvc.core.regex module#
- dvc.core.regex.get_matched_files_in_folder_by_regex(folder_path: pathlib.Path, file_name_regex: str) List[pathlib.Path] [source]#
Loop recursively for all files in a given folder. Return those files whose name satisfy the regex.
- Parameters
folder_path – Path pointing tothe folder with files
file_name_regex – regex used to filter for files with the desired file name
- Returns
dvc.core.struct module#
- class dvc.core.struct.DatabaseRevisionFile(file_path: pathlib.Path)[source]#
Bases:
object
Raise error when File Path does not conform to standard
- STANDARD_RV_FILE_FORMAT_REGEX = '^RV[0-9]+__.*\\.(upgrade|downgrade)\\.sql$'#
- property description: str#
Get the file description
- Returns
- property ending: str#
Get the file ending
- Returns
- classmethod get_dummy_revision_file(revision: str, operation_type: dvc.core.struct.Operation) dvc.core.struct.DatabaseRevisionFile [source]#
Return a dummy revision file
- Parameters
revision –
operation_type –
- Returns
- property operation_type: dvc.core.struct.Operation#
Get the operation type
- Returns
- property revision_number: int#
Get the revision number
- Returns
- class dvc.core.struct.DatabaseVersion(version: str, created_at: Optional[datetime.datetime] = None)[source]#
Bases:
object
- STANDARD_DATABASE_VERSION_FORMAT_REGEX = '^V[0-9]+$'#
- property created_at#
- property next_downgrade_database_revision_file: dvc.core.struct.DatabaseRevisionFile#
Get the database revision file for downgrade :return:
- property next_upgrade_database_revision_file: dvc.core.struct.DatabaseRevisionFile#
Get the database revision file for upgrade :return:
- property version#
- property version_number: int#