Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Conversation

@louis-jan
Copy link
Contributor

@louis-jan louis-jan commented Nov 4, 2024

Describe Your Changes

Users also wanted to import the model using the copy option instead of a symlink. When the original model file was deleted, the model broke in symlink mode.

Screenshot 2024-11-04 at 16 57 01

Changes made

The git diff shows modifications in three files: cortex.json, models.cc, and test_api_model_import.py. Here's a brief summary of the changes:

  1. cortex.json (OpenAPI definition file):

    • A new field "option": "symlink" was added to an example JSON object.
    • A new property "option" was added to the JSON schema, with type "string" and description "Import options such as symlink or copy.".
  2. models.cc (Model controller in C++):

    • Included the <filesystem> header to use file system operations.
    • Extracted a new field option from the request JSON, with a default value of "symlink".
    • Implemented logic in ImportModel to handle model file import based on the option. If option is "copy", it uses std::filesystem::copy_file to copy the GGUF file to the destination. Otherwise, it just adds the current path to model_config.files.
  3. test_api_model_import.py (End-to-end tests for model import):

    • Added a new test method test_model_import_with_name_should_be_success.
    • This test sends a POST request to import a model with option set to "copy".
    • It verifies that the response is successful and checks that the imported file's path is not the original path, assuming it must be copied to a new location.

These changes add flexibility to the model import process, allowing for different import methods (copy or symlink). The tests were updated to verify this new functionality.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2024

Preview URL: https://d9a176f0.cortex-docs.pages.dev

@louis-jan louis-jan merged commit 55bbe0d into dev Nov 4, 2024
5 checks passed
@louis-jan louis-jan deleted the chore/add-import-model-option branch November 4, 2024 10:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants