Skip to content

Added "should handle checkpoints correctly" Unit Tests + Fix 2 Bugs That Were Preventing Them From Passing#93

Merged
Nuno Campos (nfcampos) merged 5 commits intolangchain-ai:mainfrom
janvi-codaio:janvi-pregel-test
Mar 21, 2024
Merged

Added "should handle checkpoints correctly" Unit Tests + Fix 2 Bugs That Were Preventing Them From Passing#93
Nuno Campos (nfcampos) merged 5 commits intolangchain-ai:mainfrom
janvi-codaio:janvi-pregel-test

Conversation

@janvi-codaio
Copy link
Copy Markdown
Contributor

@janvi-codaio Janvi Kalra (janvi-codaio) commented Mar 21, 2024

The should handle checkpoints correctly unit test was initially skipped because it didn't pass.
This PR fixes the two bugs that were preventing it from passing.

  1. BinaryOperatorAggregate Channel did not implement empty() (aka - snapshot) correctly. The issue was that the old checkpoint's value was not being saved as the initial value leading to a lossy channel that stored state in correctly

  2. Checkpoint was not implemented correctly, because it would only update the checkpoint's channel value if it had never been set before. Updated the code such that it always update's the checkpoint value based on the latest channel value

Now that these have been fixed, add the checkpointing test back in!


public checkpoint(): Value {
if (!this.value) {
if (this.value === undefined) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

nit for consistency with the rest of the file

newCheckpoint.channelValues[k] = await channels[k].checkpoint();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
if ("name" in error && error.name === EmptyChannelError.name) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Worth simplifying into one conditional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good point - done!

@nfcampos Nuno Campos (nfcampos) merged commit 45b7b63 into langchain-ai:main Mar 21, 2024
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.

3 participants