## sync()


Make the views and datapackage.json match the recipe folders, like `uv sync`.


Usage

``` python
sync(
    *,
    root=None,
    all=False,
)
```


First, every recipe folder is checked against the rules; if any recipe would be refused, sync raises before changing anything, listing every problem. Then it removes the records and view files of recipes whose folder is gone and of outputs a recipe no longer declares, and runs, upstream first, every recipe that has never run, whose recipe folder no longer matches its record, or whose views are missing, plus everything downstream of those. Progress lines go to standard error; steps' own output appears as they run.

If a recipe fails, or sync is interrupted, sync stops there. What it had already done is kept, and the views of recipes it had not reached that were made from views it had already made again are removed, so the next sync makes them again.


## Parameters


`root: str | Path | None = None`  
The project folder. By default it is found by walking up from the current folder to `datapackage.json`.

`all: bool = ``False`  
Run every recipe, not only those that are missing or changed. Use it after editing the code inside a step, which sync does not notice by itself, and after pulling or switching branches.


## Returns


`SyncResult`  
A [SyncResult](SyncResult.md#useful_views.SyncResult) saying what was removed, deleted and run.


## Raises


`RecipeRefused`  
A recipe breaks a rule; nothing changed. Its `refusals` lists every problem found.

`(StepFailed, OutputError)`  
A recipe failed while running. The removals and the recipes that ran before it are kept; the exception's `sync_result` says what was done, and its message what to run next.

`ProjectError`  
Another useful-views command is changing the project, or a file could not be written or deleted.

`ProjectNotFound`  
No project was found.
