simpleml.utils.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 |
-
class
simpleml.utils.initialization.AlembicDatabase(alembic_filepath, script_location='migrations', *args, **kwargs)[source]¶ Bases:
simpleml.utils.initialization.BaseDatabaseBase 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.utils.initialization.BaseDatabase(config=None, configuration_section=None, uri=None, use_ssh_tunnel=False, sshtunnel_params=None, **credentials)[source]¶ Bases:
sqlalchemy.engine.url.URLBase Database class to configure db connection Does not assume schema tracking or any other validation
- 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, 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
- Parameters
drop_tables – Whether or not to drop the existing tables first.
- Returns
None
-
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.utils.initialization.BinaryStorageDatabase(config=None, configuration_section=None, uri=None, use_ssh_tunnel=False, sshtunnel_params=None, **credentials)[source]¶ Bases:
simpleml.utils.initialization.BaseDatabaseHardcoded database mapped to binary storage metadata
- 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.utils.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:
simpleml.utils.initialization.AlembicDatabaseSimpleML 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.utils.initialization.DatasetDatabase(config=None, configuration_section=None, uri=None, use_ssh_tunnel=False, sshtunnel_params=None, **credentials)[source]¶ Bases:
simpleml.utils.initialization.BaseDatabaseHardcoded database mapped to dataset storage metadata
- 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