From 0536aba4f4c721bcfce9614ccee06a306f184631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 15 Sep 2023 12:19:21 +0900 Subject: [PATCH] wip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- src/openapi/schemas/content.yaml | 10 +++++----- src/openapi/schemas/instruction.yaml | 5 +++-- test/python/test_serialize.py | 24 ++++++++++++++++++------ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/openapi/schemas/content.yaml b/src/openapi/schemas/content.yaml index fdd72fd..184e274 100644 --- a/src/openapi/schemas/content.yaml +++ b/src/openapi/schemas/content.yaml @@ -40,8 +40,7 @@ components: itemContent: $ref: "#/components/schemas/ItemContentUnion" clientEventInfo: - type: object - additionalProperties: true # todo + $ref: "#/components/schemas/ClientEventInfo" feedbackInfo: type: object additionalProperties: true # todo @@ -113,8 +112,7 @@ components: - "itemContent" properties: clientEventInfo: - type: object - additionalProperties: true # todo + $ref: "#/components/schemas/ClientEventInfo" itemContent: $ref: "#/components/schemas/ItemContentUnion" @@ -229,4 +227,6 @@ components: type: string # enum half_cover element: type: string - pattern: "^(january|february|march|april|may|june|july|august|september|october|november|december)-[0-9]{4}-([a-z]-)+[a-z]+$" # august-2023-privacy-prompt-candidate + # august-2023-privacy-prompt-candidate + pattern: "(([a-z]+|[0-9]+|[0-9a-f]+)(-|$))+" + # pattern: "^(january|february|march|april|may|june|july|august|september|october|november|december)-[0-9]{4}-([a-z]-)+[a-z]+$" diff --git a/src/openapi/schemas/instruction.yaml b/src/openapi/schemas/instruction.yaml index 73bb9e6..25a3def 100644 --- a/src/openapi/schemas/instruction.yaml +++ b/src/openapi/schemas/instruction.yaml @@ -267,7 +267,7 @@ components: items: $ref: "#/components/schemas/Callback" clientEventInfo: - $ref: "#/components/schemas/ClientEventInfo" + $ref: "#/components/schemas/CtaClientEventInfo" buttonStyle: type: string enum: ["Primary"] @@ -286,9 +286,10 @@ components: properties: endpoint: type: string + format: uri # pattern: '^/1\.1/[a-z]+/[a-z]+\.json\?[a-z_]+=[a-z0-9-]+(&[a-z_]+=[a-z0-9-]+)+?$' #/1.1/onboarding/fatigue.json?{params} - ClientEventInfo: + CtaClientEventInfo: required: - action properties: diff --git a/test/python/test_serialize.py b/test/python/test_serialize.py index bd7f518..b619e6c 100644 --- a/test/python/test_serialize.py +++ b/test/python/test_serialize.py @@ -8,6 +8,7 @@ import time import glob import aenum import concurrent.futures +import traceback logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)s %(message)s") @@ -106,21 +107,23 @@ def save_cache(data): json.dump(data, f, indent=4) -def task_callback(file): +def task_callback(file, thread=True): try: with open(file, "r") as f: cache = json.load(f) data = pt.__dict__[cache["type"]].from_json(cache["raw"]) rate = match_rate(data.to_dict(), json.loads(cache["raw"])) - return f"Match rate: {rate}" + return {rate}, {file} except Exception as e: - return f"Error: {e} {file}" + if thread: + return 0, {file} + else: + raise def error_dump(e): if ERROR_UNCATCHED: raise - import traceback logger.error("==========[STACK TRACE]==========") for trace in traceback.format_exc().split("\n"): @@ -146,12 +149,21 @@ if __name__ == "__main__": with open("src/config/placeholder.json", "r") as f: placeholder = json.load(f) + fail = [] with concurrent.futures.ProcessPoolExecutor() as executor: tasks = [executor.submit(task_callback, x) for x in glob.glob("cache/*.json")] for task in concurrent.futures.as_completed(tasks): - logger.info(task.result()) + rate, file = [list(x).pop() for x in task.result()] + print(rate, file) + if rate < 1: + fail.append(file) + logger.info(f"Match rate: {rate}") - logger.info(f"Success: {len(glob.glob('cache/*.json'))}") + logger.info(f"Fail: {len(fail)} / {len(glob.glob('cache/*.json'))}") + + for file in fail: + task_callback(file, thread=False) + logger.info(f"Match rate: {rate}") api_conf = pt.Configuration( api_key={