trustgraph-cli 2.6.12__tar.gz → 2.6.13__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.
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/PKG-INFO +1 -1
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/pyproject.toml +2 -0
- trustgraph_cli-2.6.13/trustgraph/cli/export_workspace.py +141 -0
- trustgraph_cli-2.6.13/trustgraph/cli/import_workspace.py +194 -0
- trustgraph_cli-2.6.13/trustgraph/cli_version.py +1 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph_cli.egg-info/PKG-INFO +1 -1
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph_cli.egg-info/SOURCES.txt +2 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph_cli.egg-info/entry_points.txt +2 -0
- trustgraph_cli-2.6.12/trustgraph/cli_version.py +0 -1
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/README.md +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/setup.cfg +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/__init__.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/_iam.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/add_library_document.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/bootstrap_iam.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/change_password.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/create_api_key.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/create_user.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/create_workspace.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/delete_collection.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/delete_config_item.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/delete_flow_blueprint.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/delete_kg_core.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/delete_mcp_tool.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/delete_tool.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/delete_user.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/disable_user.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/dump_msgpack.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/dump_queues.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/enable_user.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/export_workspace_config.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/get_config_item.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/get_de_core.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/get_document_content.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/get_flow_blueprint.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/get_kg_core.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/graph_to_turtle.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/import_workspace_config.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/init_pulsar_manager.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_agent.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_document_embeddings.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_document_rag.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_embeddings.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_graph_embeddings.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_graph_rag.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_llm.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_mcp_tool.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_nlp_query.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_prompt.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_reranker.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_row_embeddings.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_rows_query.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_sparql_query.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_structured_query.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/list_api_keys.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/list_collections.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/list_config_items.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/list_explain_traces.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/list_my_workspaces.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/list_users.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/list_workspaces.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/load_doc_embeds.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/load_kg_core.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/load_knowledge.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/load_sample_documents.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/load_structured_data.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/load_turtle.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/login.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/monitor_prompts.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/put_config_item.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/put_de_core.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/put_flow_blueprint.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/put_kg_core.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/query_graph.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/remove_library_document.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/reset_password.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/revoke_api_key.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/sample_documents/__init__.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/sample_documents/belgian-beer.md +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/sample_documents/bronze-age-collapse.pdf +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/sample_documents/corporate-scandals.pdf +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/sample_documents/history-of-pets.md +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/sample_documents/metadata.json +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/sample_documents/mil-fortifications-america-19th-c.md +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/sample_documents/recipes.md +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/sample_documents/trade-routes-europe.md +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/save_doc_embeds.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/set_collection.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/set_mcp_tool.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/set_prompt.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/set_token_costs.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/set_tool.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_config.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_explain_trace.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_extraction_provenance.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_flow_blueprints.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_flow_state.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_flows.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_graph.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_kg_cores.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_library_documents.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_library_processing.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_mcp_tools.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_parameter_types.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_processor_state.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_prompts.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_token_costs.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_token_rate.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_tools.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/start_flow.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/start_library_processing.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/stop_flow.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/stop_library_processing.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/unload_kg_core.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/update_user.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/verify_system_status.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/whoami.py +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph_cli.egg-info/dependency_links.txt +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph_cli.egg-info/requires.txt +0 -0
- {trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/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.
|
|
3
|
+
Version: 2.6.13
|
|
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()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.6.13"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trustgraph-cli
|
|
3
|
-
Version: 2.6.
|
|
3
|
+
Version: 2.6.13
|
|
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"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/invoke_document_embeddings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/sample_documents/belgian-beer.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/sample_documents/history-of-pets.md
RENAMED
|
File without changes
|
{trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/sample_documents/metadata.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph/cli/show_extraction_provenance.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trustgraph_cli-2.6.12 → trustgraph_cli-2.6.13}/trustgraph_cli.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|