You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datalab.apache.org by dg...@apache.org on 2021/01/28 09:50:47 UTC

[incubator-datalab] 03/11: [DATALAB-2233]: added GPU count

This is an automated email from the ASF dual-hosted git repository.

dgnatyshyn pushed a commit to branch DATALAB-2233
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git

commit 13985e9f0abd2181861858f771a25234de9ee820
Author: Dmytro_Gnatyshyn <di...@ukr.net>
AuthorDate: Mon Jan 25 17:50:56 2021 +0200

    [DATALAB-2233]: added GPU count
---
 ...utational-resource-create-dialog.component.html | 54 +++++++++++++---------
 ...utational-resource-create-dialog.component.scss | 23 ++++-----
 ...mputational-resource-create-dialog.component.ts | 27 ++++++++++-
 3 files changed, 68 insertions(+), 36 deletions(-)

diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.html b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.html
index 72831e9..238d685 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.html
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.html
@@ -187,11 +187,11 @@
                   <label class="label">Master GPU type</label>
                   <div class="control selector-wrapper">
                     <mat-form-field>
-<!--                      <mat-label>Select master GPU type</mat-label>-->
                       <mat-select formControlName="master_GPU_type" disableOptionCentering
                                   placeholder="Select master GPU type">
-                        <mat-option *ngFor="let type of selectedImage.GPU.masterGPUType" [value]="type"
-                                    >{{ type }}
+                        <mat-option *ngFor="let type of selectedImage.GPU.masterGPUType"
+                                    [value]="type" (click)="setGpuCount('master', type)">
+                          {{ type }}
                         </mat-option>
                         <mat-option *ngIf="!clusterTypes.length" class="multiple-select ml-10" disabled>Master GPU types list
                           is empty</mat-option>
@@ -207,8 +207,8 @@
                   <div class="control selector-wrapper">
                     <mat-form-field>
                       <mat-label>Select slave GPU type</mat-label>
-                      <mat-select formControlName="slave_GPU_type" disableOptionCentering>
-                        <mat-option *ngFor="let type of selectedImage.GPU.slaveGPUType" [value]="type">
+                      <mat-select formControlName="slave_GPU_сount" disableOptionCentering>
+                        <mat-option *ngFor="let type of selectedImage.GPU.slaveGPUType" [value]="type" (click)="setGpuCount('master', type)">
                           {{ type }}
                         </mat-option>
                         <mat-option *ngIf="!selectedImage.GPU.slaveGPUType?.length" class="multiple-select ml-10" disabled>Slave GPU types list is empty</mat-option>
@@ -224,24 +224,36 @@
               <div class="col">
                 <div class="control-group">
                   <label class="label">Master GPU сount</label>
-                  <div class="control">
-                    <input type="number" class="form-control" min="{{minInstanceNumber}}" max="{{maxInstanceNumber}}"
-                           formControlName="master_GPU_сount" (keypress)="CheckUtils.isNumberKey($event)" />
-                    <span class="error" *ngIf="!resourceForm?.controls.instance_number.valid">
-                  <span>Only integer values greater than or equal to {{ minInstanceNumber }} and less than
-                    {{ maxInstanceNumber }} are allowed.</span>
-                </span>
+                  <div class="control selector-wrapper">
+                    <mat-form-field>
+                      <mat-label>Select master GPU type</mat-label>
+                      <mat-select formControlName="master_GPU_type" disableOptionCentering >
+                        <mat-option *ngFor="let type of masterGPUcount" [value]="type">
+                          {{ type }}
+                        </mat-option>
+                        <mat-option *ngIf="!masterGPUcount?.length" class="multiple-select ml-10" disabled>Slave GPU types list is empty</mat-option>
+                      </mat-select>
+                      <button class="caret">
+                        <i class="material-icons">keyboard_arrow_down</i>
+                      </button>
+                    </mat-form-field>
                   </div>
                 </div>
                 <div class="control-group">
                   <label class="label">Slave GPU сount</label>
-                  <div class="control">
-                    <input type="number" class="form-control" min="{{minInstanceNumber}}" max="{{maxInstanceNumber}}"
-                           formControlName="slave_GPU_сount" (keypress)="CheckUtils.isNumberKey($event)" />
-                    <span class="error" *ngIf="!resourceForm?.controls.instance_number.valid">
-                  <span>Only integer values greater than or equal to {{ minInstanceNumber }} and less than
-                    {{ maxInstanceNumber }} are allowed.</span>
-                </span>
+                  <div class="control selector-wrapper">
+                    <mat-form-field>
+                      <mat-label>Select slave GPU сount</mat-label>
+                      <mat-select formControlName="slave_GPU_сount" disableOptionCentering>
+                        <mat-option *ngFor="let type of slaveGPUcount" [value]="type" (click)="setGpuCount('slave')">
+                          {{ type }}
+                        </mat-option>
+                        <mat-option *ngIf="!selectedImage.GPU.slaveGPUType?.length" class="multiple-select ml-10" disabled>Slave GPU types list is empty</mat-option>
+                      </mat-select>
+                      <button class="caret">
+                        <i class="material-icons">keyboard_arrow_down</i>
+                      </button>
+                    </mat-form-field>
                   </div>
                 </div>
 
