Skip to content

Commit 7e833e5

Browse files
authored
Merge pull request #877 from Kiln-AI/scosman/package_project
Kiln CLI including project packager
2 parents e70507e + 69dd324 commit 7e833e5

File tree

11 files changed

+2382
-3
lines changed

11 files changed

+2382
-3
lines changed

.github/workflows/debug_detector.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
found=0
1818
1919
echo "Checking for python print statements"
20-
prints=$(grep -nR --include='*.py' --exclude-dir=node_modules --exclude-dir=.venv --exclude-dir=.git --exclude-dir=.github --exclude-dir=build --exclude-dir=dist --exclude-dir=.svelte-kit -e 'print(' . || true)
20+
prints=$(grep -nRP --include='*.py' --exclude-dir=node_modules --exclude-dir=.venv --exclude-dir=.git --exclude-dir=.github --exclude-dir=build --exclude-dir=dist --exclude-dir=.svelte-kit -e '(?<!\.)\bprint\(' . || true)
2121
if [ -n "$prints" ]; then
2222
echo "$prints"
2323
found=1

libs/core/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,19 @@ for task in tasks:
107107

108108
If you've already created a Kiln task and want to run it as part of a Python app you can follow this example.
109109

110+
**Step 1: Export your Kiln task/project**
111+
112+
You can run any Kiln task from code using it's project file/folder on disk. However, these folders can contain thousands of files relating to past runs and evals, which is more than you probably want to deploy to a service. Only a few of these files are needed for running the task: you can export a minimal project folder with on the necessary files to run a task by running our CLI:
113+
114+
```bash
115+
uvx kiln_ai package_project "/path/to/your/project.kiln" -t TASK_ID_TO_EXPORT
116+
```
117+
118+
**Step 2: Run Kiln Task from Code**
119+
110120
Prerequisites:
111121

112-
- Already have a Kiln Task created and saved to disk at `TASK_PATH`. It doesn't matter if you created it using the Kiln app or the library.
122+
- Already have a Kiln Task created and saved to disk at `TASK_PATH`. It doesn't matter if you created it using the Kiln app, the Kiln library, or exported it using the command above.
113123
- Set a default run configuration in the Kiln UI specifying how to run the task: model, AI provider, etc. Alternatively you can create a RunConfigProperties instance in code.
114124
- Set up any API keys required for the task. If running on the same machine as the Kiln app, these will already be saved in `~/.kiln_ai/settings.yaml` and will be loaded automatically. If running on a server, you can set the required environment variables (see `libs/core/kiln_ai/utils/config.py` for a list).
115125
- If your task uses RAG, ensure you have run search indexing on this machine with the Kiln UI or via the library.

libs/core/kiln_ai/cli/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from kiln_ai.cli.cli import app
2+
3+
__all__ = ["app"]

libs/core/kiln_ai/cli/cli.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import typer
2+
3+
from kiln_ai.cli.commands import package_project, projects, tasks
4+
5+
app = typer.Typer(
6+
help="Kiln AI CLI - Build AI systems with evals, data gen, fine-tuning, and more.",
7+
no_args_is_help=True,
8+
)
9+
10+
app.add_typer(projects.app, name="projects")
11+
app.add_typer(tasks.app, name="tasks")
12+
app.command(name="package_project")(package_project.package_project)

libs/core/kiln_ai/cli/commands/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)