tenseleyflow/documentlanguagemodel / aa361fc

Browse files

cli/export: --emit-sway-json flag wires the sway_json bridge (S26 X1-P3)

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
aa361fc8716e09878c5f426f5bee215247ed7368
Parents
2096ea7
Tree
8629c47

1 changed file

StatusFile+-
M src/dlm/cli/commands.py 26 0
src/dlm/cli/commands.pymodified
@@ -1664,6 +1664,18 @@ def export_cmd(
16641664
         bool,
16651665
         typer.Option("--verbose", help="Log each subprocess command as it launches."),
16661666
     ] = False,
1667
+    emit_sway_json: Annotated[
1668
+        bool,
1669
+        typer.Option(
1670
+            "--emit-sway-json",
1671
+            help=(
1672
+                "After the export, also write a ready-to-run sway.yaml "
1673
+                "(via dlm-sway autogen) into the export dir. Requires the "
1674
+                "[sway] extra: pip install 'dlm[sway]'. Closes the "
1675
+                "training-then-evaluating gap from sway Sprint 26 X1."
1676
+            ),
1677
+        ),
1678
+    ] = False,
16671679
 ) -> None:
16681680
     """Export the adapter to a runtime target."""
16691681
 
@@ -2147,6 +2159,20 @@ def export_cmd(
21472159
     console.print(f"[green]exported:[/green] {result.export_dir}{cached_tag}")
21482160
     for artifact in result.artifacts:
21492161
         console.print(f"  {artifact.name}")
2162
+
2163
+    # S26 X1 — also emit a sway.yaml next to the GGUF when the user
2164
+    # asks for it. Done AFTER the regular export so a sway-side
2165
+    # failure can never roll back a working GGUF deployment.
2166
+    if emit_sway_json:
2167
+        from dlm.export.sway_json import SwayJsonExportError, write_sway_json
2168
+
2169
+        try:
2170
+            sway_yaml_path = write_sway_json(path, result.export_dir)
2171
+        except SwayJsonExportError as exc:
2172
+            console.print(f"[red]sway-json:[/red] {exc}")
2173
+            raise typer.Exit(code=1) from exc
2174
+        console.print(f"[green]sway.yaml:[/green] {sway_yaml_path}")
2175
+        console.print("  next: sway run " + str(sway_yaml_path))
21502176
     if resolved_target.name == "llama-server":
21512177
         assert llama_server_result.launch_script_path is not None
21522178
         assert llama_server_result.config_path is not None