This repository has been archived by the owner on Oct 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84f855e
commit 3e841f1
Showing
5 changed files
with
100 additions
and
0 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,69 @@ | ||
## Deploy endpoints from different files at a time | ||
|
||
lc-serve also allows you to deploy endpoints from different files at a time. This is useful when you want to deploy endpoints from different files at a time. | ||
|
||
```bash | ||
. | ||
├── app1.py | ||
├── app2.py | ||
├── __init__.py | ||
└── README.md | ||
``` | ||
|
||
```python | ||
# app1.py | ||
from lcserve import serving | ||
|
||
@serving | ||
def one() -> int: | ||
return 1 | ||
``` | ||
|
||
|
||
```python | ||
# app2.py | ||
from lcserve import serving | ||
|
||
@serving | ||
def two() -> int: | ||
return 2 | ||
|
||
``` | ||
|
||
```python | ||
# __init__.py | ||
try: | ||
from .app1 import one | ||
from .app2 import two | ||
except ImportError: | ||
from app1 import one | ||
from app2 import two | ||
``` | ||
|
||
There are 2 ways to deploy this. | ||
|
||
1. Inside the `dirname` where the files are located. | ||
|
||
```bash | ||
lc-serve deploy jcloud . | ||
``` | ||
|
||
2. Outside the `dirname` where the files are located. | ||
|
||
```bash | ||
lc-serve deploy jcloud dirname | ||
``` | ||
|
||
|
||
##### Gotcha | ||
|
||
To support both the ways on JCloud, you'd need to allow both ways of importing from the app files. e.g.- | ||
|
||
```python | ||
# __init__.py | ||
try: | ||
from .app1 import one | ||
except ImportError: | ||
from app1 import one | ||
``` | ||
|
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,6 @@ | ||
try: | ||
from .app1 import one | ||
from .app2 import two | ||
except ImportError: | ||
from app1 import one | ||
from app2 import two |
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,6 @@ | ||
from lcserve import serving | ||
|
||
|
||
@serving | ||
def one() -> int: | ||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from lcserve import serving | ||
|
||
|
||
@serving | ||
def two() -> int: | ||
return 2 |
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