Skip to content

Commit ac0b3a7

Browse files
qingyun-wuYuandong Tiansonichiolgavrou
authored
guide on the usage of docker (microsoft#1111)
* docker documentation * docker doc * clean contribute.md * minor change * Add more detailed description * add docker instructions * more dockerfiles * readme update * latest python * dev docker python version * add version * readme * improve doc * improve doc * path name * naming * Update website/docs/Installation.md Co-authored-by: Chi Wang <[email protected]> * Update website/docs/Installation.md Co-authored-by: Chi Wang <[email protected]> * Add suggestion to install colima for Mac users * Update website/docs/Installation.md Co-authored-by: Chi Wang <[email protected]> * Update website/docs/Installation.md Co-authored-by: olgavrou <[email protected]> * update doc * typo * improve doc * add more options in dev file * contrib * add link to doc * add link * Update website/docs/Installation.md Co-authored-by: Chi Wang <[email protected]> * Update website/docs/Installation.md Co-authored-by: Chi Wang <[email protected]> * instruction * Update website/docs/FAQ.md Co-authored-by: Chi Wang <[email protected]> * FAQ * comment autogen studio --------- Co-authored-by: Yuandong Tian <[email protected]> Co-authored-by: Chi Wang <[email protected]> Co-authored-by: olgavrou <[email protected]>
1 parent be58cc9 commit ac0b3a7

File tree

7 files changed

+127
-29
lines changed

7 files changed

+127
-29
lines changed

README.md

+6-12
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,12 @@ The easiest way to start playing is
6262
3. Start playing with the notebooks!
6363

6464
*NOTE*: OAI_CONFIG_LIST_sample lists GPT-4 as the default model, as this represents our current recommendation, and is known to work well with AutoGen. If you use a model other than GPT-4, you may need to revise various system prompts (especially if using weaker models like GPT-3.5-turbo). Moreover, if you use models other than those hosted by OpenAI or Azure, you may incur additional risks related to alignment and safety. Proceed with caution if updating this default.
65+
## [Installation](https://microsoft.github.io/autogen/docs/Installation)
66+
### Option 1. Install and Run AutoGen in Docker
6567

66-
## Using existing docker image
67-
Install docker, save your oai key into an environment variable name OPENAI_API_KEY, and then run the following.
68+
Find detailed instructions for users [here](https://microsoft.github.io/autogen/docs/Installation#option-1-install-and-run-autogen-in-docker), and for developers [here](https://microsoft.github.io/autogen/docs/Contribute#docker).
6869

69-
```
70-
docker pull yuandongtian/autogen:latest
71-
docker run -it -e OPENAI_API_KEY=$OPENAI_API_KEY -p 8081:8081 docker.io/yuandongtian/autogen:latest
72-
```
73-
74-
Then open `http://localhost:8081/` in your browser to use AutoGen. The UI is from `./samples/apps/autogen-assistant`. See docker hub [link](https://hub.docker.com/r/yuandongtian/autogen) for more details.
75-
76-
## Installation
70+
### Option 2. Install AutoGen Locally
7771

7872
AutoGen requires **Python version >= 3.8, < 3.12**. It can be installed from pip:
7973

@@ -88,11 +82,11 @@ Minimal dependencies are installed without extra options. You can install extra
8882
pip install "pyautogen[blendsearch]"
8983
``` -->
9084

91-
Find more options in [Installation](https://microsoft.github.io/autogen/docs/Installation).
85+
Find more options in [Installation](https://microsoft.github.io/autogen/docs/Installation#option-2-install-autogen-locally-using-virtual-environment).
9286

9387
<!-- Each of the [`notebook examples`](https://github.com/microsoft/autogen/tree/main/notebook) may require a specific option to be installed. -->
9488

95-
For [code execution](https://microsoft.github.io/autogen/docs/FAQ/#code-execution), we strongly recommend installing the Python docker package and using docker.
89+
Even if you are installing AutoGen locally out of docker, we recommend performing [code execution](https://microsoft.github.io/autogen/docs/FAQ/#code-execution) in docker. Find more instructions [here](https://microsoft.github.io/autogen/docs/Installation#docker).
9690

9791
For LLM inference configurations, check the [FAQs](https://microsoft.github.io/autogen/docs/FAQ#set-your-api-endpoints).
9892

samples/dockers/Dockerfile.base

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM python:3.11-slim-bookworm
2+
3+
RUN : \
4+
&& apt-get update \
5+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
6+
software-properties-common \
7+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
8+
python3-venv \
9+
&& apt-get clean \
10+
&& rm -rf /var/lib/apt/lists/* \
11+
&& :
12+
13+
RUN python3 -m venv /venv
14+
ENV PATH=/venv/bin:$PATH
15+
EXPOSE 8081
16+
17+
RUN cd /venv; pip install pyautogen
18+
# Pre-load popular packages as per https://learnpython.com/blog/most-popular-python-packages/
19+
RUN pip install numpy pandas matplotlib seaborn scikit-learn requests urllib3 nltk pillow pytest beautifulsoup4
20+
21+
ENTRYPOINT []

Dockerfile renamed to samples/dockers/Dockerfile.dev

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# basic setup
2-
FROM python:3.10
2+
FROM python:3.11-slim-bookworm
33
RUN apt-get update && apt-get -y update
44
RUN apt-get install -y sudo git npm
55

@@ -13,8 +13,8 @@ USER autogen-dev
1313
RUN cd /home/autogen-dev && git clone https://github.com/microsoft/autogen.git
1414
WORKDIR /home/autogen-dev/autogen
1515

16-
# Install autogen (Note: extra components can be installed if needed)
17-
RUN sudo pip install -e .[test]
16+
# Install autogen in editable mode (Note: extra components can be installed if needed)
17+
RUN sudo pip install -e .[test,teachable,lmm,retrievechat,mathchat,blendsearch]
1818

1919
# Install precommit hooks
2020
RUN pre-commit install
@@ -25,6 +25,9 @@ RUN sudo pip install pydoc-markdown
2525
RUN cd website
2626
RUN yarn install --frozen-lockfile --ignore-engines
2727

28+
# Pre-load popular packages as per https://learnpython.com/blog/most-popular-python-packages/
29+
RUN pip install numpy pandas matplotlib seaborn scikit-learn requests urllib3 nltk pillow pytest beautifulsoup4
30+
2831
# override default image starting point
2932
CMD /bin/bash
3033
ENTRYPOINT []

samples/dockers/Dockerfile.full

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM python:3.11-slim-bookworm
2+
3+
RUN : \
4+
&& apt-get update \
5+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
6+
software-properties-common \
7+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
8+
python3-venv \
9+
&& apt-get clean \
10+
&& rm -rf /var/lib/apt/lists/* \
11+
&& :
12+
13+
RUN python3 -m venv /venv
14+
ENV PATH=/venv/bin:$PATH
15+
EXPOSE 8081
16+
17+
RUN cd /venv; pip install pyautogen[teachable,lmm,retrievechat,mathchat,blendsearch] autogenra
18+
# Pre-load popular packages as per https://learnpython.com/blog/most-popular-python-packages/
19+
RUN pip install numpy pandas matplotlib seaborn scikit-learn requests urllib3 nltk pillow pytest beautifulsoup4
20+
21+
ENTRYPOINT []

website/docs/Contribute.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,19 @@ pip install -e autogen
9797

9898
### Docker
9999

100-
We provide a simple [Dockerfile](https://github.com/microsoft/autogen/blob/main/Dockerfile).
100+
We provide [Dockerfiles](https://github.com/microsoft/autogen/blob/main/samples/dockers/Dockerfile.dev) for developers to use.
101101

102-
```bash
103-
docker build https://github.com/microsoft/autogen.git#main -t autogen-dev
104-
docker run -it autogen-dev
102+
Use the following command line to build and run a docker image.
103+
104+
```
105+
docker build -f samples/dockers/Dockerfile.dev -t autogen_dev_img https://github.com/microsoft/autogen.git#main
106+
107+
docker run -it autogen_dev_img
105108
```
106109

110+
Detailed instructions can be found [here](Installation.md#option-1-install-and-run-autogen-in-docker).
111+
112+
107113
### Develop in Remote Container
108114

109115
If you use vscode, you can open the autogen folder in a [Container](https://code.visualstudio.com/docs/remote/containers).

website/docs/FAQ.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ The `AssistantAgent` doesn't save all the code by default, because there are cas
7171

7272
We strongly recommend using docker to execute code. There are two ways to use docker:
7373

74-
1. Run autogen in a docker container. For example, when developing in GitHub codespace, the autogen runs in a docker container.
75-
2. Run autogen outside of a docker, while perform code execution with a docker container. For this option, make sure the python package `docker` is installed. When it is not installed and `use_docker` is omitted in `code_execution_config`, the code will be executed locally (this behavior is subject to change in future).
74+
1. Run AutoGen in a docker container. For example, when developing in [GitHub codespace](https://codespaces.new/microsoft/autogen?quickstart=1), AutoGen runs in a docker container. If you are not developing in Github codespace, follow instructions [here](Installation.md#option-1-install-and-run-autogen-in-docker) to install and run AutoGen in docker.
75+
2. Run AutoGen outside of a docker, while performing code execution with a docker container. For this option, set up docker and make sure the python package `docker` is installed. When not installed and `use_docker` is omitted in `code_execution_config`, the code will be executed locally (this behavior is subject to change in future).
7676

7777
### Enable Python 3 docker image
7878

website/docs/Installation.md

+61-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,50 @@
11
# Installation
22

3-
## Setup Virtual Environment
3+
## Option 1: Install and Run AutoGen in Docker
44

5-
When not using a docker container, we recommend using a virtual environment to install AutoGen. This will ensure that the dependencies for AutoGen are isolated from the rest of your system.
5+
[Docker](https://www.docker.com/) is a containerization platform that simplifies the setup and execution of your code. A properly built docker image could provide isolated and consistent environment to run your code securely across platforms. One option of using AutoGen is to install and run it in a docker container. You can do that in [Github codespace](https://codespaces.new/microsoft/autogen?quickstart=1) or follow the instructions below to do so.
66

7-
### Option 1: venv
7+
#### Step 1. Install Docker.
8+
9+
Install docker following [this instruction](https://docs.docker.com/get-docker/).
10+
11+
For Mac users, alternatively you may choose to install [colima](https://smallsharpsoftwaretools.com/tutorials/use-colima-to-run-docker-containers-on-macos/) to run docker containers, if there is any issues with starting the docker daemon.
12+
13+
#### Step 2. Build a docker image
14+
15+
AutoGen provides [dockerfiles](https://github.com/microsoft/autogen/tree/main/samples/dockers/) that could be used to build docker images. Use the following command line to build a docker image named `autogen_img` (or other names you prefer) from one of the provided dockerfiles named `Dockerfile.base`:
16+
17+
```
18+
docker build -f samples/dockers/Dockerfile.base -t autogen_img https://github.com/microsoft/autogen.git#main
19+
```
20+
which includes some common python libraries and essential dependencies of AutoGen, or build from `Dockerfile.full` which include additional dependencies for more advanced features of AutoGen with the following command line:
21+
22+
```
23+
docker build -f samples/dockers/Dockerfile.full -t autogen_full_img https://github.com/microsoft/autogen.git
24+
```
25+
Once you build the docker image, you can use `docker images` to check whether it has been created successfully.
26+
27+
#### Step 3. Run applications built with AutoGen from a docker image.
28+
29+
**Mount your code to the docker image and run your application from there:** Now suppose you have your application built with AutoGen in a main script named `twoagent.py` ([example](https://github.com/microsoft/autogen/blob/main/test/twoagent.py)) in a folder named `myapp`. With the command line below, you can mont your folder and run the application in docker.
30+
31+
```python
32+
# Mount the local folder `myapp` into docker image and run the script named "twoagent.py" in the docker.
33+
docker run -it -v `pwd`/myapp:/myapp autogen_img:latest python /myapp/main_twoagent.py
34+
```
35+
36+
<!-- You may also run [AutoGen Studio](https://github.com/microsoft/autogen/tree/main/samples/apps/autogen-studio) (assuming that you have built a docker image named `autogen_full_img` with `Dockerfile.full` and you have set the environment variable `OPENAI_API_KEY` to your OpenAI API key) as below:
37+
38+
```
39+
docker run -it -e OPENAI_API_KEY=$OPENAI_API_KEY -p 8081:8081 autogen_full_img:latest autogenra ui --host 0.0.0.0
40+
```
41+
Then open `http://localhost:8081/` in your browser to use AutoGen Studio. -->
42+
43+
## Option 2: Install AutoGen Locally Using Virtual Environment
44+
45+
When installing AutoGen locally, we recommend using a virtual environment for the installation. This will ensure that the dependencies for AutoGen are isolated from the rest of your system.
46+
47+
### Option a: venv
848

949
You can create a virtual environment with `venv` as below:
1050
```bash
@@ -17,9 +57,9 @@ The following command will deactivate the current `venv` environment:
1757
deactivate
1858
```
1959

20-
### Option 2: conda
60+
### Option b: conda
2161

22-
Another option is with `Conda`, Conda works better at solving dependency conflicts than pip. You can install it by following [this doc](https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html),
62+
Another option is with `Conda`. You can install it by following [this doc](https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html),
2363
and then create a virtual environment as below:
2464
```bash
2565
conda create -n pyautogen python=3.10 # python 3.10 is recommended as it's stable and not too old
@@ -31,7 +71,7 @@ The following command will deactivate the current `conda` environment:
3171
conda deactivate
3272
```
3373

34-
### Option 3: poetry
74+
### Option c: poetry
3575

3676
Another option is with `poetry`, which is a dependency manager for Python.
3777

@@ -93,13 +133,26 @@ Inference parameter tuning can be done via [`flaml.tune`](https://microsoft.gith
93133
### Optional Dependencies
94134
- #### docker
95135

96-
For the best user experience and seamless code execution, we highly recommend using Docker with AutoGen. Docker is a containerization platform that simplifies the setup and execution of your code. Developing in a docker container, such as GitHub Codespace, also makes the development convenient.
136+
Even if you install AutoGen locally, we highly recommend using Docker for [code execution](FAQ.md#enable-python-3-docker-image).
97137

98-
When running AutoGen out of a docker container, to use docker for code execution, you also need to install the python package `docker`:
138+
To use docker for code execution, you also need to install the python package `docker`:
99139
```bash
100140
pip install docker
101141
```
102142

143+
You might want to override the default docker image used for code execution. To do that set `use_docker` key of `code_execution_config` property to the name of the image. E.g.:
144+
```python
145+
user_proxy = autogen.UserProxyAgent(
146+
name="agent",
147+
human_input_mode="TERMINATE",
148+
max_consecutive_auto_reply=10,
149+
code_execution_config={"work_dir":"_output", "use_docker":"python:3"},
150+
llm_config=llm_config,
151+
system_message=""""Reply TERMINATE if the task has been solved at full satisfaction.
152+
Otherwise, reply CONTINUE, or the reason why the task is not solved yet."""
153+
)
154+
```
155+
103156
- #### blendsearch
104157

105158
`pyautogen<0.2` offers a cost-effective hyperparameter optimization technique [EcoOptiGen](https://arxiv.org/abs/2303.04673) for tuning Large Language Models. Please install with the [blendsearch] option to use it.

0 commit comments

Comments
 (0)