Skip to content

Commit 8f04d2e

Browse files
authored
add dev container (#648)
# Description Please add an informative description that covers that changes made by the pull request and link all relevant issues. # All Promptflow Contribution checklist: - [x] **The pull request does not introduce [breaking changes].** - [ ] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [ ] **I have read the [contribution guidelines](../CONTRIBUTING.md).** - [ ] **Create an issue and link to the pull request to get dedicated review from promptflow team. Learn more: [suggested workflow](../CONTRIBUTING.md#suggested-workflow).** ## General Guidelines and Best Practices - [x] Title of the pull request is clear and informative. - [ ] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md). ### Testing Guidelines - [x] Pull request includes test coverage for the included changes.
1 parent cb7788e commit 8f04d2e

File tree

7 files changed

+74
-2
lines changed

7 files changed

+74
-2
lines changed

.devcontainer/Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM python:3.9-slim-bullseye AS base
2+
3+
RUN set -x
4+
5+
RUN apt-get update \
6+
&& apt-get -y install curl \
7+
&& apt-get -y install net-tools \
8+
&& apt-get -y install procps \
9+
&& apt-get -y install build-essential \
10+
&& apt-get -y install docker.io
11+
12+
# specific pip version to workaround: https://github.com/conda/conda/issues/10178
13+
RUN pip install --upgrade pip==20.1.1
14+
RUN pip install ipython ipykernel
15+
RUN ipython kernel install --user --name aml
16+
17+
# FROM base AS promptflow
18+
COPY default_requirements.txt .
19+
RUN pip install -r default_requirements.txt
20+
21+
RUN set +x
22+
23+
CMD bash

.devcontainer/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Devcontainer for promptflow
2+
To facilitate your promptflow project development and empower you to work on LLM projects using promptflow more effectively,
3+
we've configured the necessary environment for developing promptflow projects and utilizing flows through the dev container feature.
4+
You can seamlessly initiate your promptflow project development and start leveraging flows by simply using the dev container feature via VS Code or Codespaces.
5+
6+
# Use devcontainer
7+
1. Use vscode to open promptflow repo, and install vscode extension: Dev Containers and then open promptflow with dev containers.
8+
![devcontainer](./devcontainers.png)
9+
**About dev containers please refer to: [dev containers](https://code.visualstudio.com/docs/devcontainers/containers)**
10+
2. Use codespaces to open promptflow repo, it will automatically build the dev containers environment and open promptflow with dev containers.
11+
![codespaces](./codespaces.png)
12+
13+
### Notes
14+
1. If you only want to try out promptflow without developing promptflow, you can simply install Docker and use promptflow within Docker without the need for using DevContainers functionality.
15+
1. `docker build -t promptflow_container`
16+
2. `docker run -it promptflow_container`
17+
2. When using the dev containers function, the promptflow and promptflow-tools installed in the container are the code of the current repo.

.devcontainer/codespaces.png

49.2 KB
Loading
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
azure-cli
2+
azure-identity
3+
opencensus-ext-azure
4+
promptflow[azure]
5+
promptflow-tools

.devcontainer/devcontainer.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "Promptflow-Python39",
3+
// "context" is the path that the Codespaces docker build command should be run from, relative to devcontainer.json
4+
"context": ".",
5+
"dockerFile": "Dockerfile",
6+
7+
// Set *default* container specific settings.json values on container create.
8+
"settings": {
9+
"terminal.integrated.shell.linux": "/bin/bash"
10+
},
11+
12+
// Add the IDs of extensions you want installed when the container is created.
13+
"extensions": [
14+
"ms-python.python",
15+
"ms-toolsai.vscode-ai",
16+
"ms-toolsai.jupyter",
17+
"redhat.vscode-yaml",
18+
"prompt-flow.prompt-flow"
19+
],
20+
21+
// Use 'postCreateCommand' to run commands after the container is created.
22+
"postCreateCommand": "pip install -r ${containerWorkspaceFolder}/src/promptflow-tools/requirements.txt --force-reinstall;pip install -r ${containerWorkspaceFolder}/src/promptflow/dev_requirements.txt --force-reinstall;pip install -e ${containerWorkspaceFolder}/src/promptflow-tools;pip install -e ${containerWorkspaceFolder}/src/promptflow",
23+
24+
"runArgs": ["-v", "/var/run/docker.sock:/var/run/docker.sock"]
25+
}

.devcontainer/devcontainers.png

22.7 KB
Loading

examples/flows/standard/gen-docstring/main.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
from diff import show_diff
44
from load_code_tool import load_code
55
from promptflow import PFClient
6+
from pathlib import Path
67

78

89
if __name__ == "__main__":
10+
current_folder = Path(__file__).absolute().parent
911
parser = argparse.ArgumentParser(description="The code path of code that need to generate docstring.")
10-
parser.add_argument("--source", help="Path for the code file", default='./azure_open_ai.py')
12+
parser.add_argument("--source", help="Path for the code file", default=str(current_folder / 'azure_open_ai.py'))
1113
args = parser.parse_args()
1214

1315
pf = PFClient()
1416
source = args.source
15-
flow_result = pf.test(flow="./", inputs={"source": source})
17+
flow_result = pf.test(flow=str(current_folder), inputs={"source": source})
1618
show_diff(load_code(source), flow_result['code'], File(source).filename)

0 commit comments

Comments
 (0)