Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset command #56

Merged
merged 3 commits into from
Sep 28, 2024
Merged

Reset command #56

merged 3 commits into from
Sep 28, 2024

Conversation

Chris7
Copy link
Collaborator

@Chris7 Chris7 commented Sep 26, 2024

This allows users to reset their branch to a previous state, detaching the commits from the head of the branch. I used a mask approach where the commits are hidden and not deleted. It could make it simpler to restore this way.

@@ -34,68 +34,72 @@ pub fn import_fasta(
change.id,
);

if !Collection::exists(conn, name) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not intentional behavior. Where only a single fasta could ever be added to a collection.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -117,7 +117,7 @@ impl BlockGroup {
None => {
conn
.query_row(
"select id from block_group where collection_name = ?1 and sample_name is null and name = ?3",
"select id from block_group where collection_name = ?1 and sample_name is null and name = ?2",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug fix, no ?3 in the params

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I missed it in review, too

.unwrap();
rows.next().unwrap().unwrap()

match stmt.query_row((name,), |row| {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes it get-or-create

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -38,7 +39,7 @@ impl Operation {
if let Some(op_id) = current_op {
let count: i32 = conn
.query_row(
"select count(*) from operation where branch_id = ?1 AND parent_id = ?2",
"select count(*) from operation where branch_id = ?1 AND parent_id = ?2 AND id not in (select operation_id from branch_masked_operations where branch_id = ?1);",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an update to the bifurcation projection to not consider operations in the masked operation list

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -98,7 +99,7 @@ impl Operation {
graph.add_node(op.id);
if let Some(v) = op.parent_id {
graph.add_node(v);
graph.add_edge(op.id, v, ());
graph.add_edge(v, op.id, ());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was a bug, the branch edges were reversed :(

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -135,7 +136,7 @@ impl Operation {
directed_graph.edges_directed(last_node, Direction::Incoming)
{
if edge_src == node {
patch_path.push((node, Direction::Incoming, last_node));
patch_path.push((last_node, Direction::Incoming, node));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goes w/ the above bug fix

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep

let creation_id = branch.start_operation_id.unwrap_or(1);

let mut dfs = DfsPostOrder::new(&graph, creation_id);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this actually was just working because i had the graph in reverse orientation. Fixed it by using the Reversed graph method to actually look at ancestors.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -673,6 +724,209 @@ mod tests {
assert_eq!(ops, vec![1, 6, 7, 8, 9, 10, 11]);
}

#[test]
fn test_graph_representation() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was added to make sure the branch graph was what i expected it to be

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

#[test]
fn test_path_between() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this ensures the paths between operations is what we expect

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -791,4 +1045,67 @@ mod tests {
change.id,
);
}

#[test]
fn test_bifurcation_allowed_on_reset() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this ensures we do not enforce the bifurcation protection if someone has reset a branch to a point

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

let new_seq = NewSequence::from(sequence).save(conn);
assert_eq!(new_seq.hash, sequence.hash);
println!("dep seq is {sequence:?}");
if !Sequence::is_delimiter_hash(&sequence.hash) {
Copy link
Collaborator Author

@Chris7 Chris7 Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the sequence field isn't set, the start/end node hashes weren't matching

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be aware that the is_delimiter_hash method is going away, but it should be possible to determine start/end nodes in the new model

@@ -470,15 +518,15 @@ pub fn move_to(conn: &Connection, operation_conn: &Connection, operation: &Opera
}
for (operation_id, direction, next_op) in path.iter() {
match direction {
Direction::Outgoing => {
Direction::Incoming => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix from the inverted graph

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Chris7 Chris7 requested a review from dkhofer September 26, 2024 19:27
);

assert_eq!(
Operation::get_path_between(op_conn, 3, 7),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat

Copy link
Collaborator

@dkhofer dkhofer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Chris7 Chris7 merged commit 2dbb2d4 into main Sep 28, 2024
1 check passed
@Chris7 Chris7 deleted the reset-command branch September 28, 2024 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants