8000 doc: v1 by kemingy · Pull Request #1284 · tensorchord/envd · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

doc: v1 #1284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 15, 2022
Merged

doc: v1 #1284

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions envd/__init__.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
105 changes: 105 additions & 0 deletions envd/api/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Copyright 2022 The envd Authors
#
# 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.

"""# v1 syntax

::: tip
Note that the documentation is automatically generated from [envd/api](https://github.com/tensorchord/envd/tree/main/envd/api) folder
in [tensorchord/envd](https://github.com/tensorchord/envd/tree/main/envd/api) repo.
Please update the python file there instead of directly editing file inside envd-docs repo.
:::

::: warning
Enable v1 by adding `# syntax=v1` to the 1st line of your envd file.

v1 is experimental and may change in the future. Make sure to freeze the envd version for online CI/CD.
:::
"""

from typing import Optional

"""## Universe
"""


def base(image: str = "ubuntu:20.04", dev: bool = False):
"""Set up the base env.

Args:
image (str): docker image, can be any Debian-based images
dev (bool): enabling the dev env will add lots of development related libraries like
envd-sshd, vim, git, shell prompt, vscode extensions, etc.
"""


def shell(name: str = "base"):
"""Interactive shell

Args:
name (str): shell name (i.e. `zsh`, `bash`)
"""


def run(commands: str, mount_host: bool = False):
"""Execute command

Args:
commands (str): command to run during the building process
mount_host (bool): mount the host directory. Default is False.
Enabling this will disable the build cache for this operation.

Example:
```
run(commands=["conda install -y -c conda-forge exa"])
```
"""


def git_config(
name: Optional[str] = None,
email: Optional[str] = None,
editor: Optional[str] = None,
):
"""Setup git config

Args:
name (str): User name
email (str): User email
editor (str): Editor for git operations

Example usage:
```
git_config(name="My Name", email="my@email.com", editor="vim")
```
"""


def include(git: str):
"""Import from another git repo

This will pull the git repo and execute all the `envd` files. The return value will be a module
contains all the variables/functions defined (expect those has `_` prefix).

Args:
git (str): git URL

Example usage:
```
envd = include("https://github.com/tensorchord/envdlib")

def build():
base(os="ubuntu20.04", language="python")
envd.tensorboard(host_port=8000)
```
"""
153 changes: 153 additions & 0 deletions envd/api/v1/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Copyright 2022 The envd Authors
#
# 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.

"""Config functions

::: tip
Note that the documentation is automatically generated from [envd/api](https://github.com/tensorchord/envd/tree/main/envd/api) folder
in [tensorchord/envd](https://github.com/tensorchord/envd/tree/main/envd/api) repo.
Please update the python file there instead of directly editing file inside envd-docs repo.
:::

::: warning
Enable v1 by adding `# syntax=v1` to the 1st line of your envd file.

v1 is experimental and may change in the future. Make sure to freeze the envd version for online CI/CD.
:::
"""

from typing import List, Optional


def apt_source(source: Optional[str]):
"""Configure apt sources

Example usage:
```
apt_source(source='''
deb https://mirror.sjtu.edu.cn/ubuntu focal main restricted
deb https://mirror.sjtu.edu.cn/ubuntu focal-updates main restricted
deb https://mirror.sjtu.edu.cn/ubuntu focal universe
deb https://mirror.sjtu.edu.cn/ubuntu focal-updates universe
deb https://mirror.sjtu.edu.cn/ubuntu focal multiverse
deb https://mirror.sjtu.edu.cn/ubuntu focal-updates multiverse
deb https://mirror.sjtu.edu.cn/ubuntu focal-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu focal partner
deb https://mirror.sjtu.edu.cn/ubuntu focal-security main restricted universe multiverse
''')
```

Args:
source (str, optional): The apt source configuration
"""


def jupyter(token: str, port: int):
"""Configure jupyter notebook configuration

Args:
token (str): Token for access authentication
port (int): Port to serve jupyter notebook
"""


def pip_index(url: str, extra_url: str):
"""Configure pypi index mirror

Args:
url (str): PyPI index URL (i.e. https://mirror.sjtu.edu.cn/pypi/web/simple)
extra_url (str): PyPI extra index URL. `url` and `extra_url` will be
treated equally, see https://github.com/pypa/pip/issues/8606
"""


def conda_channel(channel: str):
"""Configure conda channel mirror

Example usage:
```
config.conda_channel(channel='''
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
''')
```

Args:
channel (str): Basically the same with file content of an usual .condarc
"""


def entrypoint(args: List[str]):
"""Configure entrypoint for custom base image

Example usage:
```
config.entrypoint(["date", "-u"])
```

Args:
args (List[str]): list of arguments to run
"""


def gpu(count: int):
"""Configure the number of GPUs required

Example usage:
```
config.gpu(count=2)
```

Args:
count (int): number of GPUs
"""


def cran_mirror(url: str):
"""Configure the mirror URL, default is https://cran.rstudio.com

Args:
url (str): mirror URL
"""


def julia_pkg_server(url: str):
"""Configure the package server for Julia.
Since Julia 1.5, https://pkg.julialang.org is the default pkg server.

Args:
url (str): Julia pkg server URL
"""


def rstudio_server():
"""
Enable the RStudio Server (only work for `base(os="ubuntu20.04", language="r")`)
"""


def repo(url: str, description: str):
"""Setup repo related information. Will save to the image labels.

Args:
url (str): repo URL
description (str): repo description
"""
Loading
0