Skip to content

Commit 8e185cc

Browse files
davorrunjevictordibia
authored andcommitted
CRLF changed to LF (#2915)
1 parent b63ad9e commit 8e185cc

File tree

9 files changed

+1283
-1283
lines changed

9 files changed

+1283
-1283
lines changed

.devcontainer/Dockerfile

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
#-------------------------------------------------------------------------------------------------------------
2-
# Copyright (c) Microsoft Corporation. All rights reserved.
3-
# Licensed under the MIT License. See LICENSE file in the project root for license information.
4-
#-------------------------------------------------------------------------------------------------------------
5-
6-
FROM mcr.microsoft.com/vscode/devcontainers/python:3.10
7-
8-
#
9-
# Update the OS and maybe install packages
10-
#
11-
ENV DEBIAN_FRONTEND=noninteractive
12-
13-
# add git lhs to apt
14-
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
15-
16-
RUN apt-get update \
17-
&& apt-get upgrade -y \
18-
&& apt-get -y install --no-install-recommends build-essential npm git-lfs \
19-
&& apt-get autoremove -y \
20-
&& apt-get clean -y \
21-
&& arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) \
22-
&& wget https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.23/quarto-1.5.23-linux-${arch}.deb \
23-
&& dpkg -i quarto-1.5.23-linux-${arch}.deb \
24-
&& rm -rf /var/lib/apt/lists/* quarto-1.5.23-linux-${arch}.deb
25-
ENV DEBIAN_FRONTEND=dialog
26-
27-
# For docs
28-
RUN npm install --global yarn
29-
RUN pip install --upgrade pip
30-
RUN pip install pydoc-markdown
31-
RUN pip install pyyaml
32-
RUN pip install colored
1+
#-------------------------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See LICENSE file in the project root for license information.
4+
#-------------------------------------------------------------------------------------------------------------
5+
6+
FROM mcr.microsoft.com/vscode/devcontainers/python:3.10
7+
8+
#
9+
# Update the OS and maybe install packages
10+
#
11+
ENV DEBIAN_FRONTEND=noninteractive
12+
13+
# add git lhs to apt
14+
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
15+
16+
RUN apt-get update \
17+
&& apt-get upgrade -y \
18+
&& apt-get -y install --no-install-recommends build-essential npm git-lfs \
19+
&& apt-get autoremove -y \
20+
&& apt-get clean -y \
21+
&& arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) \
22+
&& wget https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.23/quarto-1.5.23-linux-${arch}.deb \
23+
&& dpkg -i quarto-1.5.23-linux-${arch}.deb \
24+
&& rm -rf /var/lib/apt/lists/* quarto-1.5.23-linux-${arch}.deb
25+
ENV DEBIAN_FRONTEND=dialog
26+
27+
# For docs
28+
RUN npm install --global yarn
29+
RUN pip install --upgrade pip
30+
RUN pip install pydoc-markdown
31+
RUN pip install pyyaml
32+
RUN pip install colored

.devcontainer/studio/Dockerfile

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
#-------------------------------------------------------------------------------------------------------------
2-
# Copyright (c) Microsoft Corporation. All rights reserved.
3-
# Licensed under the MIT License. See LICENSE file in the project root for license information.
4-
#-------------------------------------------------------------------------------------------------------------
5-
6-
FROM mcr.microsoft.com/vscode/devcontainers/python:3.10
7-
8-
#
9-
# Update the OS and maybe install packages
10-
#
11-
ENV DEBIAN_FRONTEND=noninteractive
12-
13-
# add git lhs to apt
14-
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
15-
16-
RUN apt-get update \
17-
&& apt-get upgrade -y \
18-
&& apt-get -y install --no-install-recommends build-essential npm git-lfs \
19-
&& apt-get autoremove -y \
20-
&& apt-get clean -y \
21-
&& rm -rf /var/lib/apt/lists/*
22-
ENV DEBIAN_FRONTEND=dialog
23-
24-
# For docs
25-
RUN npm install --global yarn
26-
RUN pip install --upgrade pip
27-
RUN pip install pydoc-markdown
1+
#-------------------------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See LICENSE file in the project root for license information.
4+
#-------------------------------------------------------------------------------------------------------------
5+
6+
FROM mcr.microsoft.com/vscode/devcontainers/python:3.10
7+
8+
#
9+
# Update the OS and maybe install packages
10+
#
11+
ENV DEBIAN_FRONTEND=noninteractive
12+
13+
# add git lhs to apt
14+
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
15+
16+
RUN apt-get update \
17+
&& apt-get upgrade -y \
18+
&& apt-get -y install --no-install-recommends build-essential npm git-lfs \
19+
&& apt-get autoremove -y \
20+
&& apt-get clean -y \
21+
&& rm -rf /var/lib/apt/lists/*
22+
ENV DEBIAN_FRONTEND=dialog
23+
24+
# For docs
25+
RUN npm install --global yarn
26+
RUN pip install --upgrade pip
27+
RUN pip install pydoc-markdown

test/test_notebook.py

+137-137
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,137 @@
1-
#!/usr/bin/env python3 -m pytest
2-
3-
import os
4-
import sys
5-
6-
import pytest
7-
from conftest import skip_openai
8-
9-
try:
10-
import openai
11-
except ImportError:
12-
skip = True
13-
else:
14-
skip = False or skip_openai
15-
16-
17-
here = os.path.abspath(os.path.dirname(__file__))
18-
19-
20-
def run_notebook(input_nb, output_nb="executed_openai_notebook.ipynb", save=False):
21-
import nbformat
22-
from nbconvert.preprocessors import CellExecutionError, ExecutePreprocessor
23-
24-
try:
25-
nb_loc = os.path.join(here, os.pardir, "notebook")
26-
file_path = os.path.join(nb_loc, input_nb)
27-
with open(file_path) as nb_file:
28-
nb = nbformat.read(nb_file, as_version=4)
29-
preprocessor = ExecutePreprocessor(timeout=4800, kernel_name="python3")
30-
preprocessor.preprocess(nb, {"metadata": {"path": nb_loc}})
31-
32-
output_file_name = "executed_openai_notebook_output.txt"
33-
output_file = os.path.join(here, output_file_name)
34-
with open(output_file, "a") as nb_output_file:
35-
for cell in nb.cells:
36-
if cell.cell_type == "code" and "outputs" in cell:
37-
for output in cell.outputs:
38-
if "text" in output:
39-
nb_output_file.write(output["text"].strip() + "\n")
40-
elif "data" in output and "text/plain" in output["data"]:
41-
nb_output_file.write(output["data"]["text/plain"].strip() + "\n")
42-
except CellExecutionError:
43-
raise
44-
finally:
45-
if save:
46-
with open(os.path.join(here, output_nb), "w", encoding="utf-8") as nb_executed_file:
47-
nbformat.write(nb, nb_executed_file)
48-
49-
50-
@pytest.mark.skipif(
51-
skip or not sys.version.startswith("3.10"),
52-
reason="do not run if openai is not installed or py!=3.10",
53-
)
54-
def test_agentchat_auto_feedback_from_code(save=False):
55-
run_notebook("agentchat_auto_feedback_from_code_execution.ipynb", save=save)
56-
57-
58-
@pytest.mark.skipif(
59-
skip or not sys.version.startswith("3.11"),
60-
reason="do not run if openai is not installed or py!=3.11",
61-
)
62-
def _test_oai_completion(save=False):
63-
run_notebook("oai_completion.ipynb", save=save)
64-
65-
66-
@pytest.mark.skipif(
67-
skip or not sys.version.startswith("3.12"),
68-
reason="do not run if openai is not installed or py!=3.12",
69-
)
70-
def test_agentchat_function_call(save=False):
71-
run_notebook("agentchat_function_call.ipynb", save=save)
72-
73-
74-
@pytest.mark.skipif(
75-
skip or not sys.version.startswith("3.10"),
76-
reason="do not run if openai is not installed or py!=3.10",
77-
)
78-
def test_agentchat_function_call_currency_calculator(save=False):
79-
run_notebook("agentchat_function_call_currency_calculator.ipynb", save=save)
80-
81-
82-
@pytest.mark.skipif(
83-
skip or not sys.version.startswith("3.11"),
84-
reason="do not run if openai is not installed or py!=3.11",
85-
)
86-
def test_agentchat_function_call_async(save=False):
87-
run_notebook("agentchat_function_call_async.ipynb", save=save)
88-
89-
90-
@pytest.mark.skipif(
91-
skip or not sys.version.startswith("3.12"),
92-
reason="do not run if openai is not installed or py!=3.12",
93-
)
94-
def _test_agentchat_MathChat(save=False):
95-
run_notebook("agentchat_MathChat.ipynb", save=save)
96-
97-
98-
@pytest.mark.skipif(
99-
skip or not sys.version.startswith("3.10"),
100-
reason="do not run if openai is not installed or py!=3.10",
101-
)
102-
def _test_oai_chatgpt_gpt4(save=False):
103-
run_notebook("oai_chatgpt_gpt4.ipynb", save=save)
104-
105-
106-
@pytest.mark.skipif(
107-
skip or not sys.version.startswith("3.12"),
108-
reason="do not run if openai is not installed or py!=3.12",
109-
)
110-
def test_agentchat_groupchat_finite_state_machine(save=False):
111-
run_notebook("agentchat_groupchat_finite_state_machine.ipynb", save=save)
112-
113-
114-
@pytest.mark.skipif(
115-
skip or not sys.version.startswith("3.10"),
116-
reason="do not run if openai is not installed or py!=3.10",
117-
)
118-
def test_agentchat_cost_token_tracking(save=False):
119-
run_notebook("agentchat_cost_token_tracking.ipynb", save=save)
120-
121-
122-
@pytest.mark.skipif(
123-
skip or not sys.version.startswith("3.11"),
124-
reason="do not run if openai is not installed or py!=3.11",
125-
)
126-
def test_agentchat_groupchat_stateflow(save=False):
127-
run_notebook("agentchat_groupchat_stateflow.ipynb", save=save)
128-
129-
130-
if __name__ == "__main__":
131-
# test_agentchat_auto_feedback_from_code(save=True)
132-
# test_oai_chatgpt_gpt4(save=True)
133-
# test_oai_completion(save=True)
134-
# test_agentchat_MathChat(save=True)
135-
# test_agentchat_function_call(save=True)
136-
# test_graph_modelling_language_using_select_speaker(save=True)
137-
test_agentchat_function_call_async(save=True)
1+
#!/usr/bin/env python3 -m pytest
2+
3+
import os
4+
import sys
5+
6+
import pytest
7+
from conftest import skip_openai
8+
9+
try:
10+
import openai
11+
except ImportError:
12+
skip = True
13+
else:
14+
skip = False or skip_openai
15+
16+
17+
here = os.path.abspath(os.path.dirname(__file__))
18+
19+
20+
def run_notebook(input_nb, output_nb="executed_openai_notebook.ipynb", save=False):
21+
import nbformat
22+
from nbconvert.preprocessors import CellExecutionError, ExecutePreprocessor
23+
24+
try:
25+
nb_loc = os.path.join(here, os.pardir, "notebook")
26+
file_path = os.path.join(nb_loc, input_nb)
27+
with open(file_path) as nb_file:
28+
nb = nbformat.read(nb_file, as_version=4)
29+
preprocessor = ExecutePreprocessor(timeout=4800, kernel_name="python3")
30+
preprocessor.preprocess(nb, {"metadata": {"path": nb_loc}})
31+
32+
output_file_name = "executed_openai_notebook_output.txt"
33+
output_file = os.path.join(here, output_file_name)
34+
with open(output_file, "a") as nb_output_file:
35+
for cell in nb.cells:
36+
if cell.cell_type == "code" and "outputs" in cell:
37+
for output in cell.outputs:
38+
if "text" in output:
39+
nb_output_file.write(output["text"].strip() + "\n")
40+
elif "data" in output and "text/plain" in output["data"]:
41+
nb_output_file.write(output["data"]["text/plain"].strip() + "\n")
42+
except CellExecutionError:
43+
raise
44+
finally:
45+
if save:
46+
with open(os.path.join(here, output_nb), "w", encoding="utf-8") as nb_executed_file:
47+
nbformat.write(nb, nb_executed_file)
48+
49+
50+
@pytest.mark.skipif(
51+
skip or not sys.version.startswith("3.10"),
52+
reason="do not run if openai is not installed or py!=3.10",
53+
)
54+
def test_agentchat_auto_feedback_from_code(save=False):
55+
run_notebook("agentchat_auto_feedback_from_code_execution.ipynb", save=save)
56+
57+
58+
@pytest.mark.skipif(
59+
skip or not sys.version.startswith("3.11"),
60+
reason="do not run if openai is not installed or py!=3.11",
61+
)
62+
def _test_oai_completion(save=False):
63+
run_notebook("oai_completion.ipynb", save=save)
64+
65+
66+
@pytest.mark.skipif(
67+
skip or not sys.version.startswith("3.12"),
68+
reason="do not run if openai is not installed or py!=3.12",
69+
)
70+
def test_agentchat_function_call(save=False):
71+
run_notebook("agentchat_function_call.ipynb", save=save)
72+
73+
74+
@pytest.mark.skipif(
75+
skip or not sys.version.startswith("3.10"),
76+
reason="do not run if openai is not installed or py!=3.10",
77+
)
78+
def test_agentchat_function_call_currency_calculator(save=False):
79+
run_notebook("agentchat_function_call_currency_calculator.ipynb", save=save)
80+
81+
82+
@pytest.mark.skipif(
83+
skip or not sys.version.startswith("3.11"),
84+
reason="do not run if openai is not installed or py!=3.11",
85+
)
86+
def test_agentchat_function_call_async(save=False):
87+
run_notebook("agentchat_function_call_async.ipynb", save=save)
88+
89+
90+
@pytest.mark.skipif(
91+
skip or not sys.version.startswith("3.12"),
92+
reason="do not run if openai is not installed or py!=3.12",
93+
)
94+
def _test_agentchat_MathChat(save=False):
95+
run_notebook("agentchat_MathChat.ipynb", save=save)
96+
97+
98+
@pytest.mark.skipif(
99+
skip or not sys.version.startswith("3.10"),
100+
reason="do not run if openai is not installed or py!=3.10",
101+
)
102+
def _test_oai_chatgpt_gpt4(save=False):
103+
run_notebook("oai_chatgpt_gpt4.ipynb", save=save)
104+
105+
106+
@pytest.mark.skipif(
107+
skip or not sys.version.startswith("3.12"),
108+
reason="do not run if openai is not installed or py!=3.12",
109+
)
110+
def test_agentchat_groupchat_finite_state_machine(save=False):
111+
run_notebook("agentchat_groupchat_finite_state_machine.ipynb", save=save)
112+
113+
114+
@pytest.mark.skipif(
115+
skip or not sys.version.startswith("3.10"),
116+
reason="do not run if openai is not installed or py!=3.10",
117+
)
118+
def test_agentchat_cost_token_tracking(save=False):
119+
run_notebook("agentchat_cost_token_tracking.ipynb", save=save)
120+
121+
122+
@pytest.mark.skipif(
123+
skip or not sys.version.startswith("3.11"),
124+
reason="do not run if openai is not installed or py!=3.11",
125+
)
126+
def test_agentchat_groupchat_stateflow(save=False):
127+
run_notebook("agentchat_groupchat_stateflow.ipynb", save=save)
128+
129+
130+
if __name__ == "__main__":
131+
# test_agentchat_auto_feedback_from_code(save=True)
132+
# test_oai_chatgpt_gpt4(save=True)
133+
# test_oai_completion(save=True)
134+
# test_agentchat_MathChat(save=True)
135+
# test_agentchat_function_call(save=True)
136+
# test_graph_modelling_language_using_select_speaker(save=True)
137+
test_agentchat_function_call_async(save=True)

0 commit comments

Comments
 (0)