chore: sync deploy/warehouse_datahub_sync_draft.json

This commit is contained in:
admin committed 2026-11-24 17:18:12 +00:00
1 parent 16f16822a0
commit 828e13f007
1 file changed
+1 -1
+1 -1
View File
@@ -1 +1 @@
{"graph":{"nodes":[{"id":"9100000000001","type":"custom","position":{"x":40,"y":260},"positionAbsolute":{"x":40,"y":260},"width":242,"height":108,"selected":false,"sourcePosition":"right","targetPosition":"left","data":{"type":"start","title":"开始","desc":"","selected":false,"variables":[{"type":"text-input","variable":"force","label":"force(填true强制全量重同步)","required":false,"options":[],"default":"","hint":"","placeholder":""}]}},{"id":"9100000000002","type":"custom","position":{"x":340,"y":260},"positionAbsolute":{"x":340,"y":260},"width":242,"height":220,"selected":false,"sourcePosition":"right","targetPosition":"left","data":{"type":"code","title":"采集数仓指纹","desc":"","code_language":"python3","code":"import requests, json, hashlib, base64\n\nGITEA = \"http://gitea:3000\"\nREPO = \"admin/mini-erp-fabric-demo\"\nGH = {\"Authorization\": \"token 77c6bd2fdab535b2720821d36b4cfb74aa3bf87c\"}\n\ndef sha256(s):\n return hashlib.sha256(s.encode(\"utf-8\")).hexdigest()\n\ndef raw(path):\n r = requests.get(GITEA + \"/\" + REPO + \"/raw/branch/main/\" + path, headers=GH, timeout=20)\n return r.text if r.status_code == 200 else \"\"\n\ndef main(force: str):\n tables = json.loads(raw(\"05_sync/hive_tables.json\") or '{\"tables\":[]}')[\"tables\"]\n lineage = json.loads(raw(\"warehouse/lineage.json\") or '{\"edges\":[]}')[\"edges\"]\n docs = raw(\"docs/03-\\u4e1a\\u52a1\\u8bf4\\u660e.md\") + \"\\n\\n## \\u6570\\u4ed3\\u4e0e\\u8c03\\u5ea6\\n\" + raw(\"docs/05-\\u6570\\u4ed3\\u4e0e\\u8c03\\u5ea6\\u8bf4\\u660e.md\")\n su = GITEA + \"/api/v1/repos/\" + REPO + \"/contents/05_sync/warehouse_datahub_state.json\"\n state, state_sha = {}, \"\"\n rr = requests.get(su, headers=GH, timeout=15)\n if rr.status_code == 200:\n jj = rr.json()\n state = json.loads(base64.b64decode(jj[\"content\"]).decode(\"utf-8\"))\n state_sha = jj.get(\"sha\", \"\")\n table_hashes = {t[\"db\"] + \".\" + t[\"table\"]: sha256(json.dumps(t, ensure_ascii=False, sort_keys=True)) for t in tables}\n global_hash = sha256(json.dumps(tables, ensure_ascii=False, sort_keys=True) + \"||\" + json.dumps(lineage, ensure_ascii=False, sort_keys=True) + \"||\" + docs)\n docs_hash = sha256(docs)\n prev = state.get(\"table_hashes\", {})\n force_on = (force or \"\").strip().lower() == \"true\"\n changed = sorted([t[\"db\"] + \".\" + t[\"table\"] for t in tables if prev.get(t[\"db\"] + \".\" + t[\"table\"]) != table_hashes[t[\"db\"] + \".\" + t[\"table\"]]])\n if force_on:\n changed = sorted([t[\"db\"] + \".\" + t[\"table\"] for t in tables])\n skip = (not force_on) and state.get(\"global_hash\") == global_hash\n spec_needed = force_on or (not state.get(\"spec_json\")) or state.get(\"docs_hash\") != docs_hash\n return {\n \"skip\": skip,\n \"tables_json\": json.dumps(tables, ensure_ascii=False),\n \"lineage_json\": json.dumps(lineage, ensure_ascii=False),\n \"docs_text\": docs,\n \"changed_tables\": changed,\n \"global_hash\": global_hash,\n \"docs_hash\": docs_hash,\n \"table_hashes_json\": json.dumps(table_hashes),\n \"state_sha\": state_sha,\n \"prev_state_json\": json.dumps(state, ensure_ascii=False),\n \"prev_spec_json\": state.get(\"spec_json\", \"\") if isinstance(state.get(\"spec_json\", \"\"), str) else json.dumps(state.get(\"spec_json\", {}), ensure_ascii=False),\n \"spec_needed\": spec_needed,\n }","variables":[{"variable":"force","value_selector":["9100000000001","force"],"value_type":"string"}],"outputs":{"skip":{"type":"boolean","children":null},"tables_json":{"type":"string","children":null},"lineage_json":{"type":"string","children":null},"docs_text":{"type":"string","children":null},"changed_tables":{"type":"array[string]","children":null},"global_hash":{"type":"string","children":null},"docs_hash":{"type":"string","children":null},"table_hashes_json":{"type":"string","children":null},"state_sha":{"type":"string","children":null},"prev_state_json":{"type":"string","children":null},"prev_spec_json":{"type":"string","children":null},"spec_needed":{"type":"boolean","children":null}},"selected":false}},{"id":"9100000000003","type":"custom","position":{"x":700,"y":260},"positionAbsolute":{"x":700,"y":260},"width":242,"height":130,"selected":false,"sourcePosition":"right","targetPosition":"left","data":{"type":"if-else","title":"需要更新?","desc":"","selected":false,"cases":[{"case_id":"true","logical_operator":"and","conditions":[{"id":"cond_skip","varType":"boolean","variable_selector":["9100000000002","skip"],"comparison_operator":"is","value":"false"}]}]}},{"id":"9100000000012","type":"custom","position":{"x":900,"y":260},"positionAbsolute":{"x":900,"y":260},"width":242,"height":130,"selected":false,"sourcePosition":"right","targetPosition":"left","data":{"type":"if-else","title":"规格需重生成?","desc":"","selected":false,"cases":[{"case_id":"true"Line truncated {"graph":{"nodes":[{"id":"9100000000001","type":"custom","position":{"x":40,"y":260},"positionAbsolute":{"x":40,"y":260},"width":242,"height":108,"selected":false,"sourcePosition":"right","targetPosition":"left","data":{"type":"start","title":"开始","desc":"","selected":false,"variables":[{"type":"text-input","variable":"force","label":"force(填true强制全量重同步)","required":false,"options":[],"default":"","hint":"","placeholder":""}]}},{"id":"9100000000002","type":"custom","position":{"x":340,"y":260},"positionAbsolute":{"x":340,"y":260},"width":242,"height":220,"selected":false,"sourcePosition":"right","targetPosition":"left","data":{"type":"code","title":"采集数仓指纹","desc":"","code_language":"python3","code":"import requests, json, hashlib, base64\n\nGITEA = \"http://gitea:3000\"\nREPO = \"admin/mini-erp-fabric-demo\"\nGH = {\"Authorization\": \"token 77c6bd2fdab535b2720821d36b4cfb74aa3bf87c\"}\n\ndef sha256(s):\n return hashlib.sha256(s.encode(\"utf-8\")).hexdigest()\n\ndef raw(path):\n r = requests.get(GITEA + \"/\" + REPO + \"/raw/branch/main/\" + path, headers=GH, timeout=20)\n return r.text if r.status_code == 200 else \"\"\n\ndef main(force: str):\n tables = json.loads(raw(\"05_sync/hive_tables.json\") or '{\"tables\":[]}')[\"tables\"]\n lineage = json.loads(raw(\"warehouse/lineage.json\") or '{\"edges\":[]}')[\"edges\"]\n docs = raw(\"docs/03-\\u4e1a\\u52a1\\u8bf4\\u660e.md\") + \"\\n\\n## \\u6570\\u4ed3\\u4e0e\\u8c03\\u5ea6\\n\" + raw(\"docs/05-\\u6570\\u4ed3\\u4e0e\\u8c03\\u5ea6\\u8bf4\\u660e.md\")\n su = GITEA + \"/api/v1/repos/\" + REPO + \"/contents/05_sync/warehouse_datahub_state.json\"\n state, state_sha = {}, \"\"\n rr = requests.get(su, headers=GH, timeout=15)\n if rr.status_code == 200:\n jj = rr.json()\n state = json.loads(base64.b64decode(jj[\"content\"]).decode(\"utf-8\"))\n state_sha = jj.get(\"sha\", \"\")\n table_hashes = {t[\"db\"] + \".\" + t[\"table\"]: sha256(json.dumps(t, ensure_ascii=False, sort_keys=True)) for t in tables}\n global_hash = sha256(json.dumps(tables, ensure_ascii=False, sort_keys=True) + \"||\" + json.dumps(lineage, ensure_ascii=False, sort_keys=True) + \"||\" + docs)\n docs_hash = sha256(docs)\n prev = state.get(\"table_hashes\", {})\n force_on = (force or \"\").strip().lower() == \"true\"\n changed = sorted([t[\"db\"] + \".\" + t[\"table\"] for t in tables if prev.get(t[\"db\"] + \".\" + t[\"table\"]) != table_hashes[t[\"db\"] + \".\" + t[\"table\"]]])\n if force_on:\n changed = sorted([t[\"db\"] + \".\" + t[\"table\"] for t in tables])\n skip = (not force_on) and state.get(\"global_hash\") == global_hash\n spec_needed = force_on or (not state.get(\"spec_json\")) or state.get(\"docs_hash\") != docs_hash\n return {\n \"skip\": skip,\n \"tables_json\": json.dumps(tables, ensure_ascii=False),\n \"lineage_json\": json.dumps(lineage, ensure_ascii=False),\n \"docs_text\": docs,\n \"changed_tables\": changed,\n \"global_hash\": global_hash,\n \"docs_hash\": docs_hash,\n \"table_hashes_json\": json.dumps(table_hashes),\n \"state_sha\": state_sha,\n \"prev_state_json\": json.dumps(state, ensure_ascii=False),\n \"prev_spec_json\": state.get(\"spec_json\", \"\") if isinstance(state.get(\"spec_json\", \"\"), str) else json.dumps(state.get(\"spec_json\", {}), ensure_ascii=False),\n \"spec_needed\": spec_needed,\n }","variables":[{"variable":"force","value_selector":["9100000000001","force"],"value_type":"string"}],"outputs":{"skip":{"type":"boolean","children":null},"tables_json":{"type":"string","children":null},"lineage_json":{"type":"string","children":null},"docs_text":{"type":"string","children":null},"changed_tables":{"type":"array[string]","children":null},"global_hash":{"type":"string","children":null},"docs_hash":{"type":"string","children":null},"table_hashes_json":{"type":"string","children":null},"state_sha":{"type":"string","children":null},"prev_state_json":{"type":"string","children":null},"prev_spec_json":{"type":"string","children":null},"spec_needed":{"type":"boolean","children":null}},"selected":false}},{"id":"9100000000003","type":"custom","position":{"x":700,"y":260},"positionAbsolute":{"x":700,"y":260},"width":242,"height":130,"selected":false,"sourcePosition":"right","targetPosition":"left","data":{"type":"if-else","title":"需要更新?","desc":"","selected":false,"cases":[{"case_id":"true","logical_operator":"and","conditions":[{"id":"cond_skip","varType":"boolean","variable_selector":["9100000000002","skip"],"comparison_operator":"is","value":"false"}]}]}},{"id":"9100000000012","type":"custom","position":{"x":900,"y":260},"positionAbsolute":{"x":900,"y":260},"width":242,"height":130,"selected":false,"sourcePosition":"right","targetPosition":"left","data":{"type":"if-else","title":"规格需重生成?","desc":"","selected":false,"cases":[{"case_id":"true"Line truncated