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

pingsutw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git


The following commit(s) were added to refs/heads/master by this push:
     new be8d662  SUBMARINE-955. Add Limit on Experiment Name
be8d662 is described below

commit be8d662fe643a1014adf0d9018f0b642bc4bdeda
Author: noidname01 <[email protected]>
AuthorDate: Fri Aug 6 11:35:29 2021 +0800

    SUBMARINE-955. Add Limit on Experiment Name
    
    ### What is this PR for?
    
    [Former PR](https://issues.apache.org/jira/browse/SUBMARINE-886) has some 
edge case.
    Like:
    * \-
    * --invalid
    
    Valid cases are like:
    * valid-one
    * valid1
    
    So I change the pattern for validating experiment name to filter these 
cases.
    And I also add this pattern to experiment name of predefine template.
    
    ### What type of PR is it?
    [Bug Fix]
    
    ### Todos
    
    None
    
    ### What is the Jira issue?
    
    https://issues.apache.org/jira/projects/SUBMARINE/issues/SUBMARINE-955
    
    ### How should this be tested?
    
    Open the workbench and type invalid experiment name.
    
    ### Screenshots (if appropriate)
    
    invalid name on custom experiment
    ![2021-08-01 14-47-13 
的螢幕擷圖](https://user-images.githubusercontent.com/55401762/127762058-e73ad41d-546b-4b45-960a-5d15b646d2cc.png)
    invalid name on predefine experiment
    ![2021-08-01 14-47-34 
的螢幕擷圖](https://user-images.githubusercontent.com/55401762/127762063-1510f983-a388-4472-89c4-7b7451cbaab5.png)
    valid name on custom experiment
    ![2021-08-01 14-48-07 
的螢幕擷圖](https://user-images.githubusercontent.com/55401762/127762066-2816e348-3202-43ce-b541-41ab4c85ca1b.png)
    valid name on predefine experiment
    ![2021-08-01 14-47-52 
的螢幕擷圖](https://user-images.githubusercontent.com/55401762/127762067-eda0d8c6-cb71-426c-a8af-6f446e9bffa8.png)
    
    ### Questions:
    * Do the license files need updating? No
    * Are there breaking changes for older versions? No
    * Does this need new documentation? No
    
    Author: noidname01 <[email protected]>
    
    Signed-off-by: Kevin <[email protected]>
    
    Closes #692 from noidname01/SUBMARINE-955 and squashes the following 
commits:
    
    f096c1b0 [noidname01] fix indent and fix description
    71cd759e [noidname01] modify pattern for experiment name
---
 .../experiment-customized-form.component.html                     | 2 +-
 .../experiment-customized-form.component.ts                       | 2 +-
 .../experiment-predefined-form.component.html                     | 8 +++++++-
 .../experiment-predefined-form.component.scss                     | 6 ++++++
 .../experiment-predefined-form.component.ts                       | 5 ++++-
 5 files changed, 19 insertions(+), 4 deletions(-)

diff --git 
a/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-customized-form/experiment-customized-form.component.html
 
b/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-customized-form/experiment-customized-form.component.html
index 3021fda..4c29168 100644
--- 
a/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-customized-form/experiment-customized-form.component.html
+++ 
b/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-customized-form/experiment-customized-form.component.html
@@ -42,7 +42,7 @@
             placeholder="mnist-example"
           />
           <div class="alert-message" 
*ngIf="experiment.get('experimentName').hasError('pattern')">
-            Only letters(a-z), numbers(0-9), and hyphens(-) are allowed.
+            Only letters(a-z), numbers(0-9), and hyphens are allowed, but you 
can't start with hyphens.
           </div>
         </div>
         <div class="single-field-group">
diff --git 
a/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-customized-form/experiment-customized-form.component.ts
 
b/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-customized-form/experiment-customized-form.component.ts
index 9372493..0560c9b 100644
--- 
a/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-customized-form/experiment-customized-form.component.ts
+++ 
b/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-customized-form/experiment-customized-form.component.ts
@@ -88,7 +88,7 @@ export class ExperimentCustomizedFormComponent implements 
OnInit, OnDestroy {
 
   ngOnInit() {
     this.experiment = new FormGroup({
-      experimentName: new FormControl(null, 
[Validators.pattern('[a-zA-Z0-9\-]*'), Validators.required]),
+      experimentName: new FormControl(null, 
[Validators.pattern('[a-zA-Z0-9][a-zA-Z0-9\-]*'), Validators.required]),
       description: new FormControl(null, [Validators.required]),
       namespace: new FormControl(this.defaultNameSpace, [Validators.required]),
       cmd: new FormControl('', [Validators.required]),
diff --git 
a/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-predefined-form/experiment-predefined-form.component.html
 
b/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-predefined-form/experiment-predefined-form.component.html
index dc4faeb..0a94c96 100644
--- 
a/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-predefined-form/experiment-predefined-form.component.html
+++ 
b/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-predefined-form/experiment-predefined-form.component.html
@@ -36,9 +36,15 @@
     <h4 nz-typography>Configurable Parameters</h4>
     <nz-form-item *ngFor="let item of paramList">
       <nz-form-label [nzSpan]="5" [nzRequired]="item.required" 
[nzFor]="item.name">{{ item.name }}</nz-form-label>
-      <nz-form-control [nzSpan]="12" nzErrorTip="Please provide the value!">
+      <nz-form-control [nzSpan]="12" nzErrorTip="Please provide the value!" 
*ngIf="item.name != 'experiment_name'">
         <input type="text" nz-input [id]="item.name" 
[formControlName]="item.name" />
       </nz-form-control>
+      <nz-form-control [nzSpan]="12" *ngIf="item.name == 'experiment_name'">
+        <input type="text" nz-input [id]="item.name" 
[formControlName]="item.name" />
+        <div class="alert-message" 
*ngIf="predefinedForm.get('params').get(item.name).hasError('pattern')">
+          Only letters(a-z), numbers(0-9), and hyphens are allowed, but you 
can't start with hyphens.
+        </div>
+      </nz-form-control>
     </nz-form-item>
   </div>
 
diff --git 
a/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-predefined-form/experiment-predefined-form.component.scss
 
b/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-predefined-form/experiment-predefined-form.component.scss
index 042f3ce..e3b796a 100644
--- 
a/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-predefined-form/experiment-predefined-form.component.scss
+++ 
b/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-predefined-form/experiment-predefined-form.component.scss
@@ -16,3 +16,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
+ .alert-message {
+    color: red;
+    margin-top: .3rem;
+    line-height: normal;
+}
\ No newline at end of file
diff --git 
a/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-predefined-form/experiment-predefined-form.component.ts
 
b/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-predefined-form/experiment-predefined-form.component.ts
index fe6a16f..5a1864f 100644
--- 
a/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-predefined-form/experiment-predefined-form.component.ts
+++ 
b/submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-predefined-form/experiment-predefined-form.component.ts
@@ -151,7 +151,10 @@ export class ExperimentPredefinedFormComponent implements 
OnInit, OnDestroy {
     let controls = {};
     for (let item of this.templates[this.currentOption].templateParams) {
       controls[item.name] = [item.value];
-      if (item.required === 'true') 
controls[item.name].push([Validators.required]);
+      if (item.required === 'true') {
+        if(item.name !== 'experiment_name') 
controls[item.name].push([Validators.required]);
+        else controls[item.name].push([Validators.required, 
Validators.pattern('[a-zA-Z0-9][a-zA-Z0-9\-]*')]);
+      }
     }
     const new_param_group = this.fb.group(controls);
     this.predefinedForm.setControl('params', new_param_group);

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to