@@ -251,7 +263,7 @@
 
         <div class="checkbox-group control-group m-top-15" *ngIf="PROVIDER === 'aws'" [hidden]="!selectedImage.templates.length">
           <div class="d-flex cursor-pointer label" (click)="openBlock('spotInstances')">
-            <div class="empty-checkbox ml-10" [ngClass]="{'checked': isBlockOpen.spotInstances}" (change)="selectSpotInstances()">
+            <div class="empty-checkbox ml-10" [ngClass]="{'checked': isBlockOpen.spotInstances}" (click)="selectSpotInstances()">
               <span class="checked-checkbox" *ngIf="isBlockOpen.spotInstances"></span>
             </div>
             <span class="pl-5">Spot instance</span><span [hidden]="!isBlockOpen.spotInstances">&nbsp;bid, %</span>
@@ -272,7 +284,7 @@
                [hidden]="PROVIDER === 'gcp' && selectedImage?.image === 'docker.datalab-dataengine-service'"
                *ngIf="notebook_instance?.image !== 'docker.datalab-zeppelin'">
               <div class="d-flex cursor-pointer label" (click)="openBlock('configuration')">
-                <div class="empty-checkbox ml-10" [ngClass]="{'checked': isBlockOpen.configuration}" (change)="selectConfiguration()">
+                <div class="empty-checkbox ml-10" [ngClass]="{'checked': isBlockOpen.configuration}" (click)="selectConfiguration()">
                   <span class="checked-checkbox" *ngIf="isBlockOpen.configuration"></span>
                 </div>
                 <span class="pl-5">Cluster configurations</span>
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.scss b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.scss
index 65db6a9..b61f0dc 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.scss
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.scss
@@ -24,11 +24,11 @@
     .control-group {
       position: relative;
       .label {
-        width: 42%;
+        width: 40%;
         padding-left: 10px;
       }
       .control {
-        width: 58%;
+        width: 60%;
       }
     }
     span {
@@ -74,18 +74,17 @@
       opacity: 1;
     }
   }
-  &.preemptible {
+  .preemptible {
     .label {
-      line-height: 36px;
-      padding: 0;
-      align-items: center;
-
+      padding-left: 10px;
     }
     .control {
       position: relative;
     }
   }
-
+  .align {
+    margin-left: 25px;
+  }
   .spot-details, .preemptible-details {
     position: relative;
     .error {
@@ -93,7 +92,7 @@
     }
 
     &.show {
-      height: 36px;
+      height: 50px;
       text-align: right;
     }
   }
@@ -133,7 +132,7 @@
       font-size: 13px;
       text-align: justify;
       display: inline-block;
-      padding-top: 15px;
+      padding-top: 5px;
       padding-bottom: 10px;
     }
     span {
@@ -155,8 +154,4 @@
     padding-top: 5px;
     padding-bottom: 5px;
   }
-  .error-bottom{
-    transform: translateY(9px);
-    display: block;
-  }
 }
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.ts
index b602d8f..1ef822b 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.ts
@@ -59,6 +59,8 @@ export class ComputationalResourceCreateDialogComponent implements OnInit {
   public minSpotPrice: number = 0;
   public maxSpotPrice: number = 0;
   public resourceForm: FormGroup;
+  public masterGPUcount: Array<number>;
+  public slaveGPUcount: Array<number>;
   public isBlockOpen = {
     preemptible: false,
     gpu: false,
@@ -67,6 +69,7 @@ export class ComputationalResourceCreateDialogComponent implements OnInit {
   };
 
 
+
   // @ViewChild('spotInstancesCheck') spotInstancesSelect;
   // @ViewChild('preemptibleNode') preemptible;
   // @ViewChild('addGpu') addGpuForm;
@@ -117,7 +120,6 @@ export class ComputationalResourceCreateDialogComponent implements OnInit {
   }
 
   public selectConfiguration() {
-    console.log(this.isBlockOpen.configuration);
     if (this.isBlockOpen.configuration) {
       const template = (this.selectedImage.image === 'docker.datalab-dataengine-service')
         ? CLUSTER_CONFIGURATION.EMR
@@ -338,4 +340,27 @@ export class ComputationalResourceCreateDialogComponent implements OnInit {
   public openBlock(block: string) {
     this.isBlockOpen[block] = !this.isBlockOpen[block];
   }
+
+  public setGPUCount(type): Array<number> {
+    switch (type) {
+      case 'n1-highmem-32' || 'n1-highcpu-32':
+        return [4, 8];
+      case 'n1-highmem-16':
+        return [2, 4, 8];
+      default:
+        return [1, 2, 4, 8];
+    }
+  }
+
+  public setGpuCount(type: any, gpuType: any) {
+    if (type === 'master') {
+      const masterShape = this.setGPUCount(this.resourceForm.controls['shape_master'].value);
+      this.masterGPUcount = this.setGPUCount(masterShape);
+    } else {
+      const slaveShape = this.setGPUCount(this.resourceForm.controls['shape_slave'].value);
+      this.slaveGPUcount = this.setGPUCount(slaveShape);
+    }
+
+    console.log(this.masterGPUcount, this.slaveGPUcount);
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org