Skip to content

Commit

Permalink
docs: highlight the example code (#1748)
Browse files Browse the repository at this point in the history
Signed-off-by: Keming <kemingyang@tensorchord.ai>
  • Loading branch information
kemingy committed Aug 23, 2023
1 parent a0d1efb commit 1aa4a8f
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 24 deletions.
6 changes: 3 additions & 3 deletions envd/api/v0/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def run(commands: List[str], mount_host: bool = False):
Enabling this will disable the build cache for this operation.
Example:
```
```python
run(commands=["conda install -y -c conda-forge exa"])
```
"""
Expand All @@ -70,7 +70,7 @@ def git_config(
editor (optional, str): Editor for git operations
Example usage:
```
```python
git_config(name="My Name", email="my@email.com", editor="vim")
```
"""
Expand All @@ -86,7 +86,7 @@ def include(git: str):
git (str): git URL
Example usage:
```
```python
envd = include("https://github.com/tensorchord/envdlib")
def build():
Expand Down
8 changes: 4 additions & 4 deletions envd/api/v0/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def apt_source(source: Optional[str]):
"""Configure apt sources
Example usage:
```
```python
apt_source(source='''
deb https://mirror.sjtu.edu.cn/ubuntu focal main restricted
deb https://mirror.sjtu.edu.cn/ubuntu focal-updates main restricted
Expand Down Expand Up @@ -71,7 +71,7 @@ def conda_channel(channel: str):
"""Configure conda channel mirror
Example usage:
```
```python
config.conda_channel(channel='''
channels:
- defaults
Expand All @@ -94,7 +94,7 @@ def entrypoint(args: List[str]):
"""Configure entrypoint for custom base image
Example usage:
```
```python
config.entrypoint(["date", "-u"])
```
Expand All @@ -107,7 +107,7 @@ def gpu(count: int):
"""Configure the number of GPUs required
Example usage:
```
```python
config.gpu(count=2)
```
Expand Down
6 changes: 3 additions & 3 deletions envd/api/v0/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def command(commands: Dict[str, str]):
commands (Dict[str, str]): map name to command, similar to Makefile
Example usage:
```
```python
runtime.command(commands={
"train": "python train.py --epoch 20 --notify me@tensorchord.ai",
"run": "python server.py --batch 1 --host 0.0.0.0 --port 8000",
Expand Down Expand Up @@ -73,7 +73,7 @@ def daemon(commands: List[List[str]]):
commands (List[List[str]]): run multiple commands in the background
Example usage:
```
```python
runtime.daemon(commands=[
["jupyter-lab", "--port", "8080"],
["python3", "serving.py", ">>serving.log", "2>&1"],
Expand All @@ -90,7 +90,7 @@ def environ(env: Dict[str, str], extra_path: List[str]):
extra_path (List[str]): additional PATH
Example usage:
```
```python
runtime.environ(env={"ENVD_MODE": "DEV"}, extra_path=["/usr/bin/go/bin"])
```
"""
Expand Down
8 changes: 4 additions & 4 deletions envd/api/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def run(commands: List[str], mount_host: bool = False):
Enabling this will disable the build cache for this operation.
Example:
```
```python
run(commands=["conda install -y -c conda-forge exa"])
```
"""
Expand All @@ -71,15 +71,15 @@ def git_config(
email: Optional[str] = None,
editor: Optional[str] = None,
):
"""Setup git config
"""Setup git config.
Args:
name (str): User name
email (str): User email
editor (str): Editor for git operations
Example usage:
```
```python
git_config(name="My Name", email="my@email.com", editor="vim")
```
"""
Expand All @@ -95,7 +95,7 @@ def include(git: str):
git (str): git URL
Example usage:
```
```python
envd = include("https://github.com/tensorchord/envdlib")
def build():
Expand Down
8 changes: 4 additions & 4 deletions envd/api/v1/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def apt_source(source: Optional[str]):
"""Configure apt sources
Example usage:
```
```python
apt_source(source='''
deb https://mirror.sjtu.edu.cn/ubuntu focal main restricted
deb https://mirror.sjtu.edu.cn/ubuntu focal-updates main restricted
Expand Down Expand Up @@ -77,7 +77,7 @@ def conda_channel(channel: str):
"""Configure conda channel mirror
Example usage:
```
```python
config.conda_channel(channel='''
channels:
- defaults
Expand All @@ -100,7 +100,7 @@ def entrypoint(args: List[str]):
"""Configure entrypoint for custom base image
Example usage:
```
```python
config.entrypoint(["date", "-u"])
```
Expand All @@ -113,7 +113,7 @@ def gpu(count: int):
"""Configure the number of GPUs required
Example usage:
```
```python
config.gpu(count=2)
```
Expand Down
10 changes: 8 additions & 2 deletions envd/api/v1/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,16 @@ def vscode_extensions(name: List[str]):
def cuda(version: str, cudnn: Optional[str] = "8"):
"""Replace the base image with a `nvidia/cuda` image.
If you want to install CUDA on your custom base image, you can use
`install.apt_packages` or `run` to install the CUDA toolkit.
This will replace the default base image to an `nvidia/cuda` image. You can
also use a CUDA base image directly like
`base(image="nvidia/cuda:12.2.0-devel-ubuntu20.04", dev=True)`.
Args:
version (str): CUDA version, such as '11.6.2'
cudnn (optional, str): CUDNN version, such as '8'
Example usage:
```python
install.cuda(version="11.6.2", cudnn="8")
```
"""
2 changes: 1 addition & 1 deletion envd/api/v1/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def copy(source: str, target: str, image: Optional[str]):
image(Optional[str]): image name, if not specified, will use the host
Examples:
```
```python
# copy from host to container
io.copy(source='main.py', target='/home/envd/')
# copy from image to container
Expand Down
6 changes: 3 additions & 3 deletions envd/api/v1/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def command(commands: Dict[str, str]):
commands (Dict[str, str]): map name to command, similar to Makefile
Example usage:
```
```python
runtime.command(commands={
"train": "python train.py --epoch 20 --notify me@tensorchord.ai",
"run": "python server.py --batch 1 --host 0.0.0.0 --port 8000",
Expand Down Expand Up @@ -79,7 +79,7 @@ def daemon(commands: List[List[str]]):
commands (List[List[str]]): run multiple commands in the background
Example usage:
```
```python
runtime.daemon(commands=[
["jupyter-lab", "--port", "8080"],
["python3", "serving.py", ">>serving.log", "2>&1"],
Expand All @@ -96,7 +96,7 @@ def environ(env: Dict[str, str], extra_path: List[str]):
extra_path (List[str]): additional PATH
Example usage:
```
```python
runtime.environ(env={"ENVD_MODE": "DEV"}, extra_path=["/usr/bin/go/bin"])
```
"""
Expand Down

0 comments on commit 1aa4a8f

Please sign in to comment.