Exemplo n.º 1
0
 def get(self, request, modelname):
     """
     Retrieves model information or metadata
     """
     flame_status = manage.action_info(modelname, 0, output='bin')
     if flame_status[0]:
         return Response(flame_status[1], status=status.HTTP_200_OK)
     else:
         return JsonResponse(flame_status[1],
                             status=status.HTTP_404_NOT_FOUND)
Exemplo n.º 2
0
 def get(self, request, modelname, version):
     """
     Retrieve info of model version
     """
     flame_status = manage.action_info(modelname, version, output='bin')
     if flame_status[0]:
         return Response(flame_status[1], status=status.HTTP_200_OK)
     else:
         return JsonResponse(flame_status[1],
                             status=status.HTTP_404_NOT_FOUND)
Exemplo n.º 3
0
 def get(self, request, modelname, version):
     """
     Retrieve info of model version
     """
     flame_status = manage.action_info(modelname, version, output='JSON')
     if flame_status[0]:
         return Response(json.loads(flame_status[1]),
                         status=status.HTTP_200_OK)
     else:
         return JsonResponse({'error': flame_status[1]},
                             status=status.HTTP_404_NOT_FOUND)
Exemplo n.º 4
0
 def get(self, request, modelname):
     """
     Retrieves model information or metadata
     TODO: dont use hardcoded 0 version
     TODO: haandle info errors 
     """
     # TODO: FIX model info and metadata for  whole endpoint in flame
     flame_status = manage.action_info(modelname, 0, output='bin')
     if flame_status[0]:
         return Response(flame_status[1], status=status.HTTP_200_OK)
     else:
         return JsonResponse(flame_status[1],
                             status=status.HTTP_404_NOT_FOUND)
Exemplo n.º 5
0
def manage_cmd(args):
    '''
    Calls diverse model maintenance commands
    '''

    import flame.manage as manage

    version = utils.intver(args.version)

    if args.action == 'new':
        # check if config model repo path is correct
        utils.check_repository_path()
        success, results = manage.action_new(args.endpoint)
    elif args.action == 'kill':
        success, results = manage.action_kill(args.endpoint)
    elif args.action == 'remove':
        success, results = manage.action_remove(args.endpoint, version)
    elif args.action == 'publish':
        success, results = manage.action_publish(args.endpoint)
    elif args.action == 'list':
        success, results = manage.action_list(args.endpoint)
    elif args.action == 'import':
        success, results = manage.action_import(args.infile)
    elif args.action == 'export':
        success, results = manage.action_export(args.endpoint)
    elif args.action == 'refactoring':
        success, results = manage.action_refactoring(args.file)
    elif args.action == 'info':
        success, results = manage.action_info(args.endpoint, version)
    elif args.action == 'results':
        success, results = manage.action_results(args.endpoint, version)
    elif args.action == 'parameters':
        success, results = manage.action_parameters(args.endpoint, version)
    elif args.action == 'dir':
        success, results = manage.action_dir()
    elif args.action == 'report':
        success, results = manage.action_report()
    else:
        success = False
        results = "Specified manage action is not defined"

    return success, results
Exemplo n.º 6
0
    def get(self, request, modelname, version):
        """
        Retrieve info of model version
        """
        # threadNames = [i.name for i in threading.enumerate()]
        # if 'building_'+modelname in threadNames:
        #     return JsonResponse({'waiting': time.ctime(time.time())}, status=status.HTTP_200_OK)

        success, result = manage.action_info(modelname, version, output='bin')
        if success:
            return Response(result, status=status.HTTP_200_OK)
        else:
            if 'code' in result and result['code'] == 0:
                return JsonResponse({'waiting': time.ctime(time.time())},
                                    status=status.HTTP_200_OK)
            if 'code' in result and result['code'] == 1:
                return JsonResponse({'aborted': result['message']},
                                    status=status.HTTP_200_OK)

        return JsonResponse(result, status=status.HTTP_404_NOT_FOUND)
