Add cookiecutter template for scaffolding new QType projects#154
Conversation
Co-authored-by: lou-k <1943106+lou-k@users.noreply.github.com>
There was a problem hiding this comment.
A few changes requested.
In addition please:
Add a github action that tests the template
This should run on each pr. It should stop if nothing in the template directory changed between the PR and head of the branch.
It should:
- run cookiecutter on
templatewith a hard codednamelike "PR Test" - Cd into the directory
- Run
uv sync - Run
uv run qtype validate ..to validate the yaml file (you'll need to set a dummy openai key) - run
uv run qtype convert ....tools.pyand save the output to{{cookiecutter...}}tools.qtype.yaml. Then ensure nothing has changed. if the tools file has changed, fail the pr - Run
docker buildto ensure the docker image builds correctly
| "args": [ | ||
| "run", | ||
| "{{ cookiecutter.__slug }}.qtype.yaml", | ||
| "--flow", |
There was a problem hiding this comment.
let's not be so specific here -- just set up to use inputs in vs code launch and tack them on the end of the args. That way people can put anything they want
There was a problem hiding this comment.
Updated in commit 7dedc43. The "QType Run (CLI)" config now uses ${input:cliArgs} appended to the args, with a promptString input defined in the inputs section so users can type whatever they need at launch time.
| COPY {{ cookiecutter.__module }}/ ./{{ cookiecutter.__module }}/ | ||
|
|
||
| # Install the project and all dependencies | ||
| RUN uv pip install --system . |
There was a problem hiding this comment.
since the dependencies are likely heavier than the source code, and the source code changes more often, I think this line should be swapped with line 10. That way the python dependencies get cached on builds
There was a problem hiding this comment.
Swapped the order in commit 7dedc43 — pyproject.toml is now copied and dependencies installed before the source module is added, so the heavy dep layer gets cached on subsequent builds when only source changes.
|
|
||
| [project] | ||
| name = "{{ cookiecutter.project_name }}" | ||
| version = "0.1.0" |
There was a problem hiding this comment.
nit: 0.0.1 for initial please
lou-k
left a comment
There was a problem hiding this comment.
A few changes requested.
In addition please:
Add a github action that tests the template
This should run on each pr. It should stop if nothing in the template directory changed between the PR and head of the branch.
It should:
- run cookiecutter on
templatewith a hard codednamelike "PR Test" - Cd into the directory
- Run
uv sync - Run
uv run qtype validate ..to validate the yaml file (you'll need to set a dummy openai key) - run
uv run qtype convert ....tools.pyand save the output to{{cookiecutter...}}tools.qtype.yaml. Then ensure nothing has changed. if the tools file has changed, fail the pr - Run
docker buildto ensure the docker image builds correctly
…, and CI workflow Co-authored-by: lou-k <1943106+lou-k@users.noreply.github.com>
Added
|
lou-k
left a comment
There was a problem hiding this comment.
your test fails with:
Run uv sync
error: Failed to parse: `pyproject.toml`
Caused by: TOML parse error at line 6, column 8
|
6 | name = "PR Test"
| ^^^^^^^^^
Not a valid package or extra name: "PR Test". Names must start and end with a letter or digit and may only contain -, _, ., and alphanumeric characters.
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified FilesNo covered modified files...
|
Co-authored-by: lou-k <1943106+lou-k@users.noreply.github.com>
Fixed in commit 4d1d6af — the |
Description / purpose of change(s):
Adds a
template/directory at the repo root with a cookiecutter template for bootstrapping new QType projects with a working structure out of the box.Template inputs
project_name— human-readable (e.g."My Project")__slug— auto-derived kebab-case (my-project)__module— auto-derived snake_case Python package (my_project)Generated project layout
Also adds
.github/workflows/test-template.yml— a CI workflow that runs on every PR to validate the template end-to-end.Technical notes / screenshots / additional information (optional):
tools.qtype.yamlis pre-generated to matchqtype convert moduleoutput exactly — users can regenerate it withqtype convert module <module>.tools -o <slug>.tools.qtype.yamlafter modifyingtools.pypyproject.tomluses__slug(e.g.my-project) as the packagenamefield to ensure it is always a valid PEP 508 package name; the human-readableproject_nameis used only in thedescriptionfielddocker run --env-fileInvokeTool(greet by name) →PromptTemplate(build prompt) →LLMInference(OpenAIgpt-4o-mini), demonstrating the tool-chaining pattern.vscode/launch.json"QType Run (CLI)" config uses apromptStringinput (${input:cliArgs}) so users can supply any arguments at debug timeqtype validate✅CI workflow (
test-template.yml) steps:template/changed between the PR base and headcookiecutter template/ --no-input project_name="PR Test"uv syncthenuv run qtype validate pr-test.qtype.yaml(with a dummyOPENAI_API_KEY)qtype convert moduleand fails if it differs from the committed version (drift detection)docker build💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.