-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop copying truss server code over for "custom server" (#1189)
* update * update * tag * fix * check * check * update * update * update * check to test * check to test * update * ervert tag * fix test * lint * lint * update * lint * lint * check * lint * update * update * update * update * update * update * update * make liveness_endpoint and readiness_endpoint optional * docker_server config assertion * lint * sleep 3 * sleep comments * lint --------- Co-authored-by: Tianshu Cheng <tianshuc@Tianshus-MacBook-Pro.local> Co-authored-by: Tianshu Cheng <tianshuc@Tianshus-MBP.MG8702> Co-authored-by: Tianshu Cheng <tianshuc@Tianshus-MBP.localdomain> Co-authored-by: Tianshu Cheng <tianshuc@Mac.MG8702>
- Loading branch information
1 parent
7472bb6
commit 6964ddd
Showing
17 changed files
with
93 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 16 additions & 5 deletions
21
truss/tests/test_trussless_docker_server.py → truss/tests/test_custom_server.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,38 @@ | ||
import pytest | ||
import requests | ||
from tenacity import stop_after_attempt | ||
|
||
from truss.local.local_config_handler import LocalConfigHandler | ||
from truss.tests.test_testing_utilities_for_other_tests import ensure_kill_all | ||
from truss.truss_handle.truss_handle import TrussHandle | ||
|
||
|
||
@pytest.mark.integration | ||
def test_docker_server_truss(test_data_path): | ||
def test_custom_server_truss(test_data_path): | ||
with ensure_kill_all(): | ||
truss_dir = test_data_path / "test_docker_server_truss" | ||
|
||
print("Running test_custom_server_truss") | ||
truss_dir = test_data_path / "test_custom_server_truss" | ||
print(f"truss_dir: {truss_dir}") | ||
tr = TrussHandle(truss_dir) | ||
print("Setting secret") | ||
LocalConfigHandler.set_secret("hf_access_token", "123") | ||
_ = tr.docker_run(local_port=8090, detach=True, wait_for_server_ready=True) | ||
try: | ||
print("Starting container") | ||
_ = tr.docker_run( | ||
local_port=8090, | ||
detach=True, | ||
wait_for_server_ready=True, | ||
model_server_stop_retry_override=stop_after_attempt(3), | ||
) | ||
except Exception as e: | ||
raise Exception(f"Failed to start container: {e}") | ||
truss_server_addr = "http://localhost:8090" | ||
full_url = f"{truss_server_addr}/v1/models/model:predict" | ||
|
||
response = requests.post(full_url, json={}) | ||
assert response.status_code == 200 | ||
assert response.json() == { | ||
"message": "Hello World", | ||
"is_torch_cuda_available": False, | ||
"is_env_var_passed": True, | ||
"is_secret_mounted": True, | ||
} |
File renamed without changes.
10 changes: 3 additions & 7 deletions
10
...data/test_docker_server_truss/config.yaml → ...data/test_custom_server_truss/config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
base_image: | ||
image: baseten/fastapi-test:0.1.1 | ||
image: baseten/fastapi-test:0.1.2 | ||
docker_server: | ||
start_command: fastapi dev /home/app.py | ||
readiness_endpoint: /health | ||
liveness_endpoint: /health | ||
start_command: python main.py | ||
predict_endpoint: /predict | ||
server_port: 8000 | ||
resources: | ||
accelerator: null | ||
cpu: '1' | ||
memory: 2Gi | ||
use_gpu: false | ||
requirements: | ||
- torch>=2.0.1 | ||
model_name: Test Docker Server Truss | ||
secrets: | ||
hf_access_token: null | ||
environment_variables: | ||
HF_TOKEN: 123 | ||
HF_TOKEN: 123456 | ||
runtime: | ||
predict_concurrency: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
truss/tests/test_data/test_custom_server_truss/test_docker_image/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
We built this minimal fastapi docker image to be used in integration test `test_custom_server_truss.py::test_custom_server_truss` | ||
|
||
Steps to update testing docker image | ||
|
||
1. run `docker login` | ||
2. cd into this directory | ||
3. update version number in VERSION file | ||
(before running the next step, make sure you meet with the [prerequisites](https://docs.docker.com/build/building/multi-platform/#prerequisites) here) | ||
4. run `sh build_upload_new_image.sh` | ||
5. update image tag to latest version in config.yaml |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
9 changes: 0 additions & 9 deletions
9
truss/tests/test_data/test_docker_server_truss/test_docker_image/README.md
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters