Skip to content
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

add dev container #648

Merged
merged 17 commits into from
Oct 12, 2023
23 changes: 23 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM python:3.9-slim-bullseye AS base

RUN set -x

RUN apt-get update \
&& apt-get -y install curl \
&& apt-get -y install net-tools \
&& apt-get -y install procps \
&& apt-get -y install build-essential \
&& apt-get -y install docker.io

# specific pip version to workaround: https://github.com/conda/conda/issues/10178
RUN pip install --upgrade pip==20.1.1
RUN pip install ipython ipykernel
RUN ipython kernel install --user --name aml

# FROM base AS promptflow
COPY default_requirements.txt .
RUN pip install -r default_requirements.txt

RUN set +x

CMD bash
17 changes: 17 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Devcontainer for promptflow
To facilitate your promptflow project development and empower you to work on LLM projects using promptflow more effectively,
we've configured the necessary environment for developing promptflow projects and utilizing flows through the dev container feature.
You can seamlessly initiate your promptflow project development and start leveraging flows by simply using the dev container feature via VS Code or Codespaces.

# Use devcontainer
1. Use vscode to open promptflow repo, and install vscode extension: Dev Containers and then open promptflow with dev containers.
![devcontainer](./devcontainers.png)
**About dev containers please refer to: [dev containers](https://code.visualstudio.com/docs/devcontainers/containers)**
2. Use codespaces to open promptflow repo, it will automatically build the dev containers environment and open promptflow with dev containers.
![codespaces](./codespaces.png)

### Notes
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.
1. `docker build -t promptflow_container`
2. `docker run -it promptflow_container`
2. When using the dev containers function, the promptflow and promptflow-tools installed in the container are the code of the current repo.
Binary file added .devcontainer/codespaces.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions .devcontainer/default_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
azure-cli
azure-identity
opencensus-ext-azure
promptflow[azure]
promptflow-tools
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "Promptflow-Python39",
// "context" is the path that the Codespaces docker build command should be run from, relative to devcontainer.json
"context": ".",
"dockerFile": "Dockerfile",

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-toolsai.vscode-ai",
"ms-toolsai.jupyter",
"redhat.vscode-yaml",
"prompt-flow.prompt-flow"
],

// Use 'postCreateCommand' to run commands after the container is created.
"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",

"runArgs": ["-v", "/var/run/docker.sock:/var/run/docker.sock"]
}
Binary file added .devcontainer/devcontainers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions examples/flows/standard/gen-docstring/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
from diff import show_diff
from load_code_tool import load_code
from promptflow import PFClient
from pathlib import Path


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

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