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

enhance: use workspace file revisions to avoid clobbering the database #437

Merged

Conversation

njhale
Copy link
Member

@njhale njhale commented Feb 12, 2025

@njhale njhale force-pushed the enhance/database-optimistic-concurrency branch from 69e6681 to ed9f368 Compare February 21, 2025 15:24
@njhale njhale marked this pull request as ready for review February 21, 2025 15:29
@njhale njhale force-pushed the enhance/database-optimistic-concurrency branch from ed9f368 to e09f799 Compare February 21, 2025 15:30
database/go.mod Outdated
@@ -2,21 +2,23 @@ module obot-platform/database

go 1.23.3

replace github.com/gptscript-ai/go-gptscript => github.com/thedadams/go-gptscript v0.0.0-20250219113618-25d959a071ff
Copy link
Member Author

Choose a reason for hiding this comment

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

I need gptscript-ai/go-gptscript#93 to merge before we can remove this and merge this PR.

Comment on lines +139 to +138
lastRevisionIndex := slices.IndexFunc(revisions, func(rev gptscript.FileInfo) bool {
return rev.RevisionID == revisionID
})

Copy link
Contributor

Choose a reason for hiding this comment

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

Revisions should come out in order.

return nil
}

for _, rev := range revisions[:lastRevisionIndex+1] {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be delete ALL revisions. Is that the intention?

Copy link
Member Author

Choose a reason for hiding this comment

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

Iiuc, this drops all revisions up-to and including the previous revision (not the one we just created).

@@ -174,17 +174,17 @@ func read(ctx context.Context, filename string) error {
return err
}

data, err := client.ReadFileInWorkspace(ctx, path.Join(FilesDir, filename))
response, err := client.ReadFileInWorkspace(ctx, path.Join(FilesDir, filename))
Copy link
Contributor

Choose a reason for hiding this comment

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

In the latest version of the go-gptscript changes, this function returns []byte instead of the data structure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, meant to drop this. Thanks for catching.

@njhale njhale force-pushed the enhance/database-optimistic-concurrency branch from e09f799 to 45df4c8 Compare February 21, 2025 20:16
if err := g.DeleteRevisionForFileInWorkspace(ctx, dbWorkspacePath, rev.RevisionID, gptscript.DeleteRevisionForFileInWorkspaceOptions{
WorkspaceID: workspaceID,
}); err != nil {
fmt.Fprintf(os.Stderr, "Error deleting revision %s: %v\n", rev.RevisionID, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@njhale njhale force-pushed the enhance/database-optimistic-concurrency branch from 45df4c8 to 24f984e Compare February 24, 2025 18:36
@njhale njhale merged commit df8e686 into obot-platform:main Feb 24, 2025
2 checks passed
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