Skip to content

Commit

Permalink
Merge pull request #123 from Mintplex-Labs/notifications-on-sync
Browse files Browse the repository at this point in the history
Add notifications on sync jobs
  • Loading branch information
timothycarambat committed Jan 19, 2024
2 parents e3c48b1 + e64d48b commit ea9084f
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 0 deletions.
4 changes: 4 additions & 0 deletions workers/functions/runRAGTest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ const runRAGTest = InngestClient.createFunction(
error: e.message,
details: e,
};
await Notification.create(organization.id, {
textContent: 'Your Context Drift test failed to run.',
symbol: Notification.symbols.error,
});
await RagTest.updateRun(run?.id, {
status: RagTest.status.failed,
results: {
Expand Down
14 changes: 14 additions & 0 deletions workers/functions/syncChroma/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const {
} = require('../../../backend/models/workspaceDocument');
const { DocumentVectors } = require('../../../backend/models/documentVectors');
const { vectorSpaceMetric } = require('../../utils/telemetryHelpers');
const { Notification } = require('../../../backend/models/notification');

const syncChromaInstance = InngestClient.createFunction(
{ name: 'Sync Chroma Instance' },
Expand Down Expand Up @@ -77,6 +78,13 @@ const syncChromaInstance = InngestClient.createFunction(
} of ${collections.length - failedToSync.length} collections.`,
failedToSync,
};

await Notification.create(organization.id, {
textContent: 'Your Chroma instance has been fully synced.',
symbol: Notification.symbols.chroma,
link: `/dashboard/${organization.slug}`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.complete, result);
await vectorSpaceMetric();
return { result };
Expand All @@ -87,6 +95,12 @@ const syncChromaInstance = InngestClient.createFunction(
error: e.message,
details: e,
};
await Notification.create(organization.id, {
textContent: 'Your Chroma instance failed to sync.',
symbol: Notification.symbols.error,
link: `/dashboard/${organization.slug}/jobs`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.failed, result);
}
}
Expand Down
13 changes: 13 additions & 0 deletions workers/functions/syncChromaWorkspace/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
const { DocumentVectors } = require('../../../backend/models/documentVectors');
const { deleteVectorCacheFile } = require('../../../backend/utils/storage');
const { vectorSpaceMetric } = require('../../utils/telemetryHelpers');
const { Notification } = require('../../../backend/models/notification');

const syncChromaWorkspace = InngestClient.createFunction(
{ name: 'Sync Chroma Workspace' },
Expand Down Expand Up @@ -47,6 +48,12 @@ const syncChromaWorkspace = InngestClient.createFunction(
message:
'Chroma instance vector data has been synced. Workspaces data synced.',
};
await Notification.create(organization.id, {
textContent: 'Your Chroma workspace has been fully synced.',
symbol: Notification.symbols.chroma,
link: `/dashboard/${organization.slug}/workspace/${workspace.fname}`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.complete, result);
await vectorSpaceMetric();
return { result };
Expand All @@ -57,6 +64,12 @@ const syncChromaWorkspace = InngestClient.createFunction(
error: e.message,
details: e,
};
await Notification.create(organization.id, {
textContent: 'Your Chroma workspace failed to sync.',
symbol: Notification.symbols.chroma,
link: `/dashboard/${organization.slug}/jobs`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.failed, result);
}
}
Expand Down
14 changes: 14 additions & 0 deletions workers/functions/syncPinecone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const {
} = require('../../../backend/models/workspaceDocument');
const { DocumentVectors } = require('../../../backend/models/documentVectors');
const { vectorSpaceMetric } = require('../../utils/telemetryHelpers');
const { Notification } = require('../../../backend/models/notification');

const syncPineconeIndex = InngestClient.createFunction(
{ name: 'Sync Pinecone Instance' },
Expand Down Expand Up @@ -84,6 +85,13 @@ const syncPineconeIndex = InngestClient.createFunction(
} of ${collections.length - failedToSync.length} namespaces.`,
failedToSync,
};

await Notification.create(organization.id, {
textContent: 'Your Pinecone instance has been fully synced.',
symbol: Notification.symbols.pinecone,
link: `/dashboard/${organization.slug}/workspace/${workspace.fname}`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.complete, result);
await vectorSpaceMetric();
return { result };
Expand All @@ -94,6 +102,12 @@ const syncPineconeIndex = InngestClient.createFunction(
error: e.message,
details: e,
};
await Notification.create(organization.id, {
textContent: 'Your Pinecone instance failed to sync.',
symbol: Notification.symbols.pinecone,
link: `/dashboard/${organization.slug}/jobs`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.failed, result);
}
}
Expand Down
14 changes: 14 additions & 0 deletions workers/functions/syncPineconeWorkspace/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
const { DocumentVectors } = require('../../../backend/models/documentVectors');
const { deleteVectorCacheFile } = require('../../../backend/utils/storage');
const { vectorSpaceMetric } = require('../../utils/telemetryHelpers');
const { Notification } = require('../../../backend/models/notification');

// Will sync ENTIRE workspace - from a fresh pull.
// Ideally we should only be creating/deleting documents which are not known to the system already.
Expand Down Expand Up @@ -57,6 +58,13 @@ const syncPineconeWorkspace = InngestClient.createFunction(
message:
'Pinecone instance vector data has been synced. Workspace updated.',
};

await Notification.create(organization.id, {
textContent: 'Your Pinecone namespace has been fully synced.',
symbol: Notification.symbols.pinecone,
link: `/dashboard/${organization.slug}/workspace/${workspace.fname}`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.complete, result);
await vectorSpaceMetric();
return { result };
Expand All @@ -67,6 +75,12 @@ const syncPineconeWorkspace = InngestClient.createFunction(
error: e.message,
details: e,
};
await Notification.create(organization.id, {
textContent: 'Your Pinecone namespace failed to sync.',
symbol: Notification.symbols.pinecone,
link: `/dashboard/${organization.slug}/jobs`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.failed, result);
}
}
Expand Down
14 changes: 14 additions & 0 deletions workers/functions/syncQDrantCluster/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const {
QDrant,
} = require('../../../backend/utils/vectordatabases/providers/qdrant');
const { vectorSpaceMetric } = require('../../utils/telemetryHelpers');
const { Notification } = require('../../../backend/models/notification');

const syncQDrantCluster = InngestClient.createFunction(
{ name: 'Sync Qdrant Instance' },
Expand Down Expand Up @@ -77,6 +78,13 @@ const syncQDrantCluster = InngestClient.createFunction(
} of ${collections.length - failedToSync.length} collections.`,
failedToSync,
};

await Notification.create(organization.id, {
textContent: 'Your QDrant cluster has been fully synced.',
symbol: Notification.symbols.qdrant,
link: `/dashboard/${organization.slug}/workspace/${workspace.fname}`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.complete, result);
await vectorSpaceMetric();
return { result };
Expand All @@ -87,6 +95,12 @@ const syncQDrantCluster = InngestClient.createFunction(
error: e.message,
details: e,
};
await Notification.create(organization.id, {
textContent: 'Your QDrant cluster failed to sync.',
symbol: Notification.symbols.qdrant,
link: `/dashboard/${organization.slug}/jobs`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.failed, result);
}
}
Expand Down
15 changes: 15 additions & 0 deletions workers/functions/syncQDrantWorkspace/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
QDrant,
} = require('../../../backend/utils/vectordatabases/providers/qdrant');
const { vectorSpaceMetric } = require('../../utils/telemetryHelpers');
const { Notification } = require('../../../backend/models/notification');

const syncQDrantWorkspace = InngestClient.createFunction(
{ name: 'Sync QDrant Workspace' },
Expand Down Expand Up @@ -51,6 +52,13 @@ const syncQDrantWorkspace = InngestClient.createFunction(
message:
'QDrant instance vector data has been synced. Workspaces data synced.',
};

await Notification.create(organization.id, {
textContent: 'Your QDrant namespace has been fully synced.',
symbol: Notification.symbols.qdrant,
link: `/dashboard/${organization.slug}/workspace/${workspace.fname}`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.complete, result);
await vectorSpaceMetric();
return { result };
Expand All @@ -61,6 +69,13 @@ const syncQDrantWorkspace = InngestClient.createFunction(
error: e.message,
details: e,
};

await Notification.create(organization.id, {
textContent: 'Your QDrant namespace failed to sync.',
symbol: Notification.symbols.qdrant,
link: `/dashboard/${organization.slug}/jobs`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.failed, result);
}
}
Expand Down
15 changes: 15 additions & 0 deletions workers/functions/syncWeaviateCluster/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const {
Weaviate,
} = require('../../../backend/utils/vectordatabases/providers/weaviate');
const { vectorSpaceMetric } = require('../../utils/telemetryHelpers');
const { Notification } = require('../../../backend/models/notification');

const syncWeaviateCluster = InngestClient.createFunction(
{ name: 'Sync Weaviate Instance' },
Expand Down Expand Up @@ -77,6 +78,13 @@ const syncWeaviateCluster = InngestClient.createFunction(
} of ${collections.length - failedToSync.length} collections.`,
failedToSync,
};

await Notification.create(organization.id, {
textContent: 'Your Weaviate cluster has been fully synced.',
symbol: Notification.symbols.weaviate,
link: `/dashboard/${organization.slug}/workspace/${workspace.fname}`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.complete, result);
await vectorSpaceMetric();
return { result };
Expand All @@ -87,6 +95,13 @@ const syncWeaviateCluster = InngestClient.createFunction(
error: e.message,
details: e,
};

await Notification.create(organization.id, {
textContent: 'Your Weaviate cluster failed to sync.',
symbol: Notification.symbols.weaviate,
link: `/dashboard/${organization.slug}/jobs`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.failed, result);
}
}
Expand Down
15 changes: 15 additions & 0 deletions workers/functions/syncWeaviateWorkspace/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
Weaviate,
} = require('../../../backend/utils/vectordatabases/providers/weaviate');
const { vectorSpaceMetric } = require('../../utils/telemetryHelpers');
const { Notification } = require('../../../backend/models/notification');

const syncWeaviateWorkspace = InngestClient.createFunction(
{ name: 'Sync Weaviate Workspace' },
Expand Down Expand Up @@ -56,6 +57,13 @@ const syncWeaviateWorkspace = InngestClient.createFunction(
message:
'Weaviate instance vector data has been synced. Workspaces data synced.',
};

await Notification.create(organization.id, {
textContent: 'Your Weaviate namespace has been fully synced.',
symbol: Notification.symbols.weaviate,
link: `/dashboard/${organization.slug}/workspace/${workspace.fname}`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.complete, result);
await vectorSpaceMetric();
return { result };
Expand All @@ -66,6 +74,13 @@ const syncWeaviateWorkspace = InngestClient.createFunction(
error: e.message,
details: e,
};

await Notification.create(organization.id, {
textContent: 'Your Weaviate namespace failed to sync.',
symbol: Notification.symbols.weaviate,
link: `/dashboard/${organization.slug}/jobs`,
target: '_blank',
});
await Queue.updateJob(jobId, Queue.status.failed, result);
}
}
Expand Down

0 comments on commit ea9084f

Please sign in to comment.