trustgraph-cli 2.6.12__tar.gz → 2.6.14__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/PKG-INFO +1 -1
  2. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/pyproject.toml +2 -0
  3. trustgraph_cli-2.6.14/trustgraph/cli/export_workspace.py +141 -0
  4. trustgraph_cli-2.6.14/trustgraph/cli/import_workspace.py +194 -0
  5. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/invoke_graph_rag.py +16 -2
  6. trustgraph_cli-2.6.14/trustgraph/cli_version.py +1 -0
  7. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph_cli.egg-info/PKG-INFO +1 -1
  8. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph_cli.egg-info/SOURCES.txt +2 -0
  9. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph_cli.egg-info/entry_points.txt +2 -0
  10. trustgraph_cli-2.6.12/trustgraph/cli_version.py +0 -1
  11. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/README.md +0 -0
  12. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/setup.cfg +0 -0
  13. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/__init__.py +0 -0
  14. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/_iam.py +0 -0
  15. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/add_library_document.py +0 -0
  16. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/bootstrap_iam.py +0 -0
  17. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/change_password.py +0 -0
  18. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/create_api_key.py +0 -0
  19. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/create_user.py +0 -0
  20. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/create_workspace.py +0 -0
  21. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/delete_collection.py +0 -0
  22. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/delete_config_item.py +0 -0
  23. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/delete_flow_blueprint.py +0 -0
  24. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/delete_kg_core.py +0 -0
  25. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/delete_mcp_tool.py +0 -0
  26. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/delete_tool.py +0 -0
  27. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/delete_user.py +0 -0
  28. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/disable_user.py +0 -0
  29. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/dump_msgpack.py +0 -0
  30. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/dump_queues.py +0 -0
  31. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/enable_user.py +0 -0
  32. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/export_workspace_config.py +0 -0
  33. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/get_config_item.py +0 -0
  34. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/get_de_core.py +0 -0
  35. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/get_document_content.py +0 -0
  36. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/get_flow_blueprint.py +0 -0
  37. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/get_kg_core.py +0 -0
  38. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/graph_to_turtle.py +0 -0
  39. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/import_workspace_config.py +0 -0
  40. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/init_pulsar_manager.py +0 -0
  41. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/invoke_agent.py +0 -0
  42. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/invoke_document_embeddings.py +0 -0
  43. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/invoke_document_rag.py +0 -0
  44. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/invoke_embeddings.py +0 -0
  45. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/invoke_graph_embeddings.py +0 -0
  46. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/invoke_llm.py +0 -0
  47. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/invoke_mcp_tool.py +0 -0
  48. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/invoke_nlp_query.py +0 -0
  49. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/invoke_prompt.py +0 -0
  50. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/invoke_reranker.py +0 -0
  51. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/invoke_row_embeddings.py +0 -0
  52. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/invoke_rows_query.py +0 -0
  53. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/invoke_sparql_query.py +0 -0
  54. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/invoke_structured_query.py +0 -0
  55. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/list_api_keys.py +0 -0
  56. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/list_collections.py +0 -0
  57. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/list_config_items.py +0 -0
  58. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/list_explain_traces.py +0 -0
  59. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/list_my_workspaces.py +0 -0
  60. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/list_users.py +0 -0
  61. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/list_workspaces.py +0 -0
  62. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/load_doc_embeds.py +0 -0
  63. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/load_kg_core.py +0 -0
  64. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/load_knowledge.py +0 -0
  65. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/load_sample_documents.py +0 -0
  66. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/load_structured_data.py +0 -0
  67. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/load_turtle.py +0 -0
  68. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/login.py +0 -0
  69. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/monitor_prompts.py +0 -0
  70. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/put_config_item.py +0 -0
  71. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/put_de_core.py +0 -0
  72. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/put_flow_blueprint.py +0 -0
  73. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/put_kg_core.py +0 -0
  74. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/query_graph.py +0 -0
  75. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/remove_library_document.py +0 -0
  76. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/reset_password.py +0 -0
  77. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/revoke_api_key.py +0 -0
  78. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/sample_documents/__init__.py +0 -0
  79. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/sample_documents/belgian-beer.md +0 -0
  80. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/sample_documents/bronze-age-collapse.pdf +0 -0
  81. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/sample_documents/corporate-scandals.pdf +0 -0
  82. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/sample_documents/history-of-pets.md +0 -0
  83. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/sample_documents/metadata.json +0 -0
  84. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/sample_documents/mil-fortifications-america-19th-c.md +0 -0
  85. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/sample_documents/recipes.md +0 -0
  86. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/sample_documents/trade-routes-europe.md +0 -0
  87. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/save_doc_embeds.py +0 -0
  88. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/set_collection.py +0 -0
  89. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/set_mcp_tool.py +0 -0
  90. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/set_prompt.py +0 -0
  91. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/set_token_costs.py +0 -0
  92. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/set_tool.py +0 -0
  93. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_config.py +0 -0
  94. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_explain_trace.py +0 -0
  95. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_extraction_provenance.py +0 -0
  96. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_flow_blueprints.py +0 -0
  97. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_flow_state.py +0 -0
  98. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_flows.py +0 -0
  99. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_graph.py +0 -0
  100. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_kg_cores.py +0 -0
  101. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_library_documents.py +0 -0
  102. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_library_processing.py +0 -0
  103. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_mcp_tools.py +0 -0
  104. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_parameter_types.py +0 -0
  105. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_processor_state.py +0 -0
  106. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_prompts.py +0 -0
  107. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_token_costs.py +0 -0
  108. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_token_rate.py +0 -0
  109. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/show_tools.py +0 -0
  110. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/start_flow.py +0 -0
  111. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/start_library_processing.py +0 -0
  112. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/stop_flow.py +0 -0
  113. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/stop_library_processing.py +0 -0
  114. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/unload_kg_core.py +0 -0
  115. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/update_user.py +0 -0
  116. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/verify_system_status.py +0 -0
  117. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph/cli/whoami.py +0 -0
  118. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph_cli.egg-info/dependency_links.txt +0 -0
  119. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph_cli.egg-info/requires.txt +0 -0
  120. {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.14}/trustgraph_cli.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trustgraph-cli
