Skip to content
Snippets Groups Projects
Commit 3392bcec authored by Daniel Lyons's avatar Daniel Lyons
Browse files

Add Marshmallow, set up WorkflowEvent schema with it

parent 7a03ac8a
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@ dependencies:
- funcsigs=1.0.2
- jxmlease=1.0
- lxml=4.5
- marshmallow=3.7.1
- mysqlclient=1.4
- paramiko
- pandas=1.0
......
import zope.sqlalchemy
from pycapo import CapoConfig
from pyramid.view import view_config, view_defaults
from pyramid.config import Configurator
from pyramid_beaker import session_factory_from_settings
from pyramid.renderers import JSONP
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from pyramid.view import view_config, view_defaults
from pyramid_beaker import session_factory_from_settings
from workspaces.services import WorkflowInfo, WorkflowService, get_session_factory, get_engine
"""
Work done:
☑ Initial sketch of using SQL Alchemy with Pyramid
☑ Sketch of first routes we need
☑ Bring over interfaces from wksp0 project
☑ Need to flesh out the object model—requests have their own files, workflows have templates
☑ Separate REST hierarchy for workflow definitions
Work to do:
☐ Actually do the work, preferably in model classes, not REST API directly
☐ Separate this into separate modules, once it makes sense to people how it works
☐ Workflow initiation CLI
To consider:
☐ Do we want to use Marshmallow to validate inputs/generate API documentation?
☐ Do we want to have a separate package with interfaces/model? Or perhaps only JSON schemas?
"""
......
......@@ -9,6 +9,7 @@ README = Path('README.md').read_text()
requires = [
'pycapo',
'marshmallow',
'schema',
'sqlalchemy',
]
......
from marshmallow import Schema, fields
class WorkflowEventSchema(Schema):
"""
Default schema for serializing WorkflowEvent.
"""
job_name = fields.String()
type = fields.Method("get_type", deserialize="load_type")
timestamp = fields.DateTime()
log = fields.String()
retval = fields.Integer()
# Enums apparently are not a first-class field type in Marshmallow
def get_type(self, obj: "EventType") -> str:
return obj.type.value
def load_type(self, value: str) -> "EventType":
return EventType[value]
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