Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
op.name = context.stage.name
op.run_id = context.run_id
op.status = Operation.STATUS_PENDING
session.add(op)
session.commit()
context.operation_id = op.id
try:
context.log.info('Running: %s', op.name)
res = func(context, data, *a, **kw)
op.status = Operation.STATUS_SUCCESS
return res
except Exception as exc:
# this should clear results and tags created by this op
session.rollback()
Event.save(op.id, Event.LEVEL_ERROR, exc=exc)
context.log.exception(exc)
finally:
if op.status == Operation.STATUS_PENDING:
op.status = Operation.STATUS_FAILED
op.ended_at = datetime.utcnow()
session.add(op)
session.commit()
def func_wrapper(context, data, *a, **kw):
op = Operation()
op.crawler = context.crawler.name
op.name = context.stage.name
op.run_id = context.run_id
op.status = Operation.STATUS_PENDING
session.add(op)
session.commit()
context.operation_id = op.id
try:
context.log.info('Running: %s', op.name)
res = func(context, data, *a, **kw)
op.status = Operation.STATUS_SUCCESS
return res
except Exception as exc:
# this should clear results and tags created by this op
session.rollback()
Event.save(op.id, Event.LEVEL_ERROR, exc=exc)
context.log.exception(exc)
finally:
if op.status == Operation.STATUS_PENDING:
def run_migrations_online():
connection = session.bind.connect()
context.configure(connection=connection,
target_metadata=target_metadata,
include_object=ignore_autogen)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
def save(cls, crawler, prev_stage, next_stage, data):
obj = cls()
obj.crawler = crawler.name
obj.prev_stage = prev_stage
obj.next_stage = next_stage
obj.data = data
session.add(obj)
return obj
from __future__ import with_statement
from alembic import context
from memorious.core import session
from memorious.model import Base
config = context.config
config.set_main_option('script_location', '.')
target_metadata = Base.metadata
target_metadata.bind = session.bind
def ignore_autogen(obj, name, type_, reflexted, compare_to):
if type_ == 'table' and name.startswith('tabular_'):
return False
return True
def run_migrations_offline():
url = config.get_main_option("sqlalchemy.url")
context.configure(url=url,
include_object=ignore_autogen)
with context.begin_transaction():
context.run_migrations()