chitralverma commented on code in PR #9421:
URL: https://github.com/apache/opendal/pull/9421#discussion_r4736231866


##########
bindings/python/src/operator.rs:
##########
@@ -143,8 +145,15 @@ fn extract_delete_paths(paths: &Bound<'_, PyAny>) -> 
PyResult<Vec<String>> {
     paths
         .try_iter()?
         .map(|entry| {
-            let path = entry?.extract::<PathBuf>()?;
-            Ok(path.to_string_lossy().into_owned())
+            let entry = entry?;
+            let (path, opts) = match entry.cast::<PyTuple>() {

Review Comment:
   e31ba5187 converts each `delete_many` entry as a path first, as `main` does, 
and reads a `(path, options)` pair only when that conversion fails. It still 
converts the full iterable before the first deletion. Your `ScopedPath` 
reproducer is now a sync and async test: it fails on e73fc362f and passes here.
   
   *This comment is AI assisted.*



##########
bindings/python/python/opendal/options.py:
##########
@@ -140,6 +143,20 @@ class ReadKwargs(TypedDict, total=False):
     without accessing storage. When `size` is positive, a file that ends
     before `offset` plus `size` fails the read.
     """
+    limit: int | None

Review Comment:
   e31ba5187 types `limit` as `None` in `OpenKwargs`. A TypedDict cannot narrow 
an inherited key, so `OpenKwargs` now lists the read and write keys itself, and 
generation fails if the two type a shared key differently. `read()` and 
`ReadKwargs` keep `limit: int | None`. Under mypy `--strict` and pyright, the 
typing test needs its `# type: ignore` on `open(..., limit=4)` and accepts 
`limit=None`. At runtime, `test_open_modes` raises `TypeError` for `limit=1` in 
read and write modes.
   
   *This comment is AI assisted.*



##########
bindings/python/src/operator.rs:
##########
@@ -2163,26 +2521,93 @@ impl AsyncOperator {
     ///
     /// Parameters
     /// ----------
-    /// paths : Iterable[str | PathLike[str]]
-    ///     The paths to delete. A single path is not accepted.
+    /// paths : Iterable[DeleteEntry]
+    ///     The paths to delete. A `(path, options)` pair deletes `path` with
+    ///     the `delete()` keyword arguments in `options`, such as
+    ///     `{"if_not_changed": metadata}`, and raises `TypeError` for an
+    ///     unknown key. A single path is not accepted.
+    /// concurrent : int, optional
+    ///     The maximum number of backend delete tasks in flight. Each task
+    ///     deletes one path, or one batch where the service deletes in
+    ///     batches. Defaults to one task at a time.
     ///
     /// Returns
     /// -------
     /// Awaitable[None]
     ///     An awaitable that completes when deletion finishes.
-    #[pyo3(signature = (paths: "collections.abc.Iterable[str | 
PathLike[str]]") -> "collections.abc.Awaitable[None]")]
+    #[pyo3(signature = (paths: "collections.abc.Iterable[DeleteEntry]", *, 
concurrent=None) -> "collections.abc.Awaitable[None]")]
     pub fn delete_many<'p>(
         &'p self,
         py: Python<'p>,
         paths: &Bound<'_, PyAny>,
+        concurrent: Option<usize>,
     ) -> PyResult<Bound<'p, PyAny>> {
-        let paths = extract_delete_paths(paths)?;
+        let paths = extract_delete_entries(paths)?;
+        let opts = DeleterOptions { concurrent };
         let this = self.core.clone();
         future_into_py(py, async move {
             if paths.is_empty() {
                 return Ok(());
             }
-            this.delete_iter(paths).await.map_err(format_pyerr)
+            let mut deleter = this
+                .deleter_options(opts.into())
+                .await
+                .map_err(format_pyerr)?;
+            deleter.delete_iter(paths).await.map_err(format_pyerr)?;
+            deleter.close().await.map_err(format_pyerr)
+        })
+    }
+
+    /// Restore a file from its latest deleted state, or restore a version.
+    ///
+    /// Restoring a path that is already live succeeds. Without a live file or
+    /// a recoverable deleted state, `restore()` raises `NotFound`.
+    ///
+    /// Parameters
+    /// ----------
+    /// path : str
+    ///     The path to the file.
+    /// version : str, optional
+    ///     The version to restore as the current version. Requires
+    ///     `restore_with_version`.
+    /// if_not_exists : bool, optional
+    ///     If True, restore only when no file exists at `path`. Requires
+    ///     `version` and `restore_with_if_not_exists`.
+    ///
+    /// Raises
+    /// ------
+    /// ConfigInvalid
+    ///     If `if_not_exists` is set without `version`.
+    /// ConditionNotMatch
+    ///     If `if_not_exists` is True and a file exists at `path`.
+    /// NotFound
+    ///     If neither a live file nor a recoverable deleted state exists.
+    /// Unsupported
+    ///     If the service does not support restore, `version`, or
+    ///     `if_not_exists`.
+    ///
+    /// Returns
+    /// -------
+    /// coroutine
+    ///     An awaitable that completes when the file is restored.
+    #[pyo3(signature = (path, *, version=None, if_not_exists=None) -> 
"collections.abc.Awaitable[None]")]
+    pub fn restore<'p>(
+        &'p self,
+        py: Python<'p>,
+        path: PathBuf,
+        version: Option<String>,
+        if_not_exists: Option<bool>,
+    ) -> PyResult<Bound<'p, PyAny>> {
+        let this = self.core.clone();
+        let path = path.to_string_lossy().to_string();
+        let opts = RestoreOptions {
+            version,
+            if_not_exists,
+        };
+        future_into_py(py, async move {
+            this.restore_options(&path, opts)

Review Comment:
   e31ba5187 makes `AsyncOperator.restore()` resolve to `None`. On a versioned 
Silo bucket, `test_async_restore` asserts `await restore(path, version=first) 
is None`. It fails on e73fc362f with `assert () is None` and passes here.
   
   *This comment is AI assisted.*



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to