-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
run LitServe with minimal dependency (#138)
* make minimal dependency * add test * fix * fix test * fix * add license
- Loading branch information
1 parent
4a3721c
commit c89449d
Showing
3 changed files
with
88 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Minimal dependency check | ||
|
||
on: | ||
push: | ||
branches: [main, "release/*"] | ||
pull_request: | ||
branches: [main, "release/*"] | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
pytester: | ||
runs-on: ubuntu-latest | ||
|
||
timeout-minutes: 30 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install LitServe | ||
run: | | ||
pip --version | ||
pip install . psutil -U -q | ||
pip list | ||
- name: Tests | ||
run: python tests/minimal_run.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
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,46 @@ | ||
# Copyright The Lightning AI team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
import subprocess | ||
import psutil | ||
import time | ||
import json | ||
import urllib.request | ||
|
||
|
||
def main(): | ||
process = subprocess.Popen( | ||
["python", "tests/simple_server.py"], | ||
) | ||
print("Waiting for server to start...") | ||
time.sleep(5) | ||
try: | ||
url = "http://127.0.0.1:8000/predict" | ||
data = json.dumps({"input": 4.0}).encode("utf-8") | ||
headers = {"Content-Type": "application/json"} | ||
request = urllib.request.Request(url, data=data, headers=headers, method="POST") | ||
response = urllib.request.urlopen(request) | ||
status_code = response.getcode() | ||
assert status_code == 200 | ||
except Exception: | ||
raise | ||
|
||
finally: | ||
parent = psutil.Process(process.pid) | ||
for child in parent.children(recursive=True): | ||
child.kill() | ||
process.kill() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |