Skip to content

Commit

Permalink
Merge branch 'main' into thomas/apps-check
Browse files Browse the repository at this point in the history
  • Loading branch information
tdraier authored Jan 22, 2025
2 parents 5b9bee4 + 50fc9d3 commit 6795a8e
Show file tree
Hide file tree
Showing 149 changed files with 4,431 additions and 1,292 deletions.
3 changes: 2 additions & 1 deletion .authors
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ Fraggle: seb@dust.tt
spolu: spolu@dust.tt
thib-martin: thibault@dust.tt
tdraier: thomas@dust.tt
albandum: alban@dust.tt
albandum: alban@dust.tt
theo-vanneufville: theo@dust.tt
8 changes: 6 additions & 2 deletions .github/actions/slack-notify/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ inputs:
region:
description: "Region being deployed to"
required: false
is_revert:
description: "Whether reverting or deploying"
required: false
default: "false"

outputs:
thread_ts:
Expand Down Expand Up @@ -81,7 +85,7 @@ runs:
payload: |
channel: ${{ inputs.channel }}
text: |
🚀 Starting deployment of ${{ inputs.component }} `${{ inputs.image_tag }}`
${{ inputs.is_revert == 'true' && '⏮️' || '🚀' }} ${{ inputs.is_revert == 'true' && 'Starting revert of' || 'Starting deployment of' }} ${{ inputs.component }} `${{ inputs.image_tag }}`
• Region: `${{ inputs.region }}`
• Commit: <${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ inputs.image_tag }}>
• Workflow: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View build>
Expand All @@ -97,6 +101,6 @@ runs:
channel: ${{ inputs.channel }}
thread_ts: "${{ inputs.thread_ts }}"
text: |
❌ Build pipeline failed
${{ inputs.is_revert == 'true' && 'Revert' || 'Build' }} pipeline failed
${{ inputs.blocked == 'true' && format('Is blocked by channel topic: {0}', inputs.blocked) }}
• Check logs: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View details>
2 changes: 1 addition & 1 deletion .github/workflows/deploy-alerting-temporal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
regions:
description: "Regions to deploy to"
required: true
default: "us-central1"
default: "all"
type: choice
options:
- "us-central1"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-connectors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
regions:
description: "Regions to deploy to"
required: true
default: "us-central1"
default: "all"
type: choice
options:
- "us-central1"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
regions:
description: "Regions to deploy to"
required: true
default: "us-central1"
default: "all"
type: choice
options:
- "us-central1"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-front-edge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
regions:
description: "Regions to deploy to"
required: true
default: "us-central1"
default: "all"
type: choice
options:
- "us-central1"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-front.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
regions:
description: "Regions to deploy to"
required: true
default: "us-central1"
default: "all"
type: choice
options:
- "us-central1"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-oauth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
regions:
description: "Regions to deploy to"
required: true
default: "us-central1"
default: "all"
type: choice
options:
- "us-central1"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-prodbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
regions:
description: "Regions to deploy to"
required: true
default: "us-central1"
default: "all"
type: choice
options:
- "us-central1"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-viz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
regions:
description: "Regions to deploy to"
required: true
default: "us-central1"
default: "all"
type: choice
options:
- "us-central1"
Expand Down
41 changes: 30 additions & 11 deletions .github/workflows/list-tags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ name: List Image Tags
on:
workflow_dispatch:
inputs:
regions:
description: "Comma-separated list of regions to deploy"
region:
description: "Region to list images from"
type: choice
options:
- "us-central1"
- "europe-west1"
default: "us-central1"
required: true
component:
Expand All @@ -25,27 +26,45 @@ on:
- prodbox
- viz
required: true

env:
GCLOUD_PROJECT_ID: ${{ secrets.GCLOUD_PROJECT_ID }}
secrets:
GCLOUD_US_PROJECT_ID:
required: true
GCLOUD_EU_PROJECT_ID:
required: true

jobs:
list-tags:
permissions:
contents: read
id-token: write

runs-on: ubuntu-latest
steps:
- name: "Authenticate with Google Cloud"
uses: "google-github-actions/auth@v1"
- name: Set project ID
id: project
run: |
if [ "${{ inputs.region }}" = "us-central1" ]; then
echo "PROJECT_ID=${{ secrets.GCLOUD_US_PROJECT_ID }}" >> $GITHUB_OUTPUT
else
echo "PROJECT_ID=${{ secrets.GCLOUD_EU_PROJECT_ID }}" >> $GITHUB_OUTPUT
fi
- id: "auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCLOUD_SA_KEY }}"
create_credentials_file: true
workload_identity_provider: "projects/357744735673/locations/global/workloadIdentityPools/github-pool-apps/providers/github-provider-apps"
service_account: "github-build-invoker@${{ steps.project.outputs.PROJECT_ID }}.iam.gserviceaccount.com"

- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"
uses: "google-github-actions/setup-gcloud@v2"

- name: List available tags
run: |
echo "Latest tags for ${{ inputs.component }} in ${{ inputs.regions }}:"
echo "Latest tags for ${{ inputs.component }} in ${{ inputs.region }}:"
echo "-------------------------------------------"
gcloud container images list-tags ${{ inputs.regions }}-docker.pkg.dev/${{ env.GCLOUD_PROJECT_ID }}/dust-images/${{ inputs.component }} \
gcloud container images list-tags "${{ inputs.region }}-docker.pkg.dev/${{ steps.project.outputs.PROJECT_ID }}/dust-images/${{ inputs.component }}" \
--limit=10 \
--sort-by=~timestamp \
--format="table(timestamp.date('%Y-%m-%d %H:%M:%S'),tags[0])"
118 changes: 118 additions & 0 deletions .github/workflows/revert.yml
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
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`;
}
3 changes: 3 additions & 0 deletions connectors/migrations/db/migration_47.sql
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';
Loading

0 comments on commit 6795a8e

Please sign in to comment.