✨ Support remote URLs in core.sqlite_zip storage - #7432
Conversation
The `filepath` of the `core.sqlite_zip` storage backend now also
accepts an `http://` or `https://` URL of an archive hosted online,
e.g.:
verdi profile setup core.sqlite_zip -n --profile-name archive \
--filepath https://example.com/export.aiida
The archive is never downloaded in full. Using the `remotezip` library
(added as a new dependency), only the SQLite database is fetched via
HTTP range requests (to a temporary file, once per Python session, on
first query), and repository files are streamed individually from the
remote zip on demand. Each storage instance opens a single connection
to the remote archive, reused for validation, database extraction and
repository access. The server hosting the archive must support range
requests, and the timeout of the HTTP requests can be changed via the
new `storage.remote_archive_timeout` configuration option (default:
60 seconds).
Since a remote archive cannot be migrated in place, profile setup
fails with a clear error if the archive is not at the target schema
version, instructing the user to download the file and run `verdi
archive migrate` on the local copy. Similarly, resetting a remote
archive raises, and `verdi profile delete --delete-data` reports that
the remote archive is left untouched instead of warning that the file
does not exist.
The `-p/--profile` option of `verdi` now also accepts the location of
a `.aiida` archive, as a `file:///absolute/path` URL of a local
archive or an `http(s)://` URL of a remote one, e.g.:
verdi -p file:///path/to/export.aiida process list -a
verdi -p https://example.com/export.aiida shell
In this case an ephemeral profile is created that mounts the archive
with the read-only `core.sqlite_zip` storage backend, for the duration
of the command only: the profile is never added to the configuration
file and any temporary files are cleaned up when the command finishes.
Archive locations are only accepted by parameters that explicitly opt
in via `ProfileParamType(accept_archive_location=True)`, currently
only the top-level `-p/--profile` option: other profile parameters,
such as the argument of `verdi profile delete`, keep treating such
values as invalid profile names. As part of this,
`aiida.manage.configuration.load_profile` now also accepts a
`Profile` instance in addition to a profile name.
Also fix a latent bug in `FolderBackendRepository.open`, which passed
`encoding` to a binary-mode `open()` call, raising `ValueError` for
any file access on unpacked folder-format archives.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #7432 +/- ##
==========================================
+ Coverage 80.44% 80.50% +0.07%
==========================================
Files 578 579 +1
Lines 46253 46523 +270
==========================================
+ Hits 37204 37451 +247
- Misses 9049 9072 +23 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Note: Developed with support of Claude Fable 5. Potential design discussion items:
|
The
filepathof thecore.sqlite_zipstorage backend now also accepts anhttp://orhttps://URL of an archive hosted online, e.g.:The archive is never downloaded in full. Using the
remoteziplibrary (added as a new dependency), only the SQLite database is fetched via HTTP range requests (to a temporary file, once per Python session, on first query), and repository files are streamed individually from the remote zip on demand. Each storage instance opens a single connection to the remote archive, reused for validation, database extraction and repository access. The server hosting the archive must support range requests, and the timeout of the HTTP requests can be changed via the newstorage.remote_archive_timeoutconfiguration option (default: 60 seconds).Since a remote archive cannot be migrated in place, profile setup fails with a clear error if the archive is not at the target schema version, instructing the user to download the file and run
verdi archive migrateon the local copy. Similarly, resetting a remote archive raises, andverdi profile delete --delete-datareports that the remote archive is left untouched instead of warning that the file does not exist.The
-p/--profileoption ofverdinow also accepts the location of a.aiidaarchive, as afile:///absolute/pathURL of a local archive or anhttp(s)://URL of a remote one, e.g.:In this case an ephemeral profile is created that mounts the archive with the read-only
core.sqlite_zipstorage backend, for the duration of the command only: the profile is never added to the configuration file and any temporary files are cleaned up when the command finishes. Archive locations are only accepted by parameters that explicitly opt in viaProfileParamType(accept_archive_location=True), currently only the top-level-p/--profileoption: other profile parameters, such as the argument ofverdi profile delete, keep treating such values as invalid profile names. As part of this,aiida.manage.configuration.load_profilenow also accepts aProfileinstance in addition to a profile name.Also fix a latent bug in
FolderBackendRepository.open, which passedencodingto a binary-modeopen()call, raisingValueErrorfor any file access on unpacked folder-format archives.