Exemplo n.º 7
0
def manage_cmd(args):
    '''
    Instantiates a Build object to build a model using the given input
    file (training series) and model (name of endpoint, eg. 'CACO2')
    '''

    version = utils.intver(args.version)

    if args.action == 'new':
        # check if config model repo path is correct
        utils.check_repository_path()
        success, results = manage.action_new(args.endpoint)
    elif args.action == 'kill':
        success, results = manage.action_kill(args.endpoint)
    elif args.action == 'remove':
        success, results = manage.action_remove(args.endpoint, version)
    elif args.action == 'publish':
        success, results = manage.action_publish(args.endpoint)
    elif args.action == 'list':
        success, results = manage.action_list(args.endpoint)
    elif args.action == 'import':
        success, results = manage.action_import(args.infile)
    elif args.action == 'export':
        success, results = manage.action_export(args.endpoint)
    elif args.action == 'refactoring':
        success, results = manage.action_refactoring(args.file)
    elif args.action == 'dir':
        success, results = manage.action_dir()
    elif args.action == 'info':
        success, results = manage.action_info(args.endpoint, version)
    elif args.action == 'results':
        success, results = manage.action_results(args.endpoint, version)
    else:
        raise ValueError("Specified action does not exist.")

    print('flame : ', results)
Exemplo n.º 8
0
def manage_cmd(args):
    '''
    Calls diverse model or space maintenance commands
    '''

    version = utils.intver(args.version)

    if args.space is not None or 'searches' in args.action :
    
        import flame.smanage as smanage
    
        if args.action == 'new':
            success, results = smanage.action_new(args.space)
        elif args.action == 'kill':
            success, results = smanage.action_kill(args.space)
        elif args.action == 'remove':
            success, results = smanage.action_remove(args.space, version)
        elif args.action == 'publish':
            success, results = smanage.action_publish(args.space)
        elif args.action == 'list':
            success, results = smanage.action_list(args.space)
        elif args.action == 'parameters':
            success, results = smanage.action_parameters(args.space, version)
        elif args.action == 'info':
            success, results = smanage.action_info(args.space, version)
        elif args.action == 'dir':
            success, results = smanage.action_dir()
        elif args.action == 'searches_result':
            success, results = smanage.action_searches_result(args.label)
        else: 
            success = False
            results = "Specified manage action is not defined"
    else: 

        import flame.manage as manage

        if args.action == 'new':
            success, results = manage.action_new(args.endpoint)
        elif args.action == 'kill':
            success, results = manage.action_kill(args.endpoint)
        elif args.action == 'remove':
            success, results = manage.action_remove(args.endpoint, version)
        elif args.action == 'publish':
            success, results = manage.action_publish(args.endpoint)
        elif args.action == 'list':
            success, results = manage.action_list(args.endpoint)
        elif args.action == 'export':
            success, results = manage.action_export(args.endpoint)
        elif args.action == 'info':
            success, results = manage.action_info(args.endpoint, version)
        elif args.action == 'refresh':
            if args.version == None:
                version = None
            success, results = manage.action_refresh(args.endpoint, version)
        elif args.action == 'series':
            success, results = manage.action_series(args.endpoint, version)         
        elif args.action == 'results':
            success, results = manage.action_results(args.endpoint, version)
        elif args.action == 'parameters':
            success, results = manage.action_parameters(args.endpoint, version)
        elif args.action == 'documentation':
            success, results = manage.action_documentation(args.endpoint,
            version, args.documentation_file)
        elif args.action == 'model_template':
            success, results = manage.action_model_template(args.endpoint, 
            version,  args.documentation_file)
        elif args.action == 'prediction_template':
            success, results = manage.action_prediction_template(args.endpoint, version)
        elif args.action == 'import':
            success, results = manage.action_import(args.infile)
        elif args.action == 'dir':
            success, results = manage.action_dir()
        elif args.action == 'report':
            success, results = manage.action_report()
        elif args.action == 'list':
            success, results = manage.action_list(args.endpoint)
        elif args.action == 'predictions':
            success, results = manage.action_predictions_list()
        elif args.action == 'predictions_result':
            success, results = manage.action_predictions_result(args.label)
        elif args.action == 'predictions_remove':
            success, results = manage.action_predictions_remove(args.label)
        elif args.action == 'label':
            success, results = manage.action_label(args.endpoint, version, args.label)
        else: 
            success = False
            results = "Specified manage action is not defined"

    return success, results
Exemplo n.º 9
0
 def POST(self, model, version, output):
     result = manage.action_info(model, numeric_version(version), output)
     return result[1]