|
| 1 | +import argparse |
1 | 2 | import logging
|
2 |
| -from servicefoundry import Build, PythonBuild, Service, Resources |
| 3 | +from servicefoundry import Build, PythonBuild, Service, Resources, Port |
3 | 4 |
|
4 | 5 | logging.basicConfig(level=logging.INFO)
|
5 | 6 |
|
| 7 | +parser = argparse.ArgumentParser() |
| 8 | +parser.add_argument("--name", required=True, type=str, help="Name of the application.") |
| 9 | +parser.add_argument( |
| 10 | + "--workspace_fqn", |
| 11 | + required=True, |
| 12 | + type=str, |
| 13 | + help="FQN of the workspace where application will be deployed.", |
| 14 | +) |
| 15 | +parser.add_argument( |
| 16 | + "--host", |
| 17 | + required=True, |
| 18 | + type=str, |
| 19 | + help="Host where the application will be available for access. Ex:- my-app.my-org.com", |
| 20 | +) |
| 21 | +args = parser.parse_args() |
| 22 | + |
6 | 23 | image = Build(
|
7 | 24 | build_spec=PythonBuild(
|
8 | 25 | command="uvicorn app:app --port 8000 --host 0.0.0.0",
|
9 |
| - requirements_path="requirements.txt" |
| 26 | + requirements_path="requirements.txt", |
10 | 27 | )
|
11 | 28 | )
|
12 | 29 |
|
13 | 30 | service = Service(
|
14 |
| - name="ml-deploy", |
| 31 | + name=args.name, |
15 | 32 | image=image,
|
16 |
| - ports=[{"port": 8000}], |
17 |
| - resources=Resources(memory_limit=1500, memory_request=1000), |
18 |
| - env={ |
19 |
| - "UVICORN_WEB_CONCURRENCY": "1", |
20 |
| - "ENVIRONMENT": "dev" |
21 |
| - } |
| 33 | + ports=[Port(port=8000, host=args.host)], |
| 34 | + resources=Resources( |
| 35 | + cpu_request=0.1, |
| 36 | + cpu_limit=0.1, |
| 37 | + memory_request=500, |
| 38 | + memory_limit=500, |
| 39 | + ), |
| 40 | + env={"UVICORN_WEB_CONCURRENCY": "1", "ENVIRONMENT": "dev"}, |
22 | 41 | )
|
23 |
| -service.deploy(workspace_fqn="YOUR_WORKSPACE_FQN") |
| 42 | +service.deploy(workspace_fqn=args.workspace_fqn) |
0 commit comments