seamm_datastore.database package
Submodules
seamm_datastore.database.build module
Automatic import of projects and jobs from directories.
- seamm_datastore.database.build.import_datastore(session, location, as_json=True)[source]
Import all the projects and jobs at <location>.
- Parameters:
session (SQLAlchemy or flask session)
location (str or path) – The location to check for jobs or projects. Usually the projects directory in a datastore.
- Returns:
(n_projects, n_jobs) – The number of projects and jobs added to the database.
- Return type:
int, integer
seamm_datastore.database.models module
Table models for SEAMM datastore SQLAlchemy database.
- class seamm_datastore.database.models.Flowchart(**kwargs)[source]
Bases:
Base
,Resource
- conceptdoi
- creators
- description
- doi
- flowchart_metadata
- flowchart_version
- group
- group_id
- group_permissions
- id
- jobs
- json
- keywords
- other_permissions
- owner
- owner_id
- owner_permissions
- static parse_flowchart_file(path)[source]
Function for parsing information from flowchart
- Parameters:
path (str) – The path to the flowchart.
- Returns:
metadata – A json containing flowchart information to be added to the database.
- Return type:
dict
- projects
- sha256
- sha256_strict
- title
- class seamm_datastore.database.models.Group(**kwargs)[source]
Bases:
Base
- classmethod create(name, users)[source]
Add a project to the database.
- Parameters:
name (str) – The name of the project, used for display and directory name.
users (list) – A list of usernames to add to the group
- Returns:
A Group object
- Return type:
- id
- name
- special_projects
- users
- class seamm_datastore.database.models.GroupProjectAssociation(**kwargs)[source]
Bases:
Base
,PermissionsAssociationMixin
- entity_id
- groups
- permissions
- projects
- resource_id
- class seamm_datastore.database.models.Job(**kwargs)[source]
Bases:
Base
,Resource
- classmethod create(id, flowchart_filename, project_names=['default'], path=None, title='', description='', submitted=None, started=None, finished=None, parameters=None, status='submitted')[source]
Create a new job to add to the datastore.
This method requires a user to be logged in and to have appropriate permissions for the project.
- Parameters:
id (int) – The id of the job, an integer > 0.
flowchart_filename (str or pathlib.Path) – The path to the file containing the flowchart.
project_names ([str]) – A list of projects that the flowchart belongs to.
path (str) – The directory path for the job.
title (str = “”) – The title of the job, used for display.
description (str = “”) – A longer, textual description of the job.
submitted (datetime.datetime = now()) – When the job was submitted as a datetime object. Defaults to now in UTC.
started (datetime.datetime = None) – When the job was started, if it was. Preferably in UTC.
finished (datetime.datetime = None) – When the job finished, if it has. Preferably in UTC.
parameters (dict) – The command-line parameters for the job.
status (str = “submitted”) – The status of the job: “submitted”, “running”, “finished”, “error”, etc.
- Returns:
The json of the job data, or the Job object, depending on “as_json”.
- Return type:
json or Job
- description
- finished
- flowchart
- flowchart_id
- group
- group_id
- group_permissions
- id
- last_update
- other_permissions
- owner
- owner_id
- owner_permissions
- parameters
- path
- projects
- started
- status
- submitted
- title
- class seamm_datastore.database.models.Project(**kwargs)[source]
Bases:
Base
,Resource
- classmethod create(name, description='', path=None, group=None)[source]
Create a project to add to the database.
- Parameters:
name (str) – The name of the project, used for display and directory name.
description (str) – A textual description of the project.
path (str = None) – The path on disk to the project files.
group (str or Group = None) – The group for the project. Defaults to user’s primary group.
- Returns:
A Project object.
- Return type:
- description
- flowcharts
- group
- group_id
- group_permissions
- id
- jobs
- name
- other_permissions
- owner
- owner_id
- owner_permissions
- path
- special_groups
- special_users
- class seamm_datastore.database.models.Resource[source]
- class seamm_datastore.database.models.User(**kwargs)[source]
Bases:
Base
- added
- classmethod create(username, password, first_name=None, last_name=None, email=None, roles=['user'], groups=None)[source]
Create a new user to be added to the database.
- Parameters:
username (str) – The username that identifies the user.
password (str) – The secret password for the user.
first_name (str = None) – The user’s first (given) name.
last_name (str = None) – The user’s last (family) name.
email (str = None) – The user’s principal email address.
roles ([str] = [“user”]) – A list of roles for the user. Defaults to just “user”.
groups ([str] = None) – A list of groups that the user belongs to. Defaults to the first group in the database.
- email
- first_name
- groups
- id
- last_name
- property password
- password_hash
- roles
- special_projects
- status
- username
seamm_datastore.database.schema module
Marshmallow models for serialization and deserialization.
- class seamm_datastore.database.schema.FlowchartSchema(*args, **kwargs)[source]
Bases:
SQLAlchemyAutoSchema
- class Meta[source]
Bases:
object
- exclude = ('json', 'owner_permissions', 'group_permissions', 'other_permissions', 'sha256')
- include_fk = True
- include_relationships = True
- opts: SchemaOpts = <marshmallow_sqlalchemy.schema.SQLAlchemyAutoSchemaOpts object>
- class seamm_datastore.database.schema.GroupSchema(*args, **kwargs)[source]
Bases:
SQLAlchemyAutoSchema
- opts: SchemaOpts = <marshmallow_sqlalchemy.schema.SQLAlchemyAutoSchemaOpts object>
- class seamm_datastore.database.schema.JobSchema(*args, **kwargs)[source]
Bases:
SQLAlchemyAutoSchema
- class Meta[source]
Bases:
object
- exclude = ('flowchart', 'owner_permissions', 'group_permissions', 'other_permissions')
- include_fk = True
- include_relationships = True
- opts: SchemaOpts = <marshmallow_sqlalchemy.schema.SQLAlchemyAutoSchemaOpts object>
- class seamm_datastore.database.schema.LocalDateTime(format: str | None = None, **kwargs)[source]
Bases:
DateTime
- class seamm_datastore.database.schema.ProjectSchema(*args, **kwargs)[source]
Bases:
SQLAlchemyAutoSchema
- class Meta[source]
Bases:
object
- exclude = ('owner_permissions', 'group_permissions', 'other_permissions')
- include_fk = True
- include_relationships = True
- opts: SchemaOpts = <marshmallow_sqlalchemy.schema.SQLAlchemyAutoSchemaOpts object>
- class seamm_datastore.database.schema.RoleSchema(*args, **kwargs)[source]
Bases:
SQLAlchemyAutoSchema
- opts: SchemaOpts = <marshmallow_sqlalchemy.schema.SQLAlchemyAutoSchemaOpts object>