mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 08:26:21 +02:00
Update config util to take files as well as command-line text (#437)
This commit is contained in:
parent
54592b5e9f
commit
a96d02da5d
1 changed files with 21 additions and 1 deletions
|
|
@ -118,7 +118,10 @@ def ensure_config(config, pulsar_host, pulsar_api_key):
|
||||||
print("Retrying...", flush=True)
|
print("Retrying...", flush=True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def init(pulsar_admin_url, pulsar_host, pulsar_api_key, config, tenant):
|
def init(
|
||||||
|
pulsar_admin_url, pulsar_host, pulsar_api_key, tenant,
|
||||||
|
config, config_file,
|
||||||
|
):
|
||||||
|
|
||||||
clusters = get_clusters(pulsar_admin_url)
|
clusters = get_clusters(pulsar_admin_url)
|
||||||
|
|
||||||
|
|
@ -156,6 +159,18 @@ def init(pulsar_admin_url, pulsar_host, pulsar_api_key, config, tenant):
|
||||||
|
|
||||||
ensure_config(dec, pulsar_host, pulsar_api_key)
|
ensure_config(dec, pulsar_host, pulsar_api_key)
|
||||||
|
|
||||||
|
elif config_file is not None:
|
||||||
|
|
||||||
|
try:
|
||||||
|
print("Decoding config...", flush=True)
|
||||||
|
dec = json.load(open(config_file))
|
||||||
|
print("Decoded.", flush=True)
|
||||||
|
except Exception as e:
|
||||||
|
print("Exception:", e, flush=True)
|
||||||
|
raise e
|
||||||
|
|
||||||
|
ensure_config(dec, pulsar_host, pulsar_api_key)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("No config to update.", flush=True)
|
print("No config to update.", flush=True)
|
||||||
|
|
||||||
|
|
@ -188,6 +203,11 @@ def main():
|
||||||
help=f'Initial configuration to load',
|
help=f'Initial configuration to load',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'-C', '--config-file',
|
||||||
|
help=f'Initial configuration to load from file',
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-t', '--tenant',
|
'-t', '--tenant',
|
||||||
default="tg",
|
default="tg",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue