-
Notifications
You must be signed in to change notification settings - Fork 0
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
Reset command #56
Conversation
@@ -34,68 +34,72 @@ pub fn import_fasta( | |||
change.id, | |||
); | |||
|
|||
if !Collection::exists(conn, name) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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| { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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);", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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, ()); |
There was a problem hiding this comment.
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 :(
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
); | ||
|
||
assert_eq!( | ||
Operation::get_path_between(op_conn, 3, 7), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.