-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into thomas/apps-check
- Loading branch information
Showing
149 changed files
with
4,431 additions
and
1,292 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
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
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
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
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
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
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
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
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
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
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
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,118 @@ | ||
name: Revert Workflow | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
region: | ||
description: "Region to revert" | ||
required: true | ||
default: "us-central1" | ||
type: choice | ||
options: | ||
- "us-central1" | ||
- "europe-west1" | ||
image_tag: | ||
description: "The image tag/SHA to deploy" | ||
type: string | ||
required: true | ||
component: | ||
description: "Component to revert" | ||
type: choice | ||
options: | ||
- alerting-temporal | ||
- connectors | ||
- core | ||
- front | ||
- front-edge | ||
- metabase | ||
- oauth | ||
- prodbox | ||
- viz | ||
required: true | ||
secrets: | ||
SLACK_CHANNEL_ID: | ||
required: true | ||
SLACK_BOT_TOKEN: | ||
required: true | ||
INFRA_DISPATCH_APP_ID: | ||
required: true | ||
INFRA_DISPATCH_APP_PRIVATE_KEY: | ||
required: true | ||
|
||
jobs: | ||
check-branch: | ||
runs-on: ubuntu-latest | ||
if: ${{ !inputs.enforce_main || github.ref == 'refs/heads/main' }} | ||
steps: | ||
- name: Check branch condition | ||
run: | | ||
if [[ "${{ inputs.enforce_main }}" == "true" && "${{ github.ref }}" != "refs/heads/main" ]]; then | ||
echo "Reverts are only allowed from the main branch" | ||
exit 1 | ||
fi | ||
notify-start: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
thread_ts: ${{ steps.build_message.outputs.thread_ts }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Notify Start | ||
id: build_message | ||
uses: ./.github/actions/slack-notify | ||
with: | ||
step: "start" | ||
channel: ${{ secrets.SLACK_CHANNEL_ID }} | ||
component: ${{ inputs.component }} | ||
image_tag: ${{ inputs.image_tag }} | ||
region: ${{ inputs.region }} | ||
slack_token: ${{ secrets.SLACK_BOT_TOKEN }} | ||
is_revert: true | ||
|
||
revert: | ||
needs: [notify-start] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Generate token | ||
id: generate-token | ||
uses: actions/create-github-app-token@v1 | ||
with: | ||
app-id: ${{ secrets.INFRA_DISPATCH_APP_ID }} | ||
private-key: ${{ secrets.INFRA_DISPATCH_APP_PRIVATE_KEY }} | ||
owner: ${{ github.repository_owner }} | ||
repositories: dust-infra | ||
|
||
- name: Trigger dust-infra workflow | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ steps.generate-token.outputs.token }} | ||
script: | | ||
await github.rest.repos.createDispatchEvent({ | ||
owner: '${{ github.repository_owner }}', | ||
repo: 'dust-infra', | ||
event_type: 'trigger-component-revert', | ||
client_payload: { | ||
regions: '${{ inputs.region }}', | ||
component: '${{ inputs.component }}', | ||
image_tag: '${{ inputs.image_tag }}', | ||
slack_thread_ts: "${{ needs.notify-start.outputs.thread_ts }}", | ||
slack_channel: '${{ secrets.SLACK_CHANNEL_ID }}', | ||
run_playwright: false, | ||
} | ||
}) | ||
- name: Notify Failure | ||
if: failure() | ||
uses: ./.github/actions/slack-notify | ||
with: | ||
step: "failure" | ||
channel: ${{ secrets.SLACK_CHANNEL_ID }} | ||
component: ${{ inputs.component }} | ||
image_tag: ${{ inputs.image_tag }} | ||
region: ${{ inputs.region }} | ||
slack_token: ${{ secrets.SLACK_BOT_TOKEN }} | ||
thread_ts: "${{ needs.notify-start.outputs.thread_ts }}" | ||
is_revert: true |
88 changes: 88 additions & 0 deletions
88
connectors/migrations/20250116_gdrive_spreadsheet_folders_backfill.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,88 @@ | ||
import { MIME_TYPES } from "@dust-tt/types"; | ||
import { makeScript } from "scripts/helpers"; | ||
import { v4 as uuidv4 } from "uuid"; | ||
|
||
import { getLocalParents } from "@connectors/connectors/google_drive/lib"; | ||
import { dataSourceConfigFromConnector } from "@connectors/lib/api/data_source_config"; | ||
import { concurrentExecutor } from "@connectors/lib/async_utils"; | ||
import { upsertDataSourceFolder } from "@connectors/lib/data_sources"; | ||
import { GoogleDriveFiles } from "@connectors/lib/models/google_drive"; | ||
import type { Logger } from "@connectors/logger/logger"; | ||
import { ConnectorResource } from "@connectors/resources/connector_resource"; | ||
|
||
const DRIVE_CONCURRENCY = 10; | ||
|
||
async function upsertFoldersForConnector( | ||
connector: ConnectorResource, | ||
execute: boolean, | ||
logger: Logger | ||
) { | ||
const localLogger = logger.child({ connectorId: connector.id }); | ||
localLogger.info("Processing Spreadsheets"); | ||
|
||
// generating a memoization key for the duration of the backfill | ||
const memo = uuidv4(); | ||
|
||
const dataSourceConfig = dataSourceConfigFromConnector(connector); | ||
const spreadsheetMimeType = "application/vnd.google-apps.spreadsheet"; | ||
// The 5 connectors with the most spreadsheets: 35k, 20k, 13k, 8k, 7k -> no need for batching | ||
const spreadsheets = await GoogleDriveFiles.findAll({ | ||
where: { | ||
connectorId: connector.id, | ||
mimeType: spreadsheetMimeType, | ||
}, | ||
}); | ||
|
||
if (spreadsheets.length === 0) { | ||
localLogger.info("No spreadsheet found"); | ||
return; | ||
} | ||
|
||
// Upsert spreadsheets as folders | ||
await concurrentExecutor( | ||
spreadsheets, | ||
async (spreadsheet) => { | ||
const { | ||
connectorId, | ||
driveFileId, | ||
dustFileId, | ||
name: spreadsheetName, | ||
} = spreadsheet; | ||
// getLocalParents returns internal IDs | ||
const parents = await getLocalParents(connectorId, dustFileId, memo); | ||
|
||
if (execute) { | ||
await upsertDataSourceFolder({ | ||
dataSourceConfig, | ||
folderId: dustFileId, | ||
parents, | ||
parentId: parents[1] || null, | ||
title: spreadsheetName, | ||
mimeType: MIME_TYPES.GOOGLE_DRIVE.SPREADSHEET, | ||
sourceUrl: getSourceUrlForGoogleDriveSheet(driveFileId), | ||
}); | ||
localLogger.info( | ||
`Upserted spreadsheet folder ${dustFileId} for ${spreadsheetName}` | ||
); | ||
} else { | ||
localLogger.info( | ||
`Would upsert spreadsheet folder ${dustFileId} for ${spreadsheetName}` | ||
); | ||
} | ||
}, | ||
{ concurrency: DRIVE_CONCURRENCY } | ||
); | ||
} | ||
|
||
makeScript({}, async ({ execute }, logger) => { | ||
// We only have 469 of them, so we can just do them all | ||
const connectors = await ConnectorResource.listByType("google_drive", {}); | ||
for (const connector of connectors) { | ||
await upsertFoldersForConnector(connector, execute, logger); | ||
} | ||
}); | ||
|
||
// Copy-pasted from the migration script for source URLs | ||
function getSourceUrlForGoogleDriveSheet(driveFileId: string): string { | ||
return `https://docs.google.com/spreadsheets/d/${driveFileId}/edit`; | ||
} |
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,3 @@ | ||
-- Migration created on Jan 21, 2025 | ||
ALTER TABLE "public"."remote_databases" ADD COLUMN "permission" VARCHAR(255) NOT NULL DEFAULT 'selected'; | ||
ALTER TABLE "public"."remote_schemas" ADD COLUMN "permission" VARCHAR(255) NOT NULL DEFAULT 'selected'; |
Oops, something went wrong.