Skip to content

Commit

Permalink
finish merge todo!()
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushAgrawal-A2 committed Dec 16, 2024
1 parent 0bcb414 commit a290694
Show file tree
Hide file tree
Showing 12 changed files with 235 additions and 182 deletions.
2 changes: 1 addition & 1 deletion quadratic-core/src/a1/a1_selection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl A1Selection {
});
Self::from_ranges(ranges, sheet)
}
#[cfg(test)]

pub fn from_ranges(ranges: impl Iterator<Item = CellRefRange>, sheet: SheetId) -> Self {
let ranges = ranges.collect::<Vec<_>>();
let last_range = ranges.last().expect("empty selection is invalid");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ pub struct PendingTransaction {
pub offsets_modified: HashMap<SheetId, SheetOffsets>,

// ai researcher requests
pub pending_ai_researcher: HashSet<SheetPos>,
pub pending_ai_researchers: HashSet<SheetPos>,

// ai researcher requests that are currently running
pub running_ai_researcher: HashSet<SheetPos>,
pub running_ai_researchers: HashSet<SheetPos>,
}

impl Default for PendingTransaction {
Expand Down Expand Up @@ -131,8 +131,8 @@ impl Default for PendingTransaction {
fill_cells: HashSet::new(),
sheet_info: HashSet::new(),
offsets_modified: HashMap::new(),
pending_ai_researcher: HashSet::new(),
running_ai_researcher: HashSet::new(),
pending_ai_researchers: HashSet::new(),
running_ai_researchers: HashSet::new(),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl GridController {

loop {
if transaction.operations.is_empty()
&& transaction.pending_ai_researcher.is_empty()
&& transaction.pending_ai_researchers.is_empty()
&& transaction.resize_rows.is_empty()
{
transaction.complete = true;
Expand All @@ -43,12 +43,12 @@ impl GridController {

// try running pending ai researchers in parallel, only if there are no other operations
if transaction.operations.is_empty()
&& !transaction.pending_ai_researcher.is_empty()
&& transaction.has_async == transaction.running_ai_researcher.len() as i64
&& !transaction.pending_ai_researchers.is_empty()
&& transaction.has_async == transaction.running_ai_researchers.len() as i64
{
self.run_ai_researcher_parallel(transaction);
// if there are still running ai researchers, break and wait for them to complete
if !transaction.running_ai_researcher.is_empty() {
if !transaction.running_ai_researchers.is_empty() {
self.transactions.update_async_transaction(transaction);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl GridController {
}
CodeCellLanguage::AIResearcher => {
// collect the sheet_pos for the AI researcher, run them in parallel at the end of the transaction
transaction.pending_ai_researcher.insert(sheet_pos);
transaction.pending_ai_researchers.insert(sheet_pos);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion quadratic-core/src/controller/execution/run_code/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ mod test {

use super::*;
use crate::grid::CodeCellValue;
use crate::wasm_bindings::js::expect_js_call_count;
use crate::wasm_bindings::js::{clear_js_calls, expect_js_call_count};

#[test]
#[parallel]
Expand Down Expand Up @@ -433,6 +433,7 @@ mod test {
#[test]
#[serial]
fn code_run_image() {
clear_js_calls();
let mut gc = GridController::test();
let sheet_id = gc.sheet_ids()[0];
let sheet_pos = SheetPos {
Expand Down
Loading

0 comments on commit a290694

Please sign in to comment.