Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions icechunk-python/python/icechunk/_icechunk_python.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2381,13 +2381,13 @@ class PySession:
) -> str: ...
def amend(
self,
message: str,
message: str | None = None,
metadata: dict[str, Any] | None = None,
allow_empty: bool = False,
) -> str: ...
async def amend_async(
self,
message: str,
message: str | None = None,
metadata: dict[str, Any] | None = None,
allow_empty: bool = False,
) -> str: ...
Expand Down
16 changes: 8 additions & 8 deletions icechunk-python/python/icechunk/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ async def commit_async(

def amend(
self,
message: str,
message: str | None = None,
metadata: dict[str, Any] | None = None,
allow_empty: bool = False,
) -> str:
Expand All @@ -524,10 +524,10 @@ def amend(

Parameters
----------
message : str
The message to write with the commit.
message : str | None, optional
The message to write with the commit. If None, reuses the message from the previous commit.
metadata : dict[str, Any] | None, optional
Additional metadata to store with the commit snapshot.
Additional metadata to store with the commit snapshot. If None, reuses the metadata from the previous commit.
allow_empty : bool, optional
If True, allow amending even if no data changes have been made to the session.
This is useful when you only want to update the commit message. Default is False.
Expand All @@ -546,7 +546,7 @@ def amend(

async def amend_async(
self,
message: str,
message: str | None = None,
metadata: dict[str, Any] | None = None,
allow_empty: bool = False,
) -> str:
Expand All @@ -563,10 +563,10 @@ async def amend_async(

Parameters
----------
message : str
The message to write with the commit.
message : str | None, optional
The message to write with the commit. If None, reuses the message from the previous commit.
metadata : dict[str, Any] | None, optional
Additional metadata to store with the commit snapshot.
Additional metadata to store with the commit snapshot. If None, reuses the metadata from the previous commit.
allow_empty : bool, optional
If True, allow amending even if no data changes have been made to the session.
This is useful when you only want to update the commit message. Default is False.
Expand Down
16 changes: 8 additions & 8 deletions icechunk-python/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,21 +598,21 @@ impl PySession {
})
}

#[pyo3(signature = (message, metadata=None, allow_empty=false))]
#[pyo3(signature = (message=None, *, metadata=None, allow_empty=false))]
pub fn amend(
&self,
py: Python<'_>,
message: &str,
message: Option<&str>,
metadata: Option<PySnapshotProperties>,
allow_empty: bool,
) -> PyResult<String> {
let metadata = metadata.map(|m| m.into());
let message = message.map(|m| m.to_string());
// This is blocking function, we need to release the Gil
py.detach(move || {
pyo3_async_runtimes::tokio::get_runtime().block_on(async {
let mut session = self.0.write().await;
let mut builder =
session.commit(message).amend().allow_empty(allow_empty);
let mut builder = session.amend(message).allow_empty(allow_empty);
if let Some(props) = metadata {
builder = builder.properties(props);
}
Expand All @@ -625,21 +625,21 @@ impl PySession {
})
}

#[pyo3(signature = (message, metadata=None, allow_empty=false))]
#[pyo3(signature = (message=None, *, metadata=None, allow_empty=false))]
pub fn amend_async<'py>(
&'py self,
py: Python<'py>,
message: &str,
message: Option<&str>,
metadata: Option<PySnapshotProperties>,
allow_empty: bool,
) -> PyResult<Bound<'py, PyAny>> {
let session = Arc::clone(&self.0);
let message = message.to_owned();
let message = message.map(|m| m.to_string());

pyo3_async_runtimes::tokio::future_into_py(py, async move {
let metadata = metadata.map(|m| m.into());
let mut session = session.write().await;
let mut builder = session.commit(&message).amend().allow_empty(allow_empty);
let mut builder = session.amend(message).allow_empty(allow_empty);
if let Some(props) = metadata {
builder = builder.properties(props);
}
Expand Down
3 changes: 1 addition & 2 deletions icechunk/benches/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,9 @@ fn benchmark_get_chunks(c: &mut Criterion) {
let mut session =
repo.writable_session("main").await.unwrap();
session
.commit("rewrite")
.amend(Some("rewrite".to_string()))
.max_concurrent_nodes(8)
.rewrite_manifests()
.amend()
.execute()
.await
.unwrap();
Expand Down
12 changes: 6 additions & 6 deletions icechunk/src/ops/manifests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ pub async fn rewrite_manifests(
.await
.map_err(|e| ManifestOpsError::ManifestRewriteError(Box::new(e.inject())))?;

let mut builder = session
.commit(message)
.max_concurrent_nodes(max_concurrent_manifests)
.rewrite_manifests();
if commit_method == CommitMethod::Amend {
builder = builder.amend();
let mut builder = if commit_method == CommitMethod::Amend {
session.amend(Some(message.to_string()))
} else {
session.commit(message)
}
.max_concurrent_nodes(max_concurrent_manifests)
.rewrite_manifests();
if let Some(props) = properties {
builder = builder.properties(props);
}
Expand Down
27 changes: 18 additions & 9 deletions icechunk/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4308,8 +4308,10 @@ mod tests {
session
.move_node("/dest".try_into().unwrap(), "/another_dest".try_into().unwrap())
.await?;
let first_amend_snap_id =
session.commit("moved dest to another_dest").amend().execute().await?;
let first_amend_snap_id = session
.amend(Some("moved dest to another_dest".to_string()))
.execute()
.await?;

// Check if moved group still shows up properly after commit
let session = repo
Expand All @@ -4329,8 +4331,10 @@ mod tests {
session
.move_node("/another_dest".try_into().unwrap(), "/src".try_into().unwrap())
.await?;
let second_amend_snap_id =
session.commit("moved another_dest to src").amend().execute().await?;
let second_amend_snap_id = session
.amend(Some("moved another_dest to src".to_string()))
.execute()
.await?;

// Check if moved group still shows up properly after commit
let session = repo
Expand Down Expand Up @@ -4442,8 +4446,11 @@ mod tests {
// Rearrange session: move a node
let mut session = repo.rearrange_session("main").await?;
session.move_node("/f".try_into().unwrap(), "/foo".try_into().unwrap()).await?;
let amend_snap_id =
session.commit("f to foo").max_concurrent_nodes(8).amend().execute().await?;
let amend_snap_id = session
.amend(Some("f to foo".to_string()))
.max_concurrent_nodes(8)
.execute()
.await?;

// Check if moved (and nested) groups still show up properly after commit
let session = repo
Expand Down Expand Up @@ -4531,7 +4538,7 @@ mod tests {
.move_node("/f/bar".try_into().unwrap(), "/foo".try_into().unwrap())
.await?;
let first_amend_snap_id =
session.commit("f/bar to foo").amend().execute().await?;
session.amend(Some("f/bar to foo".to_string())).execute().await?;

// Check if moved (and nested) groups still show up properly after commit
let session = repo
Expand Down Expand Up @@ -4629,7 +4636,8 @@ mod tests {
// Rearrange session: move another node, amend this time
let mut session = repo.rearrange_session("main").await?;
session.move_node("/b".try_into().unwrap(), "/d".try_into().unwrap()).await?;
let second_amend_snap_id = session.commit("b to d").amend().execute().await?;
let second_amend_snap_id =
session.amend(Some("b to d".to_string())).execute().await?;

// Check if moved (and nested) groups still show up properly after commit
let session = repo
Expand All @@ -4651,7 +4659,8 @@ mod tests {
// Rearrange session: move child from one top-level node to another
let mut session = repo.rearrange_session("main").await?;
session.move_node("/d/a".try_into().unwrap(), "/c/e".try_into().unwrap()).await?;
let third_amend_snap_id = session.commit("d/a to c/e").amend().execute().await?;
let third_amend_snap_id =
session.amend(Some("d/a to c/e".to_string())).execute().await?;

// Check if moved (and nested) groups still show up properly after commit
let session = repo
Expand Down
Loading
Loading