public getShapes()

in services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.ts [155:213]


  public getShapes(template) {
    this.selectedImage = null;
    const controls = ['notebook_image_name', 'shape', 'gpu_type', 'gpu_count'];

    controls.forEach(control => {
      this.createExploratoryForm.controls[control].setValue(null);
      if (control !== 'shape') {
        this.createExploratoryForm.controls[control].clearValidators();
        this.createExploratoryForm.controls[control].updateValueAndValidity();
      }
    });

    if (this.additionalParams.gpu) {
      this.additionalParams.gpu = !this.additionalParams.gpu;
      this.createExploratoryForm.controls['gpu_enabled'].setValue(this.additionalParams.gpu);
    }

    if (this.selectedCloud === 'gcp' && template?.image === 'docker.datalab-deeplearning') {
      this.createExploratoryForm.controls['notebook_image_name'].setValidators([Validators.required]);
      this.createExploratoryForm.controls['notebook_image_name'].updateValueAndValidity();
    }

    if (this.selectedCloud === 'gcp' &&
        (template?.image === 'docker.datalab-jupyter' ||
        template?.image === 'docker.datalab-deeplearning' ||
        template?.image === 'docker.datalab-tensor')) {

      this.gpuTypes = template?.computationGPU ? HelpUtils.sortGpuTypes(template.computationGPU) : [];

      // tslint:disable-next-line:max-line-length
      if (template?.image === 'docker.datalab-tensor' /**|| template?.image === 'docker.datalab-jupyter-conda'|| template?.image === 'docker.datalab-jupyter-gpu' */|| template?.image === 'docker.datalab-deeplearning') {
        this.addGpuFields();
      }
    }

    this.currentTemplate = template;
    const allowed: any = ['GPU optimized'];

    if (template.exploratory_environment_versions[0].template_name.toLowerCase().indexOf('tensorflow') === -1
      && template.exploratory_environment_versions[0].template_name.toLowerCase().indexOf('deeplearning') === -1
      && template.exploratory_environment_versions[0].template_name.toLowerCase().indexOf('deep learning') === -1
      && template.exploratory_environment_versions[0].template_name.toLowerCase().indexOf('data science') === -1
    ) {
      const filtered = Object.keys(
        SortUtils.shapesSort(template.exploratory_environment_shapes))
        .filter(key => !(allowed.includes(key)))
        .reduce((obj, key) => {
          obj[key] = template.exploratory_environment_shapes[key];
          return obj;
        }, {});
      template.exploratory_environment_shapes.computation_resources_shapes = filtered;
      this.shapes = SortUtils.shapesSort(template.exploratory_environment_shapes.computation_resources_shapes);
      this.getImagesList();
    } else {
      this.shapes = SortUtils.shapesSort(template.exploratory_environment_shapes);
      this.getImagesList();
    }
    this.areShapes = !!Object.keys(this.shapes).length;
  }