Commit Graph

24 Commits

Author SHA1 Message Date
Giacomo Vercesi aa28975c3f LocalStorageProvider: prune on startup
Add two situations where the cache is pruned on startup, removing all
the cached objects from storage:
1. the version field does not match the current one
2. the model has been changed out of band

The second one is very important as it allows to use the revng2 CLI
while editing the model manually on disk.
2026-04-10 11:45:13 +02:00
Giacomo Vercesi e5ca09e0f3 pypeline-storage: drop revng_ prefix
Drop the `revng_` prefix for the version field.
2026-04-10 11:45:12 +02:00
Giacomo Vercesi d41f7bcd6e LocalStorageProvider: handle OSErrors
Ignore `OSError`s in `LocalStorageProvider` when rebuilding the list of
files for a given hash, since those paths might have become inaccessible
in the meantime.
2026-04-10 11:45:12 +02:00
Giacomo Vercesi 2663a8beb3 LocalStorageProvider: fix invalidation code
Before this commit the `invalidate` code did invalidate all the objects
but left all the rows in `dependencies` that were paired to the produced
objects except the invalidated paths.
In this commit the logic is changed to be done in 3 steps:
1. SELECT all the objects that need to be invalidated, write down their
   rowid
2. Delete all the rows in `dependencies` that were produced in
   conjunction to the objects from (1)
3. Remove the objects from the table, returning invalidation data
This guarantees that the database does not accumulate invalidation data
over time due to invalidations.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi ce60d8a1e5 pypeline: integrate model migration infrastructure
When calling `Model.deserialize` the model will be automatically be
migrated if it needs to.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi f4d0573017 pypeline: StorageProvider works with Model
Change the `get_model` and `set_model` interface of `StorageProvider` so
that it is responsibility of the `StorageProvider` to
serialize/deserialize the model before returning to the caller.
This is in preparation to the model migration being implemented, since
it's now a responsibility of the storage provider to deserialize it it
can trivially re-save it to disk if it is migrated.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi 9287c51d27 pypeline: fix -C option
Instead of executing `chdir` when using the `-C` option, which is
fragile when other paths are involved, store the option in the click
context and propagate it to the required code paths that require knowing
what the base directory is.
2026-03-04 14:58:02 +01:00
Giacomo Vercesi ae601f2d3c LocalStorageProvider: add inline parameter
Allow the storage provider to be initialized with `local://?inline`.
This will set the cache directory to `$PWD/.cache` instead of
`~/.cache/revng`. This is to simplify testing for pypeline.
2026-03-04 14:58:02 +01:00
Giacomo Vercesi 12c180bfd9 pypeline: convert uses of pypeline_logger.log
The `pypeline_logger.log` functions should only be used to convey
information to the user, all other uses should fall under `debug_log`.
2025-12-17 11:58:46 +01:00
Giacomo Vercesi 8af5e1d05c Implement revng2 quick artifact 2025-12-10 16:16:14 +01:00
Giacomo Vercesi 681e9543cf LocalStorageProvider: use table for model_paths
When running `invalidate`, use a temporary table to store the
invalidated model paths that need to be used. This saves to template
them into the query and allows them to be recycled later when the
`dependency` table needs to be cleaned up.
2025-11-26 16:13:28 +01:00
Giacomo Vercesi b1b5778822 Add infrastructure for custom invalidation
Add infrastructure to pypeline to allow for pipes to provide custom
invalidation, by implementing an `invalidate` function.
2025-11-26 16:13:28 +01:00
Tommaso Fontana b38832e251 Pypeline: move epoch to storage_provider
Move the epoch inside the storage_provider, this allows us to make the
storage_provider_factory to return an async context manager.
This way we can simplify the locking for the daemon, but forces the
CLI project commands to deal with async code.
2025-11-11 17:15:28 +01:00
Tommaso Fontana 8ae70d85d4 Pypeline: replace logging with custom log
Now the pype command has a `--verbose` argument that to enable debug
logging in the pypelien code.
Adapted the codebase to use this new logging format but replacing
`logging` with `revng.pypeline.utils.logger`, this is done in
preparation of debug-log.
2025-11-11 17:15:28 +01:00
Tommaso Fontana a7f77b1704 Pypeline: propagate invalidated artifacts objects
Changed the API of storage_provider to treturn the invalidated object
ids and propagated this info to the CLI and daemon.
2025-11-11 17:15:28 +01:00
Tommaso Fontana 71fad8b361 Pypeline: replace load_container with from_file 2025-11-11 17:15:28 +01:00
Tommaso Fontana 639593164a Pypeline: add autocomplete and refactor CLI
Now pype has an `autocomplete` command usable to enable autocompletion
and revng2 now is based on `pype`, modifying its defalults and
injecting new commands.
2025-11-11 17:15:27 +01:00
Tommaso Fontana 652ffbb0f7 Pypeline: remove abbreviations, normalize quotes 2025-11-11 17:15:27 +01:00
Giacomo Vercesi b622fe8f19 Implement FileProvider interface
Implement the `FileProvider` interface, this allows pipes to request
files given a `FileRequest` (hash and optional size/name).
2025-10-16 17:48:45 +02:00
Giacomo Vercesi 0f7dc7047d pypeline.Container: fix signature of (de)serialize
Change the signature of `Container.serialize` and
`Container.deserialize` to use `Buffer` instead of `bytes`, as this
makes the functions compatible with the `revng::pypeline::Buffer`
classes.
2025-10-16 16:08:05 +02:00
Giacomo Vercesi 5c0ef7789e pypeline.storage: return invalidated objects
When calling `StorageProvider.invalidate`, return a dictionary that
conveys to the caller which objects were deleted from storage as a
consequence of the paths supplied to the `invalidate` call.
2025-10-15 17:43:09 +02:00
Giacomo Vercesi 5ea2cbdeaf pypeline.storage: fix invalidation
Fix the invalidation logic in both `InMemoryStorageProvider` and
`Sqlite3StorageProvider`, as it did not account for propagating the
invalidation to both children objects and parent objects.
2025-10-15 17:43:09 +02:00
Giacomo Vercesi 59a7e0716a pypeline.storage.sqlite3: fix model path column
The column stored read model paths was erroneously called
`model_path_hash`, while the entire model was stored instead of a hash.
Rename the column to just `model_path` to avoid any confusion.
2025-10-15 11:58:41 +02:00
Tommaso Fontana 80eb02c207 Pypeline: merge pypeline 2025-09-10 12:05:15 +02:00