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():
@validate_json
@validate_schema(create_job_schema)
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 fractalis.data.etls.etlhandler 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__)
@data_blueprint.before_request
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):
pass
@validate_json
@validate_schema(create_data_schema)
def create_data():
json = request.get_json(force=True) # pattern enforced by decorators
handler = ETLHandler.factory(json)
job_ids = handler.handle()
session['jobs'].append(job_ids)
return jsonify({'job_ids': job_ids}), 201
@data_blueprint.route('', method=['GET'])
......
......@@ -6,8 +6,6 @@ from fractalis.data.etls.etl import ETL
class ETLHandler(metaclass=abc.ABCMeta):
_etls = []
@property
@abc.abstractmethod
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)
self._etls.append(etl)
async_result = etl.delay(params)
etl_job_ids.append(async_result.id)
return etl_job_ids
@classmethod
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