Beispiel #1
0
def toolkit_steps_to_obj(job_obj, project_id):
    new_args = {}
    if len(job_obj.steps) > 2:
        args = StepBusiness.get_parameters_step(job_obj.steps).get('args')
        # args = job_obj.steps[2].get("args")
        for arg in args:
            new_args[
                arg['name']] = arg['value'] if arg['value'] else arg['default']

    if StepBusiness.check_fields(job_obj.steps):
        data_fields = StepBusiness.get_fields(job_obj.steps)
    else:
        data_fields = [
            StepBusiness.get_feature_fields(job_obj.steps),
            StepBusiness.get_label_fields(job_obj.steps)
        ]

    obj = {
        "staging_data_set_id": job_obj.steps[0]["args"][0]["value"],
        "conf": {
            "args": new_args,
            "data_fields": data_fields,
            # ["HighAlpha", "Attention_dimension_reduction_PCA_col"]
            #     job_obj.steps[1]["args"][0]["values"],
        },
        "project_id": project_id,
        "toolkit_id": job_obj.toolkit.id,
    }
    return obj
Beispiel #2
0
def save_as_result(job_id, new_sds_name):
    job_obj = job_business.get_by_job_id(job_id)
    result = job_obj.result
    toolkit = job_obj.toolkit
    project_obj = job_obj.project

    sds_id = staging_data_set_business.add(
        name=new_sds_name,
        description='des',
        project=project_obj,
        # job=job_obj
    )

    # 拿到原表
    old_sds = StepBusiness.get_datasource(job_obj.steps)
    table = staging_data_business.get_by_staging_data_set_id(old_sds)

    table_dict = []
    for i in range(len(table)):
        row = table[i].to_mongo().to_dict()
        row.pop("_id")
        row.pop("staging_data_set")
        table_dict.append(row)

    # 复制原表
    staging_data_business.add_many(staging_data_set=sds_id,
                                   data_array=table_dict)

    # 保存结果
    save_result_sub(result, sds_id, toolkit)
Beispiel #3
0
def save_result(job_id):
    job_obj = job_business.get_by_job_id(job_id)
    result = job_obj.result
    toolkit = job_obj.toolkit

    sds_id = StepBusiness.get_datasource(job_obj.steps)
    save_result_sub(result, sds_id, toolkit)
Beispiel #4
0
def add_rows_append(steps):
    target_table_id = StepBusiness.get_step(
        steps, 'target_datasource')['args'][0]['value']
    source_table_id = StepBusiness.get_step(
        steps, 'from_datasource')['args'][0]['value']
    # index = StepBusiness.get_step(steps, 'select_index')['args'][0]['values']
    # added_fields = StepBusiness.get_step(steps, 'from_fields')['args'][0]['values']
    nan_type = StepBusiness.get_step(steps, 'parameters')['args'][0]['value']

    add_rows_append_in(target_table_id, source_table_id)
    return {
        "target_table_id": target_table_id,
        "source_table_id": source_table_id,
        # "index": index,
        # "added_fields": added_fields,
        "nan_type": nan_type
    }