Skip to content

Commit 37231dc

Browse files
authored
Update run-examples tests (#139)
* Update run-examples tests * Schedule the action to run every day at 1 am
1 parent 3b0ff32 commit 37231dc

File tree

6 files changed

+32
-12
lines changed

6 files changed

+32
-12
lines changed

.github/workflows/run-examples.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
name: Run examples
33

44
on:
5+
schedule:
6+
- cron: '0 1 * * *'
57
workflow_dispatch:
68

79
jobs:
@@ -38,4 +40,8 @@ jobs:
3840
pip install pipdeptree
3941
pipdeptree -fl
4042
- name: run tests
43+
env:
44+
WATSONX_PROJECT_ID: ${{ secrets.WATSONX_PROJECT_ID }}
45+
WATSONX_APIKEY: ${{ secrets.WATSONX_APIKEY }}
46+
WATSONX_URL: ${{ secrets.WATSONX_URL }}
4147
run: py.test -v --capture=tee-sys tests/test_examples_run.py
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
The weather in Yorktown Heights, New York, USA is currently partly cloudy with a temperature of 15.6°C (60.1°F). The wind speed is 10.1 mph (16.2 kph) from the NNW direction. The humidity is 40%, and the visibility is 16 km (9 miles). The UV index is 3.4, and there is no precipitation. The feels-like temperature is 15.6°C (60.1°F), and the wind chill is 13.7°C (56.6°F). The heat index is 14.4°C (58.0°F), and the dew point is 3.8°C (38.8°F). The pressure is 1017 mb (30.02 in).

tests/results/examples/react/wikipedia.result

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ Act:{"name": "Search", "arguments": {"topic": "discoverer of the Hudson River"}}
2222
The Hudson River runs through the Munsee, Lenape, Mohican, Mohawk, and Haudenosaunee homelands. Prior to European exploration, the river was known as the Mahicannittuk by the Mohicans, Ka'nón:no by the Mohawks, and Muhheakantuck by the Lenape. The river was subsequently named after Henry Hudson, an Englishman sailing for the Dutch East India Company who explored it in 1609, and after whom Hudson Bay in Canada is also named. It had previously been observed by Italian explorer Giovanni da Verrazzano sailing for King Francis I of France in 1524, as he became the first European known to have entered the Upper New York Bay, but he considered the river to be an estuary. The Dutch called the river the North River, and they called the present-day Delaware River the South River, which formed the spine of the Dutch colony of New Netherland. Settlements of the colony clustered around the Hudson, and its strategic importance as the gateway to the American interior led to years of competition between the English and the Dutch over control of the river and colony.
2323
During the 18th century, the river valley and its inhabitants were the subject and inspiration of Washington Irving, the first internationally acclaimed American author. In the nineteenth century, the area inspired the Hudson River School of landscape painting, an American pastoral style, as well as the concepts of environmentalism and wilderness. The Hudson River was also the eastern outlet for the Erie Canal, which, when completed in 1825, became an important transportation artery for the early 19th century United States.
2424
Pollution in the Hudson River increased in the 20th century, more acutely by mid-century, particularly with industrial contamination from polychlorinated biphenyls, also known by their acronym PCBs. Pollution control regulations, enforcement actions and restoration projects initiated in the latter 20th century have begun to improve water quality, and restoration work has continued in the 21st century.
25-
26-
Tho: The discoverer of the Hudson River is Henry Hudson. I need to search Henry Hudson, find when he was born.
25+
Tho: The discoverer of the Hudson River is Henry Hudson. I need to search Henry Hudson, find when he was born.
2726
Act:{"name": "Search", "arguments": {"topic": "Henry Hudson"}}Obs: Henry Hudson (c. 1565 – disappeared 23 June 1611) was an English sea explorer and navigator during the early 17th century, best known for his explorations of present-day Canada and parts of the Northeastern United States.
2827
In 1607 and 1608, Hudson made two attempts on behalf of English merchants to find a rumoured Northeast Passage to Cathay via a route above the Arctic Circle. In 1609, he landed in North America on behalf of the Dutch East India Company and explored the region around the modern New York metropolitan area. Looking for a Northwest Passage to Asia on his ship Halve Maen ("Half Moon"), he sailed up the Hudson River, which was later named after him, and thereby laid the foundation for Dutch colonization of the region. His contributions to the exploration of the New World were significant and lasting. His voyages helped to establish European contact with the native peoples of North America and contributed to the development of trade and commerce.
2928
On his final expedition, while still searching for the Northwest Passage, Hudson became the first European to see Hudson Strait and the immense Hudson Bay. In 1611, after wintering on the shore of James Bay, Hudson wanted to press on to the west, but most of his crew mutinied. The mutineers cast Hudson, his son, and six others adrift; the Hudsons and their companions were never seen again.

tests/results/examples/talk/9-react.result

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ Act:{"name": "Search", "arguments": {"topic": "discoverer of the Hudson River"}}
2222
The Hudson River runs through the Munsee, Lenape, Mohican, Mohawk, and Haudenosaunee homelands. Prior to European exploration, the river was known as the Mahicannittuk by the Mohicans, Ka'nón:no by the Mohawks, and Muhheakantuck by the Lenape. The river was subsequently named after Henry Hudson, an Englishman sailing for the Dutch East India Company who explored it in 1609, and after whom Hudson Bay in Canada is also named. It had previously been observed by Italian explorer Giovanni da Verrazzano sailing for King Francis I of France in 1524, as he became the first European known to have entered the Upper New York Bay, but he considered the river to be an estuary. The Dutch called the river the North River, and they called the present-day Delaware River the South River, which formed the spine of the Dutch colony of New Netherland. Settlements of the colony clustered around the Hudson, and its strategic importance as the gateway to the American interior led to years of competition between the English and the Dutch over control of the river and colony.
2323
During the 18th century, the river valley and its inhabitants were the subject and inspiration of Washington Irving, the first internationally acclaimed American author. In the nineteenth century, the area inspired the Hudson River School of landscape painting, an American pastoral style, as well as the concepts of environmentalism and wilderness. The Hudson River was also the eastern outlet for the Erie Canal, which, when completed in 1825, became an important transportation artery for the early 19th century United States.
2424
Pollution in the Hudson River increased in the 20th century, more acutely by mid-century, particularly with industrial contamination from polychlorinated biphenyls, also known by their acronym PCBs. Pollution control regulations, enforcement actions and restoration projects initiated in the latter 20th century have begun to improve water quality, and restoration work has continued in the 21st century.
25-
26-
Tho: The discoverer of the Hudson River is Henry Hudson. I need to search Henry Hudson, find when he was born.
25+
Tho: The discoverer of the Hudson River is Henry Hudson. I need to search Henry Hudson, find when he was born.
2726
Act:{"name": "Search", "arguments": {"topic": "Henry Hudson"}}Obs: Henry Hudson (c. 1565 – disappeared 23 June 1611) was an English sea explorer and navigator during the early 17th century, best known for his explorations of present-day Canada and parts of the Northeastern United States.
2827
In 1607 and 1608, Hudson made two attempts on behalf of English merchants to find a rumoured Northeast Passage to Cathay via a route above the Arctic Circle. In 1609, he landed in North America on behalf of the Dutch East India Company and explored the region around the modern New York metropolitan area. Looking for a Northwest Passage to Asia on his ship Halve Maen ("Half Moon"), he sailed up the Hudson River, which was later named after him, and thereby laid the foundation for Dutch colonization of the region. His contributions to the exploration of the New World were significant and lasting. His voyages helped to establish European contact with the native peoples of North America and contributed to the development of trade and commerce.
2928
On his final expedition, while still searching for the Northwest Passage, Hudson became the first European to see Hudson Strait and the immense Hudson Bay. In 1611, after wintering on the shore of James Bay, Hudson wanted to press on to the west, but most of his crew mutinied. The mutineers cast Hudson, his son, and six others adrift; the Hudsons and their companions were never seen again.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
The temperature is 15.6 degrees Celsius and the sky is partly cloudy.

tests/test_examples_run.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
str(name)
1616
for name in [
1717
pathlib.Path("examples") / "demo" / "2-teacher.pdl", # TODO: check why
18+
pathlib.Path("examples") / "talk" / "8-tools.pdl", # TODO: check why
1819
pathlib.Path("examples") / "talk" / "11-sdg.pdl", # TODO: check why
1920
pathlib.Path("examples") / "teacher" / "teacher.pdl", # TODO: check why
20-
pathlib.Path("examples") / "demo" / "3-weather.pdl",
21+
pathlib.Path("examples") / "tools" / "calc.pdl", # TODO: check why
2122
pathlib.Path("examples") / "tutorial" / "calling_apis.pdl",
2223
pathlib.Path("examples") / "cldk" / "cldk-assistant.pdl",
23-
pathlib.Path("examples") / "weather" / "weather.pdl",
2424
pathlib.Path("examples") / "talk" / "10-multi-agent.pdl",
2525
pathlib.Path("examples") / "gsm8k" / "gsmhard-bugs.pdl",
2626
pathlib.Path("examples") / "gsm8k" / "math-base.pdl",
@@ -38,11 +38,16 @@
3838
pathlib.Path("examples") / "granite" / "multi_round_chat.pdl",
3939
pathlib.Path("examples") / "granite" / "single_round_chat.pdl",
4040
pathlib.Path("examples") / "joke" / "Joke.pdl",
41-
# pathlib.Path("examples") / "react" / "multi-agent.pdl",
41+
pathlib.Path("examples") / "react" / "multi-agent.pdl",
4242
pathlib.Path("examples") / "talk" / "11-sdg.pdl",
4343
pathlib.Path("examples") / "talk" / "7-chatbot-roles.pdl",
44+
pathlib.Path("examples") / "talk" / "8-tools.pdl",
4445
pathlib.Path("examples") / "teacher" / "teacher.pdl",
46+
pathlib.Path("examples") / "tools" / "calc.pdl",
4547
pathlib.Path("examples") / "tutorial" / "include.pdl",
48+
pathlib.Path("examples") / "hello" / "hello-roles-array.pdl",
49+
pathlib.Path("examples") / "weather" / "weather.pdl",
50+
pathlib.Path("examples") / "demo" / "3-weather.pdl",
4651
]
4752
}
4853

