simpleml.orm.initialization
Util module to initialize SimpleML and configure database management
Module Contents
Classes
Base database class to manage dbs with schema tracking. Includes alembic |
|
Base Database class to configure db connection |
|
Hardcoded database mapped to binary storage metadata |
|
SimpleML specific configuration to interact with the database |
|
Hardcoded database mapped to dataset storage metadata |
Attributes
- class simpleml.orm.initialization.AlembicDatabase(alembic_filepath, script_location='migrations', *args, **kwargs)[source]
Bases:
BaseDatabase
Base database class to manage dbs with schema tracking. Includes alembic config references
- Parameters
use_ssh_tunnel – boolean - default false. Whether to tunnel sqlalchemy connection through an ssh tunnel or not
sshtunnel_params – Dict of ssh params - specify according to sshtunnel project https://github.com/pahaz/sshtunnel/ - direct passthrough
- create_tables(self, base, drop_tables=False, ignore_errors=False)[source]
Creates database tables (and potentially drops existing ones). Assumes to be running under a sufficiently privileged user
- Parameters
drop_tables – Whether or not to drop the existing tables first.
- Returns
None
- downgrade(self, revision)[source]
Proxy Method to invoke alembic downgrade command to specified revision Indirectly runs the alembic env.py code
- initialize(self, base_list, upgrade=False, validate=True, **kwargs)[source]
Initialization method to set up database connection and inject session manager
Raises a SimpleML error if database schema is not up to date
- Parameters
drop_tables – Bool, whether to drop existing tables in database
upgrade – Bool, whether to run an upgrade migration after establishing a connection
- Returns
None
- class simpleml.orm.initialization.BaseDatabase(config=None, configuration_section=None, uri=None, use_ssh_tunnel=False, sshtunnel_params=None, **credentials)[source]
Bases:
object
Base Database class to configure db connection Does not assume schema tracking or any other validation
Starting in sqlalchemy 1.4.2, the signature of sqlalchemy.engine.url.URL has changed to an immutable object without an __init__
- Parameters
use_ssh_tunnel (bool) – boolean - default false. Whether to tunnel sqlalchemy connection through an ssh tunnel or not
sshtunnel_params (Optional[Dict[str, Any]]) – Dict of ssh params - specify according to sshtunnel project https://github.com/pahaz/sshtunnel/ - direct passthrough
config (Optional[Dict[str, Any]]) –
configuration_section (Optional[str]) –
uri (Optional[str]) –
- _initialize(self, base, create_tables=False, **kwargs)[source]
Initialization method to set up database connection and inject session manager
- Parameters
create_tables – Bool, whether to create tables in database
drop_tables – Bool, whether to drop existing tables in database
- Returns
None
- create_tables(self, base, drop_tables=False, ignore_errors=False)[source]
Creates database tables (and potentially drops existing ones). Assumes to be running under a sufficiently privileged user
- initialize(self, base_list, **kwargs)[source]
Initialization method to set up database connection and inject session manager
Raises a SimpleML error if database schema is not up to date
- Parameters
drop_tables – Bool, whether to drop existing tables in database
upgrade – Bool, whether to run an upgrade migration after establishing a connection
- Returns
None
- class simpleml.orm.initialization.BinaryStorageDatabase(config=None, configuration_section=None, uri=None, use_ssh_tunnel=False, sshtunnel_params=None, **credentials)[source]
Bases:
BaseDatabase
Hardcoded database mapped to binary storage metadata
- Parameters
use_ssh_tunnel (bool) – boolean - default false. Whether to tunnel sqlalchemy connection through an ssh tunnel or not
sshtunnel_params (Optional[Dict[str, Any]]) – Dict of ssh params - specify according to sshtunnel project https://github.com/pahaz/sshtunnel/ - direct passthrough
config (Optional[Dict[str, Any]]) –
configuration_section (Optional[str]) –
uri (Optional[str]) –
- initialize(self, base_list=None, **kwargs)[source]
Initialization method to set up database connection and inject session manager
Raises a SimpleML error if database schema is not up to date
- Parameters
drop_tables – Bool, whether to drop existing tables in database
upgrade – Bool, whether to run an upgrade migration after establishing a connection
- Returns
None
- class simpleml.orm.initialization.Database(configuration_section=None, uri=None, database=None, username=None, password=None, drivername=None, host=None, port=None, query=None, *args, **kwargs)[source]
Bases:
AlembicDatabase
SimpleML specific configuration to interact with the database Defaults to sqlite db in filestore directory
- Parameters
use_ssh_tunnel – boolean - default false. Whether to tunnel sqlalchemy connection through an ssh tunnel or not
sshtunnel_params – Dict of ssh params - specify according to sshtunnel project https://github.com/pahaz/sshtunnel/ - direct passthrough
- initialize(self, base_list=None, **kwargs)[source]
Initialization method to set up database connection and inject session manager
Raises a SimpleML error if database schema is not up to date
- Parameters
drop_tables – Bool, whether to drop existing tables in database
upgrade – Bool, whether to run an upgrade migration after establishing a connection
- Returns
None
- class simpleml.orm.initialization.DatasetDatabase(config=None, configuration_section=None, uri=None, use_ssh_tunnel=False, sshtunnel_params=None, **credentials)[source]
Bases:
BaseDatabase
Hardcoded database mapped to dataset storage metadata
- Parameters
use_ssh_tunnel (bool) – boolean - default false. Whether to tunnel sqlalchemy connection through an ssh tunnel or not
sshtunnel_params (Optional[Dict[str, Any]]) – Dict of ssh params - specify according to sshtunnel project https://github.com/pahaz/sshtunnel/ - direct passthrough
config (Optional[Dict[str, Any]]) –
configuration_section (Optional[str]) –
uri (Optional[str]) –
- initialize(self, base_list=None, **kwargs)[source]
Initialization method to set up database connection and inject session manager
Raises a SimpleML error if database schema is not up to date
- Parameters
drop_tables – Bool, whether to drop existing tables in database
upgrade – Bool, whether to run an upgrade migration after establishing a connection
- Returns
None