qme.main.database package¶
Submodules¶
qme.main.database.base module¶
Copyright (C) 2020 Vanessa Sochat.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
class
qme.main.database.base.
Database
[source]¶ Bases:
object
A qme database holds common functions to represent tasks, and results. This is literally the base of the database, so it holds common shared functions to generate a task id or similar. The child classes (the specific database types) should have an init functions that ensures connection or creation of folders is possible.
-
add_task
(executor)[source]¶ Create a filesystem task based on an executor type. The executor controls what data is exported and the uid, the task object just handles saving it.
-
database
= 'notimplemented'¶
-
delete_task
(taskid)[source]¶ delete a task based on a specific task id. All task ids must be in the format of <taskid>-<uid> without extra dashes so we can reliably split based on the first dash.
-
get_task
(taskid=None)[source]¶ Get a task based on a taskid. Exits on error if doesn’t exist. If a task id is not provided, get the last run task.
-
iter_executors
(fullpath=False)[source]¶ list executors based on the subfolders in the base database folder.
-
qme.main.database.filesystem module¶
Copyright (C) 2020 Vanessa Sochat.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
class
qme.main.database.filesystem.
FileSystemDatabase
(config_dir, config=None, **kwargs)[source]¶ Bases:
qme.main.database.base.Database
A FileSystemDatabase writes raw json to files at $HOME/.qme/database This is the default flat database for qme, and on init we ensure that the database folder is created in QME_HOME.
-
add_task
(executor)[source]¶ Create a filesystem task based on an executor type. The executor controls what data is exported and the uid, the task object just handles saving it.
-
database
= 'filesystem'¶
-
delete_task
(taskid)[source]¶ delete a task based on a specific task id. All task ids must be in the format of <taskid>-<uid> without extra dashes so we can reliably split based on the first dash.
-
get_task
(taskid=None)[source]¶ Get a task based on a taskid. Exits on error if doesn’t exist. If a task id is not provided, get the last run task.
-
iter_executors
(fullpath=False)[source]¶ list executors based on the subfolders in the base database folder.
-
-
class
qme.main.database.filesystem.
FileSystemTask
(executor, data_base, exists=False)[source]¶ Bases:
object
A Filesystem Task can take a task id, determine if the task exists, and then interact with the data. If the task is instantiated without a taskid it is assumed to not exist yet, otherwise it must already exist.
-
create
(should_exist=False)[source]¶ create the filename if it doesn’t exist, otherwise if it should (and does not) exit on error.
-
property
executor_dir
¶
-
property
filename
¶
-
qme.main.database.models module¶
Copyright (C) 2020 Vanessa Sochat.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
class
qme.main.database.models.
Task
(taskid=None, executor=None, command=None)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base
An executor task. The id is prefixed with the executor type, and must be unique.
-
command
¶
-
data
¶
-
executor_name
¶
-
run_action
(name, **kwargs)[source]¶ Run an action, meaning that we prepare data to it, and then run the self.executor.run_action(name, data) function.
-
taskid
¶
-
timestamp
¶
-
qme.main.database.relational module¶
Copyright (C) 2020 Vanessa Sochat.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
class
qme.main.database.relational.
RelationalDatabase
(config_dir, config=None, **kwargs)[source]¶ Bases:
qme.main.database.base.Database
A RelationalDatabase is a more robust relational datbase (to sqlite). Since the global database property can be any of postgresql, mysql+pysq;, it is defined on init. The sqlite database also uses this class, but defines a custom init function to handle the $HOME/.qme/qme.db file.
-
add_task
(executor)[source]¶ Create a new task based on an executor type. The executor controls what data is exported and the uid, the task object just handles saving it.
-
create_database
()[source]¶ create the databsae based on the string, whether it’s relational or sqlite. self.db must be defined.
-
delete_task
(taskid)[source]¶ delete a task based on a specific task id. All task ids must be in the format of <taskid>-<uid> without extra dashes so we can reliably split based on the first dash.
-
get_task
(taskid=None)[source]¶ Get a task based on a taskid. Exits on error if doesn’t exist. If a task id is not provided, get the last run task.
-
iter_executors
(fullpath=False)[source]¶ list executors based on the subfolders in the base database folder.
-
qme.main.database.sqlite module¶
Copyright (C) 2020 Vanessa Sochat.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
class
qme.main.database.sqlite.
SqliteDatabase
(config_dir, config=None, **kwargs)[source]¶ Bases:
qme.main.database.relational.RelationalDatabase
A SqliteDatabase writes to a qme.db file in $HOME/.qme. This is the suggested database backend for QueueMe, as it doesn’t require anything beyond a filesystem and still allows for relational type queries.
-
database
= 'sqlite'¶
-
Module contents¶
Copyright (C) 2020 Vanessa Sochat.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
qme.main.database.
init_db
(database, config_dir=None, database_string='', config=None)[source]¶ Initialize the database, meaning a base client and appropriate functions to save, or generate a unique ID based on the backend being used. Each client has it’s own init to check for a connection (or filesystem path existence) and then functions to interact with entities.