@@ -83,6 +88,14 @@ class InputsType:
8388
pathlib.Path("examples")
8489
/ "hello"
8590
/ "hello-data.pdl": InputsType(scope={"something": "ABC"}),
91+
pathlib.Path("examples")
92+
/ "weather"
93+
/ "weather.pdl": InputsType(stdin="What is the weather in Yorktown Heights?\n"),
94+
pathlib.Path("examples")
95+
/ "demo"
96+
/ "3-weather.pdl": InputsType(
97+
stdin="What is the weather in Yorktown Heights?\n"
98+
),
8699
}.items()
87100
}
88101

@@ -134,9 +147,6 @@ def test_valid_programs(capsys, monkeypatch) -> None:
134147
wrong_results = {}
135148
for pdl_file_name in pathlib.Path(".").glob("**/*.pdl"):
136149
scope: ScopeType = {}
137-
print(str(pdl_file_name))
138-
# if "cldk" in str(pdl_file_name):
139-
# pass
140150
if str(pdl_file_name) in TO_SKIP:
141151
continue
142152
if str(pdl_file_name) in TESTS_WITH_INPUT:
@@ -167,14 +177,16 @@ def test_valid_programs(capsys, monkeypatch) -> None:
167177
result_dir_name / result_file_name, "r", encoding="utf-8"
168178
) as result_file:
169179
expected_result = str(result_file.read())
170-
if str(result) != expected_result:
180+
if str(result).strip() != expected_result.strip():
171181
wrong_results[str(pdl_file_name)] = {
172182
"actual": str(result),
173183
"expected": str(expected_result),
174184
}
175185
except PDLParseError:
176186
actual_parse_error |= {str(pdl_file_name)}
177-
except PDLRuntimeError:
187+
except PDLRuntimeError as exc:
188+
if str(pdl_file_name) not in set(str(p) for p in EXPECTED_RUNTIME_ERROR):
189+
print(exc) # unexpected error: breakpoint
178190
actual_runtime_error |= {str(pdl_file_name)}
179191
# Parse errors
180192
expected_parse_error = set(str(p) for p in EXPECTED_PARSE_ERROR)

0 commit comments

Comments
 (0)