-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scripts[patch]: Add notebook check for unexpected rebuild error (#6602)
- Loading branch information
1 parent
20d5bbe
commit 656db40
Showing
4 changed files
with
40 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
import "../dist/validate_notebook.js"; | ||
import "../dist/notebooks/index.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
libs/langchain-scripts/src/notebooks/check_unexpected_rebuild_timer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import fs from "fs"; | ||
|
||
const [pathname] = process.argv.slice(2); | ||
|
||
if (!pathname) { | ||
throw new Error("No pathname provided."); | ||
} | ||
|
||
/** | ||
* tslab will sometimes throw an error inside the output cells of a notebook | ||
* if the notebook is being rebuilt. This function checks for that error, | ||
* because we do not want to commit that to our docs. | ||
*/ | ||
export async function checkUnexpectedRebuildError() { | ||
if (!pathname.endsWith(".ipynb")) { | ||
throw new Error("Only .ipynb files are supported."); | ||
} | ||
const notebookContents = await fs.promises.readFile(pathname, "utf-8"); | ||
if ( | ||
notebookContents.includes( | ||
"UncaughtException: Error: Unexpected pending rebuildTimer" | ||
) | ||
) { | ||
throw new Error(`Found unexpected pending rebuildTimer in ${pathname}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { checkNotebookTypeErrors } from "./check_notebook_type_errors.js"; | ||
import { checkUnexpectedRebuildError } from "./check_unexpected_rebuild_timer.js"; | ||
|
||
async function main() { | ||
await Promise.all([checkNotebookTypeErrors(), checkUnexpectedRebuildError()]); | ||
} | ||
|
||
try { | ||
void main(); | ||
} catch { | ||
process.exit(1); | ||
} |