From 9dc9966433eede7fe9e1472ab93d0a17d848dcba Mon Sep 17 00:00:00 2001 From: scott-ca <59944183+scott-ca@users.noreply.github.com> Date: Sat, 23 Jul 2022 22:02:03 -0600 Subject: [PATCH] Added functionality to add any/all args via json --- aiserver.py | 9 +++++++++ customsettings_template.json | 3 +++ 2 files changed, 12 insertions(+) create mode 100644 customsettings_template.json diff --git a/aiserver.py b/aiserver.py index 9d34fe9c..87283f6a 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1044,6 +1044,7 @@ def general_startup(override_args=None): parser.add_argument("--no_aria2", action='store_true', default=False, help="Prevents KoboldAI from using aria2 to download huggingface models more efficiently, in case aria2 is causing you issues") parser.add_argument("--lowmem", action='store_true', help="Extra Low Memory loading for the GPU, slower but memory does not peak to twice the usage") parser.add_argument("--savemodel", action='store_true', help="Saves the model to the models folder even if --colab is used (Allows you to save models to Google Drive)") + parser.add_argument("--customsettings", help="Preloads arguements from json file. You only need to provide the location of the json file. Use customsettings.json template file. It can be renamed if you wish so that you can store multiple configurations. Leave any settings you want as default as null. Any values you wish to set need to be in double quotation marks") #args: argparse.Namespace = None if "pytest" in sys.modules and override_args is None: args = parser.parse_args([]) @@ -1057,6 +1058,14 @@ def general_startup(override_args=None): else: args = parser.parse_args() + if args.customsettings: + f = open (args.customsettings) + importedsettings = json.load(f) + for items in importedsettings: + if importedsettings[items] is not None: + setattr(args, items, importedsettings[items]) + f.close() + vars.model = args.model; vars.revision = args.revision diff --git a/customsettings_template.json b/customsettings_template.json new file mode 100644 index 00000000..876af058 --- /dev/null +++ b/customsettings_template.json @@ -0,0 +1,3 @@ +{"aria2_port":null, "breakmodel":null, "breakmodel_disklayers":null, "breakmodel_gpulayers":null, "breakmodel_layers":null, "colab":null, "configname":null, "cpu":null, "host":null, "localtunnel":null, "lowmem":null, "model":null, "ngrok":null, "no_aria2":null, "noaimenu":null, "nobreakmodel":null, "override_delete":null, "override_rename":null, "path":null, "port":null, "quiet":null, "remote":null, "revision":null, "savemodel":null, "unblock":null} + +