Skip to content

Automate browser based workflows with AI

Stop rationing copilot page inspection and show the page after acting (#7808)

Andrew Neilson6c5426a0ecc2
diff --git a/prompt_evaluation/extract_action/scripts/install_directory.py b/prompt_evaluation/extract_action/scripts/install_directory.py
new file mode 100644
index 000000000..bccf91518
--- /dev/null
+++ b/prompt_evaluation/extract_action/scripts/install_directory.py
@@ -0,0 +1,36 @@
+"""Install a staged dataset directory without replacing an existing destination."""
+
+from __future__ import annotations
+
+import argparse
+import sys
+from pathlib import Path
+
+
+def install_directory(source: Path, destination: Path) -> None:
+ """Move ``source`` to ``destination`` when the destination is absent."""
+ if destination.exists() or destination.is_symlink():
+ raise FileExistsError(f"Destination already exists: {destination}")
+ if not source.is_dir() or source.is_symlink():
+ raise NotADirectoryError(f"Source is not a directory: {source}")
+
+ source.rename(destination)
+
+
+def main() -> int:
+ """Parse command-line arguments and install the staged directory."""
+ parser = argparse.ArgumentParser()
+ parser.add_argument("source", type=Path)
+ parser.add_argument("destination", type=Path)
+ args = parser.parse_args()
+
+ try:
+ install_directory(args.source, args.destination)
+ except OSError as exc:
+ print(exc, file=sys.stderr)
+ return 1
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())