Skip to content
Snippets Groups Projects
Commit 390eff57 authored by Nathan Hertz's avatar Nathan Hertz
Browse files

Added prototype implementations of the persistent classes that will be

present in the archive eventually
parent 4a1634eb
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,9 @@ from sqlalchemy import create_engine
from sqlalchemy.orm import relationship, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from workspaces.interfaces import CapabilityIF, CapabilityName, \
ProductLocator, CapabilityRequestIF, ParameterIF, CapabilityQueueIF
class AbstractFile:
"""
......@@ -94,10 +97,80 @@ class WorkflowEvent:
self.retval == other.retval
Base = declarative_base()
class Capability(Base, CapabilityIF):
"""
A capability, which is a particular workflow setup, intended to accept
a certain kind of product and some parameters and produce another product
FIXME: Needs to pull workflow steps, capability info, capability params, etc. from database
"""
__tablename__ = 'capabilities'
capability_name = sa.Column('capability_name', sa.String, primary_key=True)
max_jobs = sa.Column('max_jobs', sa.Integer)
def __init__(self, name: CapabilityName, max_jobs: int, locators: List[ProductLocator]):
self.name = name
self.max_jobs = max_jobs
self.locators = locators
self.request = self.create_request(self.locators)
def create_request(self, locators: List[ProductLocator]) -> CapabilityRequestIF:
# FIXME: Fill in correct parameter details
return CapabilityRequest(
capability=self,
locators=locators,
id=None,
parameters=[],
files=[],
versions=[],
tickets=[],
queue=None
)
class CapabilityRequest(Base, CapabilityRequestIF):
"""
A capability request, which couples a capability to a product, representing
the expectation of a new product given a set of parameters
"""
id = sa.Column('request_id', sa.Integer, primary_key=True)
capability = sa.Column(
'capability_name',
sa.String,
sa.ForeignKey('capabilities.capability_name')
)
locators = sa.Column('product_locators', sa.String)
# FIXME: Should this be type JSON or type String or even some other type
parameters = sa.Column('parameters', sa.JSON)
files = sa.Column('files', sa.String)
versions = sa.Column('versions', sa.String)
# FIXME: 'tickets' table does not currently exist
tickets = sa.Column('tickets', sa.String, sa.ForeignKey('tickets.ticket_name'))
# FIXME: There might be a way to reduce the number of params here, which would be great
def __init__(
self,
capability: CapabilityIF,
locators: List[ProductLocator],
parameters: List[ParameterIF],
files: List[Path],
versions: List[str],
tickets: List[Ticket],
queue: CapabilityQueueIF,
id: int = None,
):
self.capability = capability
self.locators = locators
self.parameters = parameters
self.files = files
self.versions = versions
self.tickets = tickets
self.queue = queue
self.id = id
class Workflow(Base):
"""
A Workflow is a suite of tasks defined by templates that must be
......@@ -105,8 +178,8 @@ class Workflow(Base):
"""
__tablename__ = 'workflows'
workflow_name = sa.Column('workflow_name', sa.String, primary_key=True)
templates = relationship('WorkflowTemplate', backref='workflow')
requests = relationship('WorkflowRequest', backref='workflow')
templates = relationship('WorkflowTemplate', backref='workflows')
requests = relationship('WorkflowRequest', backref='workflows')
def __json__(self, request):
return {'workflow_name': self.workflow_name, 'templates': self.templates}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment