All files / widgets/CreateNotebookJobForm/JobEnvironment jobEnvironment.ts

44.44% Statements 4/9
0% Branches 0/2
0% Functions 0/1
44.44% Lines 4/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 381x   1x 1x                                               1x                    
import { URLExt } from '@jupyterlab/coreutils';
import { Scheduler } from '@jupyterlab/scheduler';
import { ContentsManager, ServerConnection } from '@jupyterlab/services';
import { parseListSageMakerImagesAPIResponse } from '../../../utils';
import { FormState } from '../CreateNotebookJobform';
 
export interface IAutoDetectedConfig {
  name: string;
  label: string;
  description: string;
  value: any;
}
 
export type JobEnvironmentProps = Scheduler.IAdvancedOptionsProps & {
  isDisabled: boolean;
  executionEnvironments: {
    environment_configs: IAutoDetectedConfig[] | null;
    auto_detected_config: IAutoDetectedConfig[];
  };
  formState: FormState;
  formErrors: Scheduler.ErrorsType;
  setFormState: React.Dispatch<React.SetStateAction<FormState>>;
  setFormErrors: (errors: Scheduler.ErrorsType) => void;
  requestClient: ServerConnection.ISettings;
  contentsManager: ContentsManager;
}
 
export async function fetchKernelAndImages(requestClient: ServerConnection.ISettings) {
  const url = URLExt.join(requestClient.baseUrl, '/sagemaker_studio_jupyter_scheduler/sagemaker_images');
  const response = await ServerConnection.makeRequest(url, {}, requestClient);
 
  if (response.status !== 200) {
    return {};
  } else {
    return parseListSageMakerImagesAPIResponse(await response.json());
  }
}