|
| 1 | +/* |
| 2 | + * Copyright 2023 The Kubernetes Authors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import { Arguments } from "@kui-shell/core" |
| 18 | +import { MadWizardOptions } from "madwizard" |
| 19 | + |
| 20 | +import appName from "./appName" |
| 21 | +import { ProfileOptions } from "./options" |
| 22 | + |
| 23 | +export default async function logs(args: Arguments<ProfileOptions>) { |
| 24 | + // Display logs for this jobID; if not provided, the user will be |
| 25 | + // prompted (via the guidebook) to choose one |
| 26 | + const jobId = args.argvNoOptions[args.argvNoOptions.indexOf("logs") + 1] |
| 27 | + if (jobId) { |
| 28 | + process.env.JOB_ID = jobId |
| 29 | + } |
| 30 | + |
| 31 | + // play this guidebook |
| 32 | + const guidebook = jobId === undefined ? "ml/ray/aggregator" : "ml/ray/aggregator/with-jobid" |
| 33 | + |
| 34 | + // but only interactive starting here |
| 35 | + const ifor = |
| 36 | + jobId === undefined |
| 37 | + ? ["ml/ray/cluster/choose", "ml/ray/cluster/choose/kubernetes", "ml/ray/run/choose/list-jobs"] |
| 38 | + : undefined |
| 39 | + |
| 40 | + const options: MadWizardOptions = Object.assign({ |
| 41 | + appName, |
| 42 | + store: args.parsedOptions.s || process.env.GUIDEBOOK_STORE, |
| 43 | + verbose: args.parsedOptions.V, |
| 44 | + profile: args.parsedOptions.profile || (await import("madwizard").then((_) => _.Profiles.lastUsed())), |
| 45 | + interactive: false, |
| 46 | + ifor, |
| 47 | + }) |
| 48 | + |
| 49 | + const { guide } = await import("madwizard/dist/fe/cli") |
| 50 | + |
| 51 | + await guide([appName, "guide", guidebook], undefined, options) |
| 52 | + return true |
| 53 | +} |
0 commit comments