chore: import upstream snapshot with attribution
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,201 @@
|
||||
import type {
|
||||
DagsterMaterializeAssetsParams,
|
||||
DagsterMaterializeAssetsResponse,
|
||||
} from '@/tools/dagster/types'
|
||||
import {
|
||||
dagsterGraphqlUrl,
|
||||
dagsterRequestHeaders,
|
||||
dagsterUnionErrorMessage,
|
||||
parseAssetSelection,
|
||||
parseDagsterGraphqlResponse,
|
||||
} from '@/tools/dagster/utils'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
interface MaterializeAssetsResult {
|
||||
type: string
|
||||
run?: { runId: string }
|
||||
message?: string
|
||||
errors?: Array<{ message: string }>
|
||||
}
|
||||
|
||||
function buildMaterializeMutation(hasTags: boolean) {
|
||||
const varDefs = [
|
||||
'$repositoryLocationName: String!',
|
||||
'$repositoryName: String!',
|
||||
'$jobName: String!',
|
||||
'$assetSelection: [AssetKeyInput!]',
|
||||
]
|
||||
if (hasTags) varDefs.push('$tags: [ExecutionTag!]')
|
||||
|
||||
const execParams = [
|
||||
`selector: {
|
||||
repositoryLocationName: $repositoryLocationName
|
||||
repositoryName: $repositoryName
|
||||
jobName: $jobName
|
||||
assetSelection: $assetSelection
|
||||
}`,
|
||||
]
|
||||
if (hasTags) execParams.push('executionMetadata: { tags: $tags }')
|
||||
|
||||
return `
|
||||
mutation MaterializeAssets(${varDefs.join(', ')}) {
|
||||
launchRun(
|
||||
executionParams: {
|
||||
${execParams.join('\n ')}
|
||||
}
|
||||
) {
|
||||
type: __typename
|
||||
... on LaunchRunSuccess {
|
||||
run {
|
||||
runId
|
||||
}
|
||||
}
|
||||
... on RunConfigValidationInvalid {
|
||||
errors {
|
||||
message
|
||||
}
|
||||
}
|
||||
... on PipelineNotFoundError {
|
||||
message
|
||||
}
|
||||
... on InvalidSubsetError {
|
||||
message
|
||||
}
|
||||
... on UnauthorizedError {
|
||||
message
|
||||
}
|
||||
... on ConflictingExecutionParamsError {
|
||||
message
|
||||
}
|
||||
... on PresetNotFoundError {
|
||||
message
|
||||
}
|
||||
... on RunConflict {
|
||||
message
|
||||
}
|
||||
... on PythonError {
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
}
|
||||
|
||||
export const materializeAssetsTool: ToolConfig<
|
||||
DagsterMaterializeAssetsParams,
|
||||
DagsterMaterializeAssetsResponse
|
||||
> = {
|
||||
id: 'dagster_materialize_assets',
|
||||
name: 'Dagster Materialize Assets',
|
||||
description: 'Materialize selected assets by launching their asset job with an asset selection.',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
host: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description:
|
||||
'Dagster host URL (e.g., https://myorg.dagster.cloud/prod or http://localhost:3001)',
|
||||
},
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Dagster+ API token (leave blank for OSS / self-hosted)',
|
||||
},
|
||||
repositoryLocationName: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Repository location (code location) name',
|
||||
},
|
||||
repositoryName: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Repository name within the code location',
|
||||
},
|
||||
jobName: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Asset job that contains the assets, e.g. "__ASSET_JOB" or a named asset job',
|
||||
},
|
||||
assetSelection: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'Comma- or newline-separated asset keys to materialize, each slash-delimited (e.g. "raw/events, summary")',
|
||||
},
|
||||
tags: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Tags as a JSON array of {key, value} objects (optional)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => dagsterGraphqlUrl(params.host),
|
||||
method: 'POST',
|
||||
headers: (params) => dagsterRequestHeaders(params),
|
||||
body: (params) => {
|
||||
const assetSelection = parseAssetSelection(params.assetSelection)
|
||||
if (assetSelection.length === 0) {
|
||||
throw new Error('assetSelection must contain at least one asset key')
|
||||
}
|
||||
|
||||
const variables: Record<string, unknown> = {
|
||||
repositoryLocationName: params.repositoryLocationName,
|
||||
repositoryName: params.repositoryName,
|
||||
jobName: params.jobName,
|
||||
assetSelection,
|
||||
}
|
||||
|
||||
let hasTags = false
|
||||
if (params.tags) {
|
||||
try {
|
||||
variables.tags = JSON.parse(params.tags)
|
||||
hasTags = true
|
||||
} catch {
|
||||
throw new Error('Invalid JSON in tags')
|
||||
}
|
||||
}
|
||||
|
||||
return { query: buildMaterializeMutation(hasTags), variables }
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await parseDagsterGraphqlResponse<{ launchRun?: unknown }>(response)
|
||||
|
||||
const result = data.data?.launchRun as MaterializeAssetsResult | undefined
|
||||
if (!result) throw new Error('Unexpected response from Dagster')
|
||||
|
||||
if (result.type === 'LaunchRunSuccess' && result.run) {
|
||||
return {
|
||||
success: true,
|
||||
output: { runId: result.run.runId },
|
||||
}
|
||||
}
|
||||
|
||||
if (result.type === 'RunConfigValidationInvalid' && result.errors?.length) {
|
||||
throw new Error(
|
||||
`RunConfigValidationInvalid: ${result.errors.map((e) => e.message).join('; ')}`
|
||||
)
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`${result.type}: ${dagsterUnionErrorMessage(result, 'Materialize assets failed')}`
|
||||
)
|
||||
},
|
||||
|
||||
outputs: {
|
||||
runId: {
|
||||
type: 'string',
|
||||
description: 'The globally unique ID of the launched materialization run',
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user