Allow for export and input of knowls via yaml - #7029
Conversation
|
Is this ready to be reviewed? |
|
Yep, this is ready to be reviewed! The goal is to allow for changes to many knowls at once by exporting the current state, modifying on disk, then uploading. |
|
I asked Claude to take a look at this PR too and to test it for correctness/safety/bugs. It had one tiny bug and a few small suggestions (see below). Several of them are cautions for careless usage which we may not want to worry about. For (3) in Correctness, I'm not sure what we want the general behavior to be. If this is just fixing a small typo, they should not go back to being unreviewed. But if it is something more substantial, maybe? And in the smaller issue, I do think we want to not add the author name by default to all of these knowls if the person doing the import/export is just fixing a small issue. Correctness1.
|
- Fix crash on invalid knowl ids in yaml_import: allowed_id calls flash_error, which requires a Flask request context, but yaml_import is run from the command line. The validation logic now lives in a context-free helper bad_knowl_id_reason in knowl.py (also fixing a latent formatting crash when a bad id contains a percent sign), and invalid comment ids now flash an explanatory message on the web instead of failing silently. - Wrap the import loop in a single DelayCommit so a failure partway through does not leave a partial import. - Add a minor flag to yaml_import (default True) so the person running a bulk import is not added as an author of every touched knowl; creators of new knowls are still recorded. - Document the straight_to_production status foot-gun, fix the yaml_export docstring (update_from_yaml -> yaml_import, truncated sentence, wrong fields default) and explain the ids=0 default. Tested against devmirror (dryrun only): a full export of all 1722 normal knowls re-imports with zero spurious diffs, so the yaml round trip is faithful on real data; invalid ids in a creation batch now print a message instead of raising RuntimeError. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Address review feedback on yaml knowl import/export
|
@jenpaulhus I think I've addressed all of the comments. |
|
LGTM! |
No description provided.