Commit 5aec3b12 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

partially implemented POST data controller

parent fd345093
Pipeline #1726 failed with stage
in 1 minute and 16 seconds
......@@ -22,7 +22,7 @@ def prepare_session():
def create_job():
json = request.get_json(force=True)
json = request.get_json(force=True) # pattern enforced by decorators
analytics_job = AnalyticsJob.factory(json['job_name'])
if analytics_job is None:
return jsonify({'error_msg': "Job with name '{}' not found.".format(
from flask import Blueprint, session, request, jsonify
from fractalis import redis
from import ETLHandler
from .etlhandler import ETLHandler
from .schema import create_data_schema
from fractalis.validator import validate_json, validate_schema
data_blueprint = Blueprint('data_blueprint', __name__)
def prepare_session():
session.permanent = True
if 'jobs' not in session:
session['jobs'] = []
@data_blueprint.route('', methods=['POST'])
def create_data(handler, server, token, descriptors):
def create_data():
json = request.get_json(force=True) # pattern enforced by decorators
handler = ETLHandler.factory(json)
job_ids = handler.handle()
return jsonify({'job_ids': job_ids}), 201
@data_blueprint.route('', method=['GET'])
......@@ -6,8 +6,6 @@ from import ETL
class ETLHandler(metaclass=abc.ABCMeta):
_etls = []
def _HANDLER(self):
......@@ -18,14 +16,16 @@ class ETLHandler(metaclass=abc.ABCMeta):
self.__dict__['_' + key] = kwargs[key]
def handle(self):
assert not self._etls
assert self._descriptors
etl_job_ids = []
for descriptor in self._descriptors:
params = copy.deepcopy(vars(self))
del params['_descriptors']
params['_descriptor'] = descriptor
etl = ETL.factory(params)
async_result = etl.delay(params)
return etl_job_ids
def factory(cls, **kwargs):
__all__ = ['handler_transmart', 'etl_hdd', 'etl_ldd']
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment