Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down Expand Up @@ -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."
Expand All @@ -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
Expand Down