class ExportJobSchema(Schema): export_id = fields.Integer(attribute="export_job_id") file_path = fields.String(attribute="export_file_path") mark_type = fields.Function(lambda obj: NlpTaskEnum(obj.nlp_task_id).name) # nlp_task_id export_state = fields.Function(lambda obj: StatusEnum(obj.export_job_status).name) project_name = fields.String(attribute="doc_type_name") created_time = fields.String() mark_job_ids = fields.List(fields.Integer(), attribute="export_mark_job_ids")
class MarkTaskSchema(Schema): # type: ignore task_id = fields.Integer(attribute="mark_task_id") doc = fields.Nested(DocSchema) doc_type = fields.Nested({ "doc_type_id": fields.Integer(), "doc_type_name": fields.String(), "doc_type_desc": fields.String(), }) user_task_list = fields.List(fields.Nested(UserTaskSchema)) task_state = fields.Function( lambda obj: StatusEnum(obj.mark_task_status).name) status = fields.Function(lambda obj: not obj.is_deleted) created_time = fields.String() task_result = fields.List(fields.Dict, attribute="mark_task_result")
class UserTaskSchema(Schema): doc = fields.Nested(DocSchema) doc_type = fields.Nested({ "doc_type_id": fields.Integer(), "doc_type_name": fields.String(), "doc_type_desc": fields.String(), }) task_id = fields.Integer(attribute="user_task_id") labeler_id = fields.Integer(attribute="annotator_id") manual_task_id = fields.Integer(attribute="mark_task_id") task_result = fields.List(fields.Dict, attribute="user_task_result") task_state = fields.Function( lambda obj: StatusEnum(obj.user_task_status).name) status = fields.Function(lambda obj: not obj.is_deleted) created_time = fields.String()
class TrainTermTaskSchema(Schema): # type: ignore train_term_id = fields.Integer(attribute="train_term_task_id") train_term_result = fields.Dict() train_term_state = fields.Function( lambda obj: StatusEnum(obj.train_term_status).name) model_train_id = fields.Integer(attribute="train_task_id") doc_term_id = fields.Integer()
class PredictTaskSchema(Schema): doc_type = fields.Nested(DocTypeSchema) doc = fields.Nested(DocSchema) task_id = fields.Integer(attribute="predict_task_id") task_result = fields.Dict(attribute="predict_task_result") task_state = fields.Function( lambda obj: StatusEnum(obj.predict_task_status).name) created_time = fields.DateTime()
class CustomAlgorithmSchema(Schema): custom_id = fields.Integer(attribute="custom_algorithm_id") custom_ip = fields.String(attribute="custom_algorithm_ip") custom_port = fields.Integer(attribute="custom_algorithm_predict_port") custom_evaluate_port = fields.Integer( attribute="custom_algorithm_evaluate_port") custom_name = fields.String(attribute="custom_algorithm_name") custom_id_name = fields.String(attribute="custom_algorithm_alias") custom_desc = fields.String(attribute="custom_algorithm_desc") custom_type = fields.Function( lambda obj: "ner" if obj.nlp_task_id == NlpTaskEnum.extract and obj.preprocess.get( "split_by_sentence", False) else NlpTaskEnum(obj.nlp_task_id).name) custom_state = fields.Function( lambda obj: StatusEnum(obj.custom_algorithm_status).name) custom_config = fields.String(attribute="custom_algorithm_config") created_time = fields.DateTime() preprocess = fields.Dict()
class PredictJobSchema(Schema): doc_type = fields.Nested(DocTypeSchema) task_list = fields.List(fields.Nested(PredictTaskSchema)) extract_job_id = fields.Integer(attribute="predict_job_id") extract_job_name = fields.String(attribute="predict_job_name") extract_job_type = fields.String(attribute="predict_job_type.value") extract_job_state = fields.Function(lambda obj: StatusEnum(obj.predict_job_status).name) extract_job_desc = fields.String(attribute="predict_job_desc") is_batch = fields.Boolean() created_time = fields.DateTime()
class MarkJobSchema(Schema): mark_job_id = fields.Integer() mark_job_name = fields.String() mark_job_type = fields.Function(lambda obj: obj.mark_job_type.value) assign_mode = fields.Function(lambda obj: obj.assign_mode.value) mark_job_state = fields.Function( lambda obj: StatusEnum(obj.mark_job_status).name) mark_job_desc = fields.String() task_list = fields.List(fields.Integer()) created_time = fields.DateTime() assessor_id = fields.Function(lambda obj: obj.reviewer_ids[0] if len(obj.reviewer_ids) > 0 else 0) doc_type = fields.Nested(DocTypeSchema, exclude=('doc_term_list', )) labeler_ids = fields.List(fields.Integer(), attribute='annotator_ids') stats = fields.Nested({ "all": fields.Integer(), "labeled": fields.Integer(), "audited": fields.Integer() })
class TrainTaskSchema(Schema): # type: ignore model_train_id = fields.Integer(attribute="train_task_id") model_train_config = fields.Dict(attribute="train_config") model_train_state = fields.Function( lambda obj: StatusEnum(obj.train_status).name) model_id = fields.Integer(attribute="train_job_id") mark_job_ids = fields.List(fields.Integer()) train_terms = fields.List(fields.Nested(TrainTermTaskSchema)) created_time = fields.DateTime() last_updated_time = fields.DateTime(attribute="updated_time") model_version = fields.String()
class EvaluateTaskSchema(Schema): model_evaluate_id = fields.Integer(attribute="evaluate_task_id") model_evaluate_name = fields.String(attribute="evaluate_task_name") model_evaluate_desc = fields.String(attribute="evaluate_task_desc") model_evaluate_state = fields.Function( lambda obj: StatusEnum(obj.evaluate_task_status).name) model_evaluate_result = fields.Dict(attribute="evaluate_task_result") model_id = fields.Integer(attribute="train_job_id") mark_job_ids = fields.List(fields.Integer()) created_time = fields.DateTime() last_updated_time = fields.DateTime(attribute="updated_time")
class TrainJobSchema(Schema): # type: ignore model_id = fields.Integer(attribute='train_job_id') model_name = fields.String(attribute="train_job_name") model_desc = fields.String(attribute="train_job_desc") status = fields.Function(lambda obj: not obj.is_deleted) doc_type = fields.Nested(DocTypeSchema) created_time = fields.String() model_version = fields.String() train_list = fields.List(fields.Nested(TrainTaskSchema)) model_evaluate = fields.Nested(EvaluateTaskSchema) preprocess = fields.Dict()
class DocTypeSchema(Schema): doc_terms = fields.List(fields.Integer()) doc_term_list = fields.List(fields.Nested(DocTermSchema)) doc_relation_list = fields.List(fields.Nested(EntityDocRelationSchema)) doc_lexicon_list = fields.List(fields.Nested(WordsegDocLexiconSchema), attribute='doc_rules') doc_type_id = fields.Integer() doc_type_name = fields.String() doc_type_desc = fields.String() is_top = fields.Boolean(attribute="is_favorite") created_time = fields.DateTime() group_id = fields.Integer() status = fields.Function(lambda obj: not obj.is_deleted)
class DocSchema(Schema): # type: ignore doc_id = fields.Integer() doc_unique_name = fields.String() doc_raw_name = fields.String() convert_state = fields.Function( lambda obj: StatusEnum(obj.doc_status).name)