Esempio n. 1
0
def recipe_airflow(request, pk):
    try:
        recipe = request.user.recipe_set.get(pk=pk)
        data = script_to_dag(recipe.slug(), recipe.name, '', [],
                             recipe.get_json(credentials=False)['tasks'])
        response = HttpResponse(data, content_type='application/vnd.jupyter')
        response[
            'Content-Disposition'] = 'attachment; filename=airflow_%s.py' % recipe.slug(
            )
        return response
    except Exception as e:
        messages.error(request, str(e))
        raise (e)
    return HttpResponseRedirect('/recipe/download/%s/' % pk)
Esempio n. 2
0
    def handle(self, *args, **kwargs):

        for script in Script.get_scripts():
            if script.get_open_source():

                print('Writing: %s_dag.py' % script.get_tag())

                with open(
                        '%s/dags/%s_dag.py' %
                    (settings.UI_ROOT, script.get_tag()), 'w') as dag_file:
                    dag_file.write(
                        script_to_dag(script.get_tag(), script.get_name(),
                                      script.get_description(),
                                      script.get_instructions(),
                                      script.get_tasks()))