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

Commit 620db2a

Browse files
vansangpfievsangjanaihiento09
authored
fix: add hugging face token into configuration file (#1441)
* fix: add HF token to header * fix: build * fix: add header to model download if host is HF * fix: enable e2e tests * fix: e2e tests * fix: more * f:m * fix: add hfToken to cortexrc * fix: rename * fix: e2e tests * ci: add huggingface token to run e2e testing * chore: remove HUGGINGFACE_TOKEN_READ --------- Co-authored-by: vansangpfiev <sang@jan.ai> Co-authored-by: Hien To <tominhhien97@gmail.com>
1 parent 9f89860 commit 620db2a

18 files changed

+178
-93
lines changed

.github/workflows/cortex-cpp-quality-gate.yml

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -106,36 +106,50 @@ jobs:
106106
cd engine
107107
make run-unit-tests
108108
109-
# - name: Run e2e tests
110-
# if: runner.os != 'Windows' && github.event.pull_request.draft == false
111-
# run: |
112-
# cd engine
113-
# cp build/cortex build/cortex-nightly
114-
# cp build/cortex build/cortex-beta
115-
# python -m pip install --upgrade pip
116-
# python -m pip install pytest
117-
# python -m pip install requests
118-
# python e2e-test/main.py
119-
# rm build/cortex-nightly
120-
# rm build/cortex-beta
121-
# env:
122-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123-
124-
125-
# - name: Run e2e tests
126-
# if: runner.os == 'Windows' && github.event.pull_request.draft == false
127-
# run: |
128-
# cd engine
129-
# cp build/cortex.exe build/cortex-nightly.exe
130-
# cp build/cortex.exe build/cortex-beta.exe
131-
# python -m pip install --upgrade pip
132-
# python -m pip install pytest
133-
# python -m pip install requests
134-
# python e2e-test/main.py
135-
# rm build/cortex-nightly.exe
136-
# rm build/cortex-beta.exe
137-
# env:
138-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109+
- name: Run setup config for macos
110+
if: runner.os == 'macOS'
111+
run: |
112+
cd engine
113+
./build/cortex --version
114+
sed -i '' 's/huggingFaceToken: ""/huggingFaceToken: "${{ secrets.HUGGINGFACE_TOKEN_READ }}"/' ~/.cortexrc
115+
116+
- name: Run setup config for linux
117+
if: runner.os != 'macOS'
118+
shell: bash
119+
run: |
120+
cd engine
121+
./build/cortex --version
122+
sed -i 's/huggingFaceToken: ""/huggingFaceToken: "${{ secrets.HUGGINGFACE_TOKEN_READ }}"/' ~/.cortexrc
123+
124+
- name: Run e2e tests
125+
if: runner.os != 'Windows' && github.event.pull_request.draft == false
126+
run: |
127+
cd engine
128+
cp build/cortex build/cortex-nightly
129+
cp build/cortex build/cortex-beta
130+
python -m pip install --upgrade pip
131+
python -m pip install pytest
132+
python -m pip install requests
133+
python e2e-test/main.py
134+
rm build/cortex-nightly
135+
rm build/cortex-beta
136+
env:
137+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138+
139+
- name: Run e2e tests
140+
if: runner.os == 'Windows' && github.event.pull_request.draft == false
141+
run: |
142+
cd engine
143+
cp build/cortex.exe build/cortex-nightly.exe
144+
cp build/cortex.exe build/cortex-beta.exe
145+
python -m pip install --upgrade pip
146+
python -m pip install pytest
147+
python -m pip install requests
148+
python e2e-test/main.py
149+
rm build/cortex-nightly.exe
150+
rm build/cortex-beta.exe
151+
env:
152+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139153

140154
- name: Pre-package
141155
run: |

.github/workflows/template-build-linux-x64.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,6 @@ jobs:
135135
uses: actions/setup-python@v4
136136
with:
137137
python-version: '3.10'
138-
139-
# - name: Run e2e tests
140-
# run: |
141-
# cd engine
142-
# cp build/cortex build/cortex-nightly
143-
# cp build/cortex build/cortex-beta
144-
# python -m pip install --upgrade pip
145-
# python -m pip install pytest
146-
# python -m pip install requests
147-
# python e2e-test/main.py
148-
# rm build/cortex-nightly
149-
# rm build/cortex-beta
150-
# env:
151-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
152138

153139
- name: Pre-package
154140
run: |

.github/workflows/template-build-macos.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,6 @@ jobs:
149149
run: |
150150
cd engine
151151
make build CMAKE_EXTRA_FLAGS="${{ inputs.cmake-flags }} ${{ matrix.extra-cmake-flags }}" BUILD_DEPS_CMAKE_EXTRA_FLAGS="${{ inputs.build-deps-cmake-flags }}"
152-
153-
# - name: Run e2e tests
154-
# run: |
155-
# cd engine
156-
# cp build/cortex build/cortex-nightly
157-
# cp build/cortex build/cortex-beta
158-
# python -m pip install --upgrade pip
159-
# python -m pip install pytest
160-
# python -m pip install requests
161-
# python e2e-test/main.py
162-
# rm build/cortex-nightly
163-
# rm build/cortex-beta
164-
# env:
165-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
166152
167153
- name: Pre-package
168154
run: |

.github/workflows/template-build-windows-x64.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -172,20 +172,6 @@ jobs:
172172
with:
173173
python-version: '3.10'
174174

175-
# - name: Run e2e tests
176-
# run: |
177-
# cd engine
178-
# cp build/cortex.exe build/cortex-nightly.exe
179-
# cp build/cortex.exe build/cortex-beta.exe
180-
# python -m pip install --upgrade pip
181-
# python -m pip install pytest
182-
# python -m pip install requests
183-
# python e2e-test/main.py
184-
# rm build/cortex-nightly.exe
185-
# rm build/cortex-beta.exe
186-
# env:
187-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
188-
189175
- name: Pre-package
190176
run: |
191177
cd engine

engine/cli/commands/engine_uninstall_cmd.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void EngineUninstallCmd::Exec(const std::string& host, int port,
2121
auto res = cli.Delete("/v1/engines/" + engine);
2222
if (res) {
2323
if (res->status == httplib::StatusCode::OK_200) {
24-
CLI_LOG("Engine " + engine + " uninstalled successfully");
24+
CLI_LOG("Engine " + engine + " uninstalled successfully!");
2525
} else {
2626
CTL_ERR("Engine failed to uninstall with status code: " << res->status);
2727
}

engine/e2e-test/test_api_model_pull_direct_url.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def setup_and_teardown(self):
2222
yield
2323

2424
# Teardown
25-
stop_server()
2625
run(
2726
"Delete model",
2827
[
@@ -31,6 +30,7 @@ def setup_and_teardown(self):
3130
"TheBloke:TinyLlama-1.1B-Chat-v0.3-GGUF:tinyllama-1.1b-chat-v0.3.Q2_K.gguf",
3231
],
3332
)
33+
stop_server()
3434

3535
def test_model_pull_with_direct_url_should_be_success(self):
3636
myobj = {

engine/e2e-test/test_api_model_start.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def setup_and_teardown(self):
1515

1616
# TODO: using pull with branch for easy testing tinyllama:gguf for example
1717
run("Delete model", ["models", "delete", "tinyllama:gguf"])
18-
popen(["pull", "tinyllama"], "1\n")
18+
run("Pull model", ["pull", "tinyllama:gguf"], timeout=None,)
1919

2020
yield
2121

engine/e2e-test/test_api_model_update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ def setup_and_teardown(self):
1919

2020
def test_models_update_should_be_successful(self):
2121
body_json = {'model': 'tinyllama:gguf'}
22-
response = requests.post("http://localhost:3928/models/tinyllama:gguf", json = body_json)
22+
response = requests.patch("http://localhost:3928/models/tinyllama:gguf", json = body_json)
2323
assert response.status_code == 200

engine/e2e-test/test_cli_engine_get.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,21 @@
22

33
import pytest
44
from test_runner import run
5-
5+
from test_runner import start_server, stop_server
66

77
class TestCliEngineGet:
8+
9+
@pytest.fixture(autouse=True)
10+
def setup_and_teardown(self):
11+
# Setup
12+
success = start_server()
13+
if not success:
14+
raise Exception("Failed to start server")
15+
16+
yield
17+
18+
# Teardown
19+
stop_server()
820

921
@pytest.mark.skipif(platform.system() != "Windows", reason="Windows-specific test")
1022
def test_engines_get_tensorrt_llm_should_not_be_incompatible(self):

engine/e2e-test/test_cli_engine_list.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,22 @@
22

33
import pytest
44
from test_runner import run
5-
5+
from test_runner import start_server, stop_server
66

77
class TestCliEngineList:
8+
9+
@pytest.fixture(autouse=True)
10+
def setup_and_teardown(self):
11+
# Setup
12+
success = start_server()
13+
if not success:
14+
raise Exception("Failed to start server")
15+
16+
yield
17+
18+
# Teardown
19+
stop_server()
20+
821
@pytest.mark.skipif(platform.system() != "Windows", reason="Windows-specific test")
922
def test_engines_list_run_successfully_on_windows(self):
1023
exit_code, output, error = run("List engines", ["engines", "list"])

0 commit comments

Comments
 (0)