3
- Version: 2.6.12
3
+ Version: 2.6.14
4
4
  Summary: TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline.
5
5
  Author-email: "trustgraph.ai" <security@trustgraph.ai>
6
6
  Project-URL: Homepage, https://github.com/trustgraph-ai/trustgraph
@@ -116,6 +116,8 @@ tg-put-config-item = "trustgraph.cli.put_config_item:main"
116
116
  tg-delete-config-item = "trustgraph.cli.delete_config_item:main"
117
117
  tg-export-workspace-config = "trustgraph.cli.export_workspace_config:main"
118
118
  tg-import-workspace-config = "trustgraph.cli.import_workspace_config:main"
119
+ tg-export-workspace = "trustgraph.cli.export_workspace:main"
120
+ tg-import-workspace = "trustgraph.cli.import_workspace:main"
119
121
  tg-list-collections = "trustgraph.cli.list_collections:main"
120
122
  tg-set-collection = "trustgraph.cli.set_collection:main"
121
123
  tg-delete-collection = "trustgraph.cli.delete_collection:main"
@@ -0,0 +1,141 @@
1
+ """
2
+ Exports a workspace's full configuration state as a portable .tgx bundle
3
+ (a gzipped tar archive) for backup, migration between deployments, or
4
+ sharing a pre-configured workspace.
5
+
6
+ The bundle is human-readable: a manifest.json plus one pretty-printed JSON
7
+ file per config key under config/<type>/, so it can be inspected and
8
+ hand-edited before import. Each entry file embeds its own type and key, so
9
+ filenames are cosmetic. Knowledge export (triples, documents, embeddings)
10
+ is not yet included; the manifest records that so future importers can
11
+ distinguish config-only bundles.
12
+ """
13
+
14
+ import argparse
15
+ import io
16
+ import json
17
+ import os
18
+ import sys
19
+ import tarfile
20
+ import time
21
+ from urllib.parse import quote
22
+
23
+ from trustgraph.api import Api
24
+
25
+ default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
26
+ default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
27
+ default_workspace = os.getenv("TRUSTGRAPH_WORKSPACE", "default")
28
+
29
+ MANIFEST_FORMAT = "tgx"
30
+ MANIFEST_FORMAT_VERSION = 1
31
+
32
+
33
+ def _add_bytes(tar, name, data):
34
+ info = tarfile.TarInfo(name=name)
35
+ info.size = len(data)
36
+ info.mtime = int(time.time())
37
+ tar.addfile(info, io.BytesIO(data))
38
+
39
+
40
+ def export_workspace(url, workspace, output, token=None):
41
+
42
+ api = Api(url, token=token, workspace=workspace).config()
43
+
44
+ config, version = api.all()
45
+
46
+ manifest = {
47
+ "format": MANIFEST_FORMAT,
48
+ "format_version": MANIFEST_FORMAT_VERSION,
49
+ "workspace": workspace,
50
+ "config_version": version,
51
+ "exported_at": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
52
+ "contents": {"config": True, "knowledge": False},
53
+ }
54
+
55
+ count = 0
56
+
57
+ with tarfile.open(output, "w:gz") as tar:
58
+
59
+ _add_bytes(
60
+ tar, "manifest.json",
61
+ json.dumps(manifest, indent=2).encode("utf-8"),
62
+ )
63
+
64
+ for type_, entries in sorted(config.items()):
65
+ for key, raw in sorted(entries.items()):
66
+
67
+ # Config values are stored as JSON strings; parse so the
68
+ # bundle is pretty-printed and hand-editable. A value that
69
+ # isn't valid JSON is preserved verbatim.
70
+ try:
71
+ value = json.loads(raw)
72
+ except (TypeError, json.JSONDecodeError):
73
+ value = raw
74
+
75
+ entry = {"type": type_, "key": key, "value": value}
76
+
77
+ # Keys may contain path-unsafe characters; the entry embeds
78
+ # the real key, so the quoted filename is cosmetic only.
79
+ name = f"config/{quote(type_, safe='')}/{quote(key, safe='')}.json"
80
+
81
+ _add_bytes(
82
+ tar, name,
83
+ json.dumps(entry, indent=2).encode("utf-8"),
84
+ )
85
+
86
+ count += 1
87
+
88
+ print(f"Exported {count} config item(s) from workspace "
89
+ f"'{workspace}' to {output}", flush=True)
90
+
91
+
92
+ def main():
93
+
94
+ parser = argparse.ArgumentParser(
95
+ prog='tg-export-workspace',
96
+ description=__doc__,
97
+ )
98
+
99
+ parser.add_argument(
100
+ '-u', '--api-url',
101
+ default=default_url,
102
+ help=f'API URL (default: {default_url})',
103
+ )
104
+
105
+ parser.add_argument(
106
+ '-t', '--token',
107
+ default=default_token,
108
+ help='API token (default: TRUSTGRAPH_TOKEN environment variable)',
109
+ )
110
+
111
+ parser.add_argument(
112
+ '-w', '--workspace',
113
+ default=default_workspace,
114
+ help=f'Workspace to export (default: {default_workspace})',
115
+ )
116
+
117
+ parser.add_argument(
118
+ '-o', '--output',
119
+ required=True,
120
+ help='Output bundle path, e.g. workspace-default.tgx',
121
+ )
122
+
123
+ args = parser.parse_args()
124
+
125
+ try:
126
+
127
+ export_workspace(
128
+ url=args.api_url,
129
+ workspace=args.workspace,
130
+ output=args.output,
131
+ token=args.token,
132
+ )
133
+
134
+ except Exception as e:
135
+
136
+ print("Exception:", e, flush=True)
137
+ sys.exit(1)
138
+
139
+
140
+ if __name__ == "__main__":
141
+ main()
@@ -0,0 +1,194 @@
1
+ """
2
+ Imports a workspace bundle (.tgx, produced by tg-export-workspace) into a
3
+ TrustGraph deployment. The target workspace defaults to the name recorded
4
+ in the bundle's manifest and can be renamed with --workspace.
5
+
6
+ By default existing (type, key) entries in the target workspace are left
7
+ untouched and only missing keys are added, matching WorkspaceInit's
8
+ re-run behaviour; pass --overwrite to replace every imported key. Use
9
+ --dry-run to show what would be written without changing anything.
10
+ """
11
+
12
+ import argparse
13
+ import json
14
+ import os
15
+ import sys
16
+ import tarfile
17
+
18
+ from trustgraph.api import Api
19
+ from trustgraph.api.types import ConfigValue
20
+
21
+ default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
22
+ default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
23
+
24
+ SUPPORTED_FORMAT = "tgx"
25
+ SUPPORTED_FORMAT_VERSION = 1
26
+
27
+
28
+ def _read_bundle(path):
29
+ """Read manifest and config entries from a .tgx bundle."""
30
+
31
+ manifest = None
32
+ entries = []
33
+
34
+ with tarfile.open(path, "r:gz") as tar:
35
+ for member in tar.getmembers():
36
+ if not member.isfile():
37
+ continue
38
+ f = tar.extractfile(member)
39
+ if f is None:
40
+ continue
41
+ data = f.read()
42
+ if member.name == "manifest.json":
43
+ manifest = json.loads(data)
44
+ elif member.name.startswith("config/") and \
45
+ member.name.endswith(".json"):
46
+ entries.append(json.loads(data))
47
+
48
+ if manifest is None:
49
+ raise RuntimeError("not a workspace bundle: manifest.json missing")
50
+
51
+ if manifest.get("format") != SUPPORTED_FORMAT:
52
+ raise RuntimeError(
53
+ f"unsupported bundle format: {manifest.get('format')!r}"
54
+ )
55
+
56
+ if manifest.get("format_version", 0) > SUPPORTED_FORMAT_VERSION:
57
+ raise RuntimeError(
58
+ f"bundle format version {manifest.get('format_version')} is "
59
+ f"newer than this tool supports ({SUPPORTED_FORMAT_VERSION}); "
60
+ "upgrade trustgraph-cli"
61
+ )
62
+
63
+ return manifest, entries
64
+
65
+
66
+ def import_workspace(
67
+ url, input, workspace=None, overwrite=False, config_only=False,
68
+ dry_run=False, token=None,
69
+ ):
70
+
71
+ manifest, entries = _read_bundle(input)
72
+
73
+ # Knowledge import (triples, documents, embeddings) is not implemented
74
+ # yet; refuse to silently drop it from a bundle that carries it.
75
+ if manifest.get("contents", {}).get("knowledge") and not config_only:
76
+ raise RuntimeError(
77
+ "bundle contains knowledge data, which this tool cannot import "
78
+ "yet; re-run with --config-only to import just the configuration"
79
+ )
80
+
81
+ target = workspace or manifest.get("workspace") or "default"
82
+
83
+ api = Api(url, token=token, workspace=target).config()
84
+
85
+ # Mirror WorkspaceInit's re-run behaviour: without --overwrite, keys
86
+ # already present in the target workspace are skipped (per key, not per
87
+ # type). The config API's put is a blanket upsert, so filter client-side.
88
+ existing = {}
89
+ if not overwrite:
90
+ for type_ in sorted({e["type"] for e in entries}):
91
+ existing[type_] = set(api.list(type_))
92
+
93
+ values = []
94
+ skipped = 0
95
+
96
+ for e in entries:
97
+ type_, key, value = e["type"], e["key"], e["value"]
98
+ if not overwrite and key in existing.get(type_, set()):
99
+ skipped += 1
100
+ continue
101
+ # Config values are stored as JSON strings (see WorkspaceInit).
102
+ values.append(
103
+ ConfigValue(type=type_, key=key, value=json.dumps(value))
104
+ )
105
+
106
+ if dry_run:
107
+ for v in values:
108
+ print(f"would import {v.type}/{v.key}", flush=True)
109
+ print(f"Dry run: {len(values)} item(s) would be imported into "
110
+ f"workspace '{target}', {skipped} skipped as existing",
111
+ flush=True)
112
+ return
113
+
114
+ if values:
115
+ api.put(values)
116
+
117
+ print(f"Imported {len(values)} config item(s) into workspace "
118
+ f"'{target}', {skipped} skipped as existing", flush=True)
119
+
120
+
121
+ def main():
122
+
123
+ parser = argparse.ArgumentParser(
124
+ prog='tg-import-workspace',
125
+ description=__doc__,
126
+ )
127
+
128
+ parser.add_argument(
129
+ '-u', '--api-url',
130
+ default=default_url,
131
+ help=f'API URL (default: {default_url})',
132
+ )
133
+
134
+ parser.add_argument(
135
+ '-t', '--token',
136
+ default=default_token,
137
+ help='API token (default: TRUSTGRAPH_TOKEN environment variable)',
138
+ )
139
+
140
+ parser.add_argument(
141
+ '-i', '--input',
142
+ required=True,
143
+ help='Input bundle path, e.g. workspace-default.tgx',
144
+ )
145
+
146
+ parser.add_argument(
147
+ '-w', '--workspace',
148
+ default=None,
149
+ help='Target workspace (default: the workspace recorded in the '
150
+ 'bundle manifest)',
151
+ )
152
+
153
+ parser.add_argument(
154
+ '--overwrite',
155
+ action='store_true',
156
+ help='Replace existing keys in the target workspace (default: '
157
+ 'keep existing keys and only add missing ones)',
158
+ )
159
+
160
+ parser.add_argument(
161
+ '--config-only',
162
+ action='store_true',
163
+ help='Import only the configuration, skipping any knowledge data '
164
+ 'in the bundle',
165
+ )
166
+
167
+ parser.add_argument(
168
+ '--dry-run',
169
+ action='store_true',
170
+ help='Show what would be imported without writing anything',
171
+ )
172
+
173
+ args = parser.parse_args()
174
+
175
+ try:
176
+
177
+ import_workspace(
178
+ url=args.api_url,
179
+ input=args.input,
180
+ workspace=args.workspace,
181
+ overwrite=args.overwrite,
182
+ config_only=args.config_only,
183
+ dry_run=args.dry_run,
184
+ token=args.token,
185
+ )
186
+
187
+ except Exception as e:
188
+
189
+ print("Exception:", e, flush=True)
190
+ sys.exit(1)
191
+
192
+
193
+ if __name__ == "__main__":
194
+ main()
@@ -27,11 +27,13 @@ default_max_subgraph_size = 150
27
27
  default_max_path_length = 2
