diff --git a/start.py b/start.py index 619b07eb..909c47d4 100644 --- a/start.py +++ b/start.py @@ -159,6 +159,23 @@ def migrate_gpu_lib(): ) +def write_start_options_if_first_run(first_run, start_options): + # First run options + if first_run: + start_options["first_run_done"] = True + + # Save start options + with open("start_options.json", "w") as start_file: + start_file.write(json.dumps(start_options)) + + print( + "Successfully wrote your start script options to " + "`start_options.json`. \n" + "If something goes wrong, editing or deleting the file " + "will reinstall TabbyAPI as a first-time user." + ) + + if __name__ == "__main__": subprocess.run(["pip", "-V"]) @@ -236,21 +253,12 @@ def migrate_gpu_lib(): subprocess.run(install_command) print() - if first_run: - start_options["first_run_done"] = True - - # Save start options on first run - with open("start_options.json", "w") as start_file: - start_file.write(json.dumps(start_options)) - - print( - "Successfully wrote your start script options to " - "`start_options.json`. \n" - "If something goes wrong, editing or deleting the file " - "will reinstall TabbyAPI as a first-time user." - ) - if args.update_deps: + # If the update_deps command is run on the first_run (like building + # in a docker container). Then write the start_options to + # avoid re-running + write_start_options_if_first_run(first_run, start_options) + print( f"Dependencies updated. Please run TabbyAPI with `start.{script_ext}`. " "Exiting." @@ -262,6 +270,10 @@ def migrate_gpu_lib(): "inside the `update_scripts` folder." ) + # Write the start_options to a file on the first run to save them for + # subsequent runs + write_start_options_if_first_run(first_run, start_options) + # Expand the parser if it's not fully created if not has_full_parser: from common.args import init_argparser