-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add launch all frontend functionality for sensors
- Loading branch information
Showing
7 changed files
with
447 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
62 changes: 62 additions & 0 deletions
62
js_modules/dagster-ui/packages/ui-core/src/launchpad/useLaunchMultipleRunsWithTelemetry.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,62 @@ | ||
import {useCallback} from 'react'; | ||
import {useHistory} from 'react-router-dom'; | ||
|
||
import {showLaunchError} from './showLaunchError'; | ||
import {useMutation} from '../apollo-client'; | ||
import {TelemetryAction, useTelemetryAction} from '../app/Telemetry'; | ||
import { | ||
LAUNCH_MULTIPLE_RUNS_MUTATION, | ||
LaunchBehavior, | ||
handleLaunchMultipleResult, | ||
} from '../runs/RunUtils'; | ||
import { | ||
LaunchMultipleRunsMutation, | ||
LaunchMultipleRunsMutationVariables, | ||
} from '../runs/types/RunUtils.types'; | ||
|
||
export function useLaunchMultipleRunsWithTelemetry() { | ||
const [launchMultipleRuns] = useMutation< | ||
LaunchMultipleRunsMutation, | ||
LaunchMultipleRunsMutationVariables | ||
>(LAUNCH_MULTIPLE_RUNS_MUTATION); | ||
|
||
const logTelemetry = useTelemetryAction(); | ||
const history = useHistory(); | ||
|
||
return useCallback( | ||
async (variables: LaunchMultipleRunsMutationVariables, behavior: LaunchBehavior) => { | ||
const executionParamsList = Array.isArray(variables.executionParamsList) | ||
? variables.executionParamsList | ||
: [variables.executionParamsList]; | ||
const jobNames = executionParamsList.map((params) => params.selector?.jobName); | ||
|
||
if (jobNames.length !== executionParamsList.length || jobNames.includes(undefined)) { | ||
return; | ||
} | ||
|
||
const metadata: {[key: string]: string | string[] | null | undefined} = { | ||
jobNames: jobNames.filter((name): name is string => name !== undefined), | ||
opSelection: undefined, | ||
}; | ||
|
||
let result; | ||
try { | ||
result = (await launchMultipleRuns({variables})).data?.launchMultipleRuns; | ||
if (result) { | ||
handleLaunchMultipleResult(result, history, {behavior}); | ||
logTelemetry( | ||
TelemetryAction.LAUNCH_MULTIPLE_RUNS, | ||
metadata as {[key: string]: string | string[] | null | undefined}, | ||
); | ||
} | ||
|
||
return result; | ||
} catch (error) { | ||
console.error('error', error); | ||
showLaunchError(error as Error); | ||
} | ||
return undefined; | ||
}, | ||
[history, launchMultipleRuns, logTelemetry], | ||
); | ||
} |
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
102 changes: 102 additions & 0 deletions
102
js_modules/dagster-ui/packages/ui-core/src/runs/types/RunUtils.types.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.