28
28
  default_edge_score_limit = 30
29
29
  default_edge_limit = 25
30
+ default_max_reranker_input = 350
30
31
 
31
32
  def _question_explainable_api(
32
33
  url, flow_id, question_text, collection, entity_limit, triple_limit,
33
34
  max_subgraph_size, max_path_length, edge_score_limit=30,
34
- edge_limit=25, token=None, debug=False, workspace="default",
35
+ edge_limit=25, max_reranker_input=350, token=None, debug=False,
36
+ workspace="default",
35
37
  ):
36
38
  """Execute graph RAG with explainability using the new API classes."""
37
39
  api = Api(url=url, token=token, workspace=workspace)
@@ -50,6 +52,7 @@ def _question_explainable_api(
50
52
  max_path_length=max_path_length,
51
53
  edge_score_limit=edge_score_limit,
52
54
  edge_limit=edge_limit,
55
+ max_reranker_input=max_reranker_input,
53
56
  ):
54
57
  if isinstance(item, RAGChunk):
55
58
  # Print response content
@@ -138,7 +141,7 @@ def _question_explainable_api(
138
141
  def question(
139
142
  url, flow_id, question, collection, entity_limit, triple_limit,
140
143
  max_subgraph_size, max_path_length, edge_score_limit=50,
141
- edge_limit=25, streaming=True, token=None,
144
+ edge_limit=25, max_reranker_input=350, streaming=True, token=None,
142
145
  explainable=False, debug=False, show_usage=False,
143
146
  workspace="default",
144
147
  ):
@@ -156,6 +159,7 @@ def question(
156
159
  max_path_length=max_path_length,
157
160
  edge_score_limit=edge_score_limit,
158
161
  edge_limit=edge_limit,
162
+ max_reranker_input=max_reranker_input,
159
163
  token=token,
160
164
  debug=debug,
161
165
  workspace=workspace,
@@ -180,6 +184,7 @@ def question(
180
184
  max_path_length=max_path_length,
181
185
  edge_score_limit=edge_score_limit,
182
186
  edge_limit=edge_limit,
187
+ max_reranker_input=max_reranker_input,
183
188
  streaming=True
184
189
  )
185
190
 
@@ -212,6 +217,7 @@ def question(
212
217
  max_path_length=max_path_length,
213
218
  edge_score_limit=edge_score_limit,
214
219
  edge_limit=edge_limit,
220
+ max_reranker_input=max_reranker_input,
215
221
  )
216
222
  print(result.text)
217
223
 
@@ -308,6 +314,13 @@ def main():
308
314
  help=f'Max edges after LLM scoring (default: {default_edge_limit})'
309
315
  )
310
316
 
317
+ parser.add_argument(
318
+ '--max-reranker-input',
319
+ type=int,
320
+ default=default_max_reranker_input,
321
+ help=f'Max candidate edges sent to reranker per hop (default: {default_max_reranker_input})'
322
+ )
323
+
311
324
  parser.add_argument(
312
325
  '--no-streaming',
313
326
  action='store_true',
@@ -347,6 +360,7 @@ def main():
347
360
  max_path_length=args.max_path_length,
348
361
  edge_score_limit=args.edge_score_limit,
349
362
  edge_limit=args.edge_limit,
363
+ max_reranker_input=args.max_reranker_input,
350
364
  streaming=not args.no_streaming,
351
365
  token=args.token,
352
366
  explainable=args.explainable,
@@ -0,0 +1 @@
1
+ __version__ = "2.6.14"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trustgraph-cli
3
- Version: 2.6.12
3
+ Version: 2.6.14
4
4
  Summary: TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline.
5
5
  Author-email: "trustgraph.ai" <security@trustgraph.ai>
6
6
  Project-URL: Homepage, https://github.com/trustgraph-ai/trustgraph
@@ -20,6 +20,7 @@ trustgraph/cli/disable_user.py
20
20
  trustgraph/cli/dump_msgpack.py
21
21
  trustgraph/cli/dump_queues.py
22
22
  trustgraph/cli/enable_user.py
23
+ trustgraph/cli/export_workspace.py
23
24
  trustgraph/cli/export_workspace_config.py
24
25
  trustgraph/cli/get_config_item.py
25
26
  trustgraph/cli/get_de_core.py
@@ -27,6 +28,7 @@ trustgraph/cli/get_document_content.py
27
28
  trustgraph/cli/get_flow_blueprint.py
28
29
  trustgraph/cli/get_kg_core.py
29
30
  trustgraph/cli/graph_to_turtle.py
31
+ trustgraph/cli/import_workspace.py
30
32
  trustgraph/cli/import_workspace_config.py
31
33
  trustgraph/cli/init_pulsar_manager.py
32
34
  trustgraph/cli/invoke_agent.py
@@ -16,6 +16,7 @@ tg-disable-user = trustgraph.cli.disable_user:main
16
16
  tg-dump-msgpack = trustgraph.cli.dump_msgpack:main
17
17
  tg-dump-queues = trustgraph.cli.dump_queues:main
18
18
  tg-enable-user = trustgraph.cli.enable_user:main
19
+ tg-export-workspace = trustgraph.cli.export_workspace:main
19
20
  tg-export-workspace-config = trustgraph.cli.export_workspace_config:main
20
21
  tg-get-config-item = trustgraph.cli.get_config_item:main
21
22
  tg-get-de-core = trustgraph.cli.get_de_core:main
@@ -23,6 +24,7 @@ tg-get-document-content = trustgraph.cli.get_document_content:main
23
24
  tg-get-flow-blueprint = trustgraph.cli.get_flow_blueprint:main
24
25
  tg-get-kg-core = trustgraph.cli.get_kg_core:main
25
26
  tg-graph-to-turtle = trustgraph.cli.graph_to_turtle:main
27
+ tg-import-workspace = trustgraph.cli.import_workspace:main
26
28
  tg-import-workspace-config = trustgraph.cli.import_workspace_config:main
27
29
  tg-invoke-agent = trustgraph.cli.invoke_agent:main
28
30
  tg-invoke-document-embeddings = trustgraph.cli.invoke_document_embeddings:main
@@ -1 +0,0 @@
1
- __version__ = "2.6.12"