forked from microsoft/semantic-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_getting_started.py
More file actions
101 lines (91 loc) · 3.3 KB
/
test_getting_started.py
File metadata and controls
101 lines (91 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Copyright (c) Microsoft. All rights reserved.
import os
import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
from pytest import mark, param
from traitlets.config import Config
c = Config()
c.RegexRemovePreprocessor.patterns = ["^!pip .*"]
c.ExecutePreprocessor.exclude_input_prompt = True
# These environment variable names are used to control which samples are run during integration testing.
# This has to do with the setup of the tests and the services they depend on.
COMPLETIONS_CONCEPT_SAMPLE = "COMPLETIONS_CONCEPT_SAMPLE"
MEMORY_CONCEPT_SAMPLE = "MEMORY_CONCEPT_SAMPLE"
def run_notebook(notebook_name: str):
with open(f"samples/getting_started/{notebook_name}") as f:
nb = nbformat.read(f, as_version=4)
ep = ExecutePreprocessor(timeout=600, kernel_name="python3", config=c)
ep.preprocess(nb, {"metadata": {"path": "samples/getting_started/"}})
notebooks = [
param(
"00-getting-started.ipynb",
marks=mark.skipif(
os.getenv(COMPLETIONS_CONCEPT_SAMPLE, None) is None, reason="Not running completion samples."
),
),
param(
"01-basic-loading-the-kernel.ipynb",
marks=mark.skipif(
os.getenv(COMPLETIONS_CONCEPT_SAMPLE, None) is None, reason="Not running completion samples."
),
),
param(
"02-running-prompts-from-file.ipynb",
marks=mark.skipif(
os.getenv(COMPLETIONS_CONCEPT_SAMPLE, None) is None, reason="Not running completion samples."
),
),
param(
"03-prompt-function-inline.ipynb",
marks=mark.skipif(
os.getenv(COMPLETIONS_CONCEPT_SAMPLE, None) is None, reason="Not running completion samples."
),
),
param(
"04-kernel-arguments-chat.ipynb",
marks=mark.skipif(
os.getenv(COMPLETIONS_CONCEPT_SAMPLE, None) is None, reason="Not running completion samples."
),
),
param(
"05-using-the-planner.ipynb",
marks=mark.skip("Sample is known to be blocked by Azure OpenAI content policy."),
),
param(
"06-memory-and-embeddings.ipynb",
marks=mark.skipif(os.getenv(MEMORY_CONCEPT_SAMPLE, None) is None, reason="Not running memory samples."),
),
param(
"07-hugging-face-for-plugins.ipynb",
marks=mark.skipif(
os.getenv(COMPLETIONS_CONCEPT_SAMPLE, None) is None, reason="Not running completion samples."
),
),
param(
"08-native-function-inline.ipynb",
marks=mark.skipif(
os.getenv(COMPLETIONS_CONCEPT_SAMPLE, None) is None, reason="Not running completion samples."
),
),
param(
"09-groundedness-checking.ipynb",
marks=mark.skipif(
os.getenv(COMPLETIONS_CONCEPT_SAMPLE, None) is None, reason="Not running completion samples."
),
),
param(
"10-multiple-results-per-prompt.ipynb",
marks=mark.skipif(
os.getenv(COMPLETIONS_CONCEPT_SAMPLE, None) is None, reason="Not running completion samples."
),
),
param(
"11-streaming-completions.ipynb",
marks=mark.skipif(
os.getenv(COMPLETIONS_CONCEPT_SAMPLE, None) is None, reason="Not running completion samples."
),
),
]
@mark.parametrize("name", notebooks)
def test_notebooks(name):
run_notebook(name)