Skip to content

Commit

Permalink
feat(py): implementation of parse.py; refactor parse.ts and update te…
Browse files Browse the repository at this point in the history
…sts.

CHANGELOG:
- [ ] Add Python implementation of parse.py
- [ ] Add scripts/run_tests to run all tests and update hooks.
- [ ] Update scripts/fmt to make additional python fixes.
- [ ] Update .github/workflows/test.yml to also build the library
  (missing)
- [ ] Add a Role type for the role in types.d.ts and typing.py
- [ ] Add docstrings to Python models in typing.py
- [ ] Configure pyproject.toml to remove unused vars and imports.
- [ ] Switch to testing in the affirmative and go bottom up for Python
  and Go as team wants the CI to complain when the tests fail.
- [ ] Disable a stub test in helpers_test.py until we have a handlebars
  py dependency
- [ ] Add build and test scripts to the root package.json file for
  convenience.
- [ ] Update to pnpm 10.2.0 to keep up with Genkit and setup script.
- [ ] Some lint fixes.
  • Loading branch information
yesudeep committed Feb 25, 2025
1 parent 8200ae4 commit 144393b
Show file tree
Hide file tree
Showing 24 changed files with 1,930 additions and 318 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2024 Google LLC
# SPDX-License-Identifier: Apache-2.0

name: "JS: Run Tests"
name: "JS: Run Tests and Build"

on:
push:
Expand Down Expand Up @@ -38,3 +38,6 @@ jobs:

- name: Run tests
run: cd js && pnpm test

- name: Build
run: cd js && pnpm build
20 changes: 4 additions & 16 deletions captainhook.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,14 @@
{
"run": "scripts/check_license"
},
{
"run": "uv run --directory python ruff check --select I --fix ."
},
{
"run": "uv run --directory python mypy ."
},
{
"run": "scripts/run_python_tests"
},
{
"run": "scripts/run_go_tests"
"run": "scripts/run_tests"
},
{
"run": "scripts/run_js_tests"
"run": "pnpm -C js build"
},
{
"run": "uv run mkdocs build"
Expand Down Expand Up @@ -85,20 +79,14 @@
{
"run": "scripts/check_license"
},
{
"run": "uv run --directory python ruff check --select I --fix ."
},
{
"run": "uv run --directory python mypy ."
},
{
"run": "scripts/run_python_tests"
},
{
"run": "scripts/run_go_tests"
"run": "scripts/run_tests"
},
{
"run": "scripts/run_js_tests"
"run": "pnpm -C js build"
},
{
"run": "uv run mkdocs build"
Expand Down
9 changes: 2 additions & 7 deletions go/dotprompt/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ func Square(n int) int {
return n * n
}

func TestSkipAllFailing(t *testing.T) {
// Currently, since the Go runtime is catching up to the JS runtime implementation
// we skip all failing tests. This test will fail because 2*2 = 4, not 5
// but the CI/pre-commits will not complain.
//
// TODO: Remove this test when the runtime implementation is complete.
assert.Equal(t, 5, Square(2), "This test should fail because 2*2 = 4, not 5")
func TestSquare(t *testing.T) {
assert.Equal(t, 4, Square(2))
}
4 changes: 2 additions & 2 deletions js/examples/adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ input:
);

const openaiResponse = await fetch(
`https://generativelanguage.googleapis.com/v1beta/openai/chat/completions`,
'https://generativelanguage.googleapis.com/v1beta/openai/chat/completions',
{
method: 'POST',
body: JSON.stringify(openaiFormat),
headers: {
'content-type': 'application/json',
authorization: 'Bearer ' + process.env.GOOGLE_GENAI_API_KEY,
authorization: `Bearer ${process.env.GOOGLE_GENAI_API_KEY}`,
},
}
);
Expand Down
4 changes: 2 additions & 2 deletions js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dotprompt",
"version": "1.0.1",
"description": "",
"description": "Dotprompt: Executable GenAI Prompt Templates",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": {
Expand Down Expand Up @@ -35,7 +35,7 @@
"handlebars": "^4.7.8",
"yaml": "^2.5.0"
},
"packageManager": "pnpm@9.13.2+sha256.ccce81bf7498c5f0f80e31749c1f8f03baba99d168f64590fc7e13fad3ea1938",
"packageManager": "pnpm@10.2.0",
"pnpm": {
"overrides": {
"rollup@>=4.0.0 <4.22.4": ">=4.22.4",
Expand Down
Loading

0 comments on commit 144393b

Please sign in to comment.