# -*- coding: utf-8 -*- BASE_DIR = 'base_dir' GPU_CODES = ['3090', '2080', '4090', 'A10'] GPU_NAME = 'gpu_name' GPU_2080 = '2080' GPU_2080_Ti = '2080Ti' KAFKA_ACKS = "acks" KAFKA_RETRIES = "retries" KAFKA_LINGER_MS = "linger_ms" KAFKA_RETRY_BACKOFF_MS = "retry_backoff_ms" KAFKA_MAX_IN_FLIGHT_REQUESTS = "max_in_flight_requests_per_connection" KAFKA_CLIENT_ID = "client_id" KAFKA_GROUP_ID = "group_id" KAFKA_AUTO_OFFSET_RESET = "auto_offset_reset" KAFKA_ENABLE_AUTO_COMMIT = "enable_auto_commit" KAFKA_MAX_POLL_RECORDS = "max_poll_records" REQUEST_IDREQUEST_ID = "request_id" FEEDBACK = "feedback" RECORDING = "recording" FBQUEUE = "fbQueue" CONTEXT = "context" MODEL = 'model' MSG = "msg" GPU_IDS = "gpu_ids" ANALYSE_TYPE = "analyse_type" COMMAND = "command" START = "start" STOP = "stop" SERVICE = "service" FRAME_SCORE = "frame_score" PULL_URL = "pull_url" PUSH_URL = "push_url" ORIGINAL_URL = "original_url" ORIGINAL_TYPE = "original_type" IMAGE_URLS = "image_urls" RESULTS_BASE_DIR = "results_base_dir" MODELS = "models" CODE = 'code' CATEGORIES = "categories" ID = 'id' CONFIG = "config" VIDEO = "video" FILE_PATH = "file_path" KAFKA = "kafka" TOPIC = "topic" DSP_ALG_ONLINE_TASKS_TOPIC = "dsp-alg-online-tasks-topic" DSP_ALG_OFFLINE_TASKS_TOPIC = "dsp-alg-offline-tasks-topic" DSP_ALG_IMAGE_TASKS_TOPI = "dsp-alg-image-tasks-topic" DSP_RECORDING_TASKS_TOPI = "dsp-recording-task-topic" DSP_ALG_RESULTS_TOPIC = "dsp-alg-results-topic" DSP_RECORDING_RESULTS_TOPIC = "dsp-recording-result-topic" DSP = "dsp" ACTIVE = "active" PRODUCER = "producer" CONSUMER = "consumer" BOOTSTRAP_SERVERS = "bootstrap_servers" ALIYUN = "aliyun" ACCESS_KEY = "access_key" ACCESS_SECRET = "access_secret" OSS = "oss" ENDPOINT = "endpoint" BUCKET = "bucket" CONNECT_TIMEOUT = "connect_timeout" VOD = "vod" ECSREGIONID = "ecsRegionId" CATEID = "CateId" GPU = "gpu" ORDER = "order" LIMIT = "limit" MAXLOAD = "maxLoad" MAXMEMORY = "maxMemory" INCLUDENAN = "includeNan" EXCLUDEID = "excludeID" EXCLUDEUUID = "excludeUUID" BAIDU = "baidu" VEHICLE = "vehicle" APP_ID = "APP_ID" API_KEY = "API_KEY" SECRET_KEY = "SECRET_KEY" PERSON = "person" ORC = "orc" LOG = 'log' IS_VIDEO = "is_video" IS_IMAGE = "is_image" # 校验schema规则定义 SCHEMA = { "request_id": { 'type': 'string', 'required': True, 'empty': False, 'regex': r'^[a-zA-Z0-9]{1,36}$' }, COMMAND: { 'type': 'string', 'required': True, 'allowed': [START, STOP] }, PULL_URL: { 'type': 'string', 'required': False, 'nullable': True, 'maxlength': 255 }, PUSH_URL: { 'type': 'string', 'required': False, 'nullable': True, 'maxlength': 255 }, ORIGINAL_URL: { 'type': 'string', 'required': False, 'nullable': True, 'maxlength': 255 }, ORIGINAL_TYPE: { 'type': 'string', 'required': False, 'nullable': True, 'maxlength': 255 }, "logo_url": { 'type': 'string', 'required': False, 'nullable': True, 'maxlength': 255 }, IMAGE_URLS: { 'type': 'list', 'required': False, 'schema': { 'type': 'string', 'empty': False, 'maxlength': 5000 } }, RESULTS_BASE_DIR: { 'type': 'string', 'required': False, 'nullable': True, 'regex': r'^[a-zA-Z0-9]{0,36}$' }, MODELS: { 'type': 'list', 'required': False, 'nullable': True, 'schema': { 'type': 'dict', 'required': True, 'schema': { CODE: { 'type': 'string', 'required': True, 'empty': False, 'dependencies': CATEGORIES, 'regex': r'^[a-zA-Z0-9]{1,255}$' }, IS_VIDEO: { 'type': 'string', 'required': True, 'empty': False, 'dependencies': CODE, 'allowed': ["0", "1"] }, IS_IMAGE: { 'type': 'string', 'required': True, 'empty': False, 'dependencies': CODE, 'allowed': ["0", "1"] }, CATEGORIES: { 'type': 'list', 'required': True, 'dependencies': CODE, 'schema': { 'type': 'dict', 'required': True, 'schema': { ID: { 'type': 'string', 'required': True, 'empty': False, 'regex': r'^[a-zA-Z0-9]{0,255}$'}, CONFIG: { 'type': 'dict', 'required': False, 'dependencies': ID, } } } } } } } } def get_file_path(context): return context[VIDEO][FILE_PATH] def get_video_add_water(context): return context[VIDEO]["video_add_water"] def get_online_tasks_topic(context): return context["kafka"]["topic"]["dsp-alg-online-tasks-topic"] def get_offline_tasks_topic(context): return context[KAFKA][TOPIC][DSP_ALG_OFFLINE_TASKS_TOPIC] def get_image_tasks_topic(context): return context[KAFKA][TOPIC][DSP_ALG_IMAGE_TASKS_TOPI] def get_recording_tasks_topic(context): return context[KAFKA][TOPIC][DSP_RECORDING_TASKS_TOPI] def get_kafka_producer_config(context): return context[KAFKA][context[DSP][ACTIVE]][PRODUCER] def get_kafka_consumer_config(context): return context[KAFKA][context[DSP][ACTIVE]][CONSUMER] def get_kafka_bootstrap_servers(context): return context[KAFKA][context[DSP][ACTIVE]][BOOTSTRAP_SERVERS] def get_kafka_results_topic(context): return context[KAFKA][TOPIC][DSP_ALG_RESULTS_TOPIC] def get_kafka_recording_result_topic(context): return context[KAFKA][TOPIC][DSP_RECORDING_RESULTS_TOPIC] def get_aliyun_access_key(context): return context[ALIYUN][ACCESS_KEY] def get_aliyun_access_secret(context): return context[ALIYUN][ACCESS_SECRET] def get_aliyun_oss_endpoint(context): return context[ALIYUN][OSS][ENDPOINT] def get_aliyun_oss_bucket(context): return context[ALIYUN][OSS][BUCKET] def get_aliyun_oss_connect_timeout(context): return context[ALIYUN][OSS][CONNECT_TIMEOUT] def get_aliyun_vod_ecsRegionId(context): return context[ALIYUN][VOD][ECSREGIONID] def get_aliyun_vod_cateId(context): return context[ALIYUN][VOD][context[DSP][ACTIVE]][CATEID] def get_gpu_order(context): return context[GPU][ORDER] def get_gpu_limit(context): return context[GPU][LIMIT] def get_gpu_maxLoad(context): return context[GPU][MAXLOAD] def get_gpu_maxMemory(context): return context[GPU][MAXMEMORY] def get_gpu_includeNan(context): return context[GPU][INCLUDENAN] def get_gpu_excludeID(context): return context[GPU][EXCLUDEID] def get_gpu_excludeUUID(context): return context[GPU][EXCLUDEUUID] def get_baidu_vehicle_APP_ID(context): return context[BAIDU][VEHICLE][APP_ID] def get_baidu_vehicle_API_KEY(context): return context[BAIDU][VEHICLE][API_KEY] def get_baidu_vehicle_SECRET_KEY(context): return context[BAIDU][VEHICLE][SECRET_KEY] def get_baidu_person_APP_ID(context): return context[BAIDU][PERSON][APP_ID] def get_baidu_person_API_KEY(context): return context[BAIDU][PERSON][API_KEY] def get_baidu_person_SECRET_KEY(context): return context[BAIDU][PERSON][SECRET_KEY] def get_baidu_ocr_APP_ID(context): return context[BAIDU][ORC][APP_ID] def get_baidu_ocr_API_KEY(context): return context[BAIDU][ORC][API_KEY] def get_baidu_ocr_SECRET_KEY(context): return context[BAIDU][ORC][SECRET_KEY] def get_log_base_path(context): return context[LOG]["base_path"] def get_log_enable_file(context): return context[LOG]["enable_file_log"] def get_log_log_name(context): return context[LOG]["log_name"] def get_log_rotation(context): return context[LOG]["rotation"] def get_log_retention(context): return context[LOG]["retention"] def get_log_log_fmt(context): return context[LOG]["log_fmt"] def get_log_level(context): return context[LOG]["level"] def get_log_enqueue(context): return context[LOG]["enqueue"] def get_log_encoding(context): return context[LOG]["encoding"] def get_log_enable_stderr(context): return context[LOG]["enable_stderr"] CV2_PULL_STREAM_TIMEOUT = "cv2_pull_stream_timeout" CV2_READ_STREAM_TIMEOUT = "cv2_read_stream_timeout" def get_pull_stream_timeout(context): return int(context[SERVICE][CV2_PULL_STREAM_TIMEOUT]) def get_read_stream_timeout(context): return int(context[SERVICE][CV2_READ_STREAM_TIMEOUT]) def get_service_timeout(context): return int(context[SERVICE]["timeout"]) FILTER = "filter" def get_similarity(context): return context[SERVICE][FILTER]["similarity"] def get_picture_similarity(context): return context[SERVICE][FILTER]["picture_similarity"] def get_frame_step(context): return int(context[SERVICE][FILTER]["frame_step"])