docs+deploy: 元数据同步工作流 v2.1(规格缓存/固定清单/force全表)与治理链路文档
This commit is contained in:
1 parent
880fad1f36
commit
9ae77528f5
37 files changed
+135
-34
No files matched your search
@@ -0,0 +1 @@
|
||||
{"graph":{"nodes":[{"id":"9000000000001","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":"9000000000002","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\"\nERP = \"http://mini-erp-app:8000\"\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 main(force: str):\n tables = requests.get(ERP + \"/api/governance/tables\", timeout=15).json()[\"tables\"]\n docs = \"\"\n for f in [\"01-\\u7cfb\\u7edf\\u4ecb\\u7ecd\", \"03-\\u4e1a\\u52a1\\u8bf4\\u660e\"]:\n r = requests.get(GITEA + \"/\" + REPO + \"/raw/branch/main/docs/\" + f + \".md\", headers=GH, timeout=15)\n if r.status_code == 200:\n docs += \"\\n\\n## \" + f + \"\\n\" + r.text\n su = GITEA + \"/api/v1/repos/\" + REPO + \"/contents/05_sync/erp_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[\"table_name\"]: 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) + \"||\" + docs)\n docs_hash = sha256(docs)\n prev = state.get(\"table_hashes\", {})\n force_on = (force or \"\").strip().lower() == \"true\"\n changed = sorted([t[\"table_name\"] for t in tables if prev.get(t[\"table_name\"]) != table_hashes[t[\"table_name\"]]])\n if force_on:\n changed = sorted([t[\"table_name\"] 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 \"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":["9000000000001","force"],"value_type":"string"}],"outputs":{"skip":{"type":"boolean","children":null},"tables_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":"9000000000003","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":["9000000000002","skip"],"comparison_operator":"is","value":"false"}]}]}},{"id":"9000000000012","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","logical_operator":"and","conditions":[{"id":"cond_spec","varType":"boolean","variable_selector":["9000000000002","spec_needed"],"comparison_operator":"is","value":"true"}]}]}},{"id":"9000000000004","type":"custom","position":{"x":1040,"y":460},"positionAbsolute":{"x":1040,"y":460},"width":242,"height":100,"selected":false,"sourcePosition":"right","targetPositLine truncated
|
||||
Reference in new issue
Block a user