Conversation
|
@t-anjam, |
| */ | ||
| export function tryMultiplePythons(paths: string[]): Promise<string> { | ||
| let promise: Promise<string> = Promise.reject(null); | ||
| //let promise: Promise<string> = Promise.reject(null); |
There was a problem hiding this comment.
yeah just remove that line
python/controllers/ncj_controller.py
Outdated
| @@ -7,13 +7,13 @@ | |||
|
|
|||
| @app.procedure("submit-ncj-job") | |||
| def submitNcjJob(request: JsonRpcRequest, template, parameters): | |||
There was a problem hiding this comment.
was like that before but should follow python coding style so submit_ncj_job
python/controllers/ncj_controller.py
Outdated
| return {"what": "it works"} | ||
|
|
||
| @app.procedure("get-ncj-pool") | ||
| def getNcjPool(request: JsonRpcRequest, template, parameters): |
There was a problem hiding this comment.
can you call that expand_ncj_pool instead(and change at id also to be expand-ncj-pool
|
|
||
| constructor(private templateService: NcjTemplateService, private route: ActivatedRoute) { } | ||
| constructor(private templateService: NcjTemplateService, private route: ActivatedRoute) { | ||
|
|
There was a problem hiding this comment.
remove spaces as it was before
| this.mode_state = "None"; | ||
| this.form = new FormGroup({a: new FormControl()}); | ||
| } | ||
| private ngOnInit() { |
|
|
||
| public ngOnInit() { | ||
| private templateService: NcjTemplateService) { | ||
| this.mode_state = "None"; |
| public ngOnInit() { | ||
| private templateService: NcjTemplateService) { | ||
| this.mode_state = "None"; | ||
| this.form = new FormGroup({a: new FormControl()}); |
|
|
||
| public createForms() { | ||
| let parameterKeys = Object.keys(this.jobTemplate.parameters); | ||
| private createForms() { |
There was a problem hiding this comment.
make private methods start with _
| for (let key of poolParameters) { | ||
| if ("defaultValue" in this.poolTemplate.parameters[key]) { | ||
| const defaultValue = String(this.poolTemplate.parameters[key].defaultValue); | ||
| fg[key] = new FormControl(defaultValue); |
There was a problem hiding this comment.
I think you should separate the pool and job properties in 2 different file group.
Form should be
this.jobParams = new FormGroup(jobFg)
this.poolParams = new FormGroup(poolFg)
this.form = formBuilder.group({pool: this.poolParams, job: this.jobParams});There was a problem hiding this comment.
let's wait till UX converges to a final design
There was a problem hiding this comment.
This will be much better that merging all params togther and then trying to figure out which ones are belong to the pool and which ones to the job
There was a problem hiding this comment.
@t-anjam , how will the UX changes affect this? Is there something that we need to discuss in the UX which will affect our decision to keep the job and pool sections of the template separate?
There was a problem hiding this comment.
Was thinking about corner cases if we decided to add special inputs for the different modes, then which category would they fall into? job or pool? So I tried to kept it general by keeping them all in one form object.
There was a problem hiding this comment.
all inputs should belong to one or the other. and in the case it doesn't we can add another root param
| <bl-file-group-picker [formControlName]="param" [label]="param" class="form-element" [hint]="jobTemplate.parameters[param].metadata.description"> | ||
| </bl-file-group-picker> | ||
| </div> | ||
| <div *ngSwitchCase="'file-in-file-group'"> |
There was a problem hiding this comment.
There is way to much duplicates here. You should probably create another component called ncj-form-parameter to which you give the param type and it will choose the right value
There was a problem hiding this comment.
let's wait till UX converges to a final design
There was a problem hiding this comment.
what do you mean? you are going to need that either way. This looks way to hacky this way
There was a problem hiding this comment.
I was thinking it is better to wait in refactoring code until a finalized design is agreed upon. I predict there might be more changes to the UX in the nearby future.
There was a problem hiding this comment.
yes but this is completely independent from whatever the UI will looks like. You just make a component that display the right input dependending on the type. This is something we should have either way(even if there was no duplicate).
| </div> | ||
| <div *ngSwitchCase="'dropdown'"> | ||
| {{param}} | ||
| <select [formControlName]="param"> |
There was a problem hiding this comment.
use a md-select here instead of simple select
paselem
left a comment
There was a problem hiding this comment.
Added several comments for review. Please take a look.
| log.warn("Invalid form param. Not valid json.", params.formParams as any); | ||
| } | ||
| } | ||
| this.templateService.getTemplates(this.applicationId, this.actionId).subscribe((templates) => { |
There was a problem hiding this comment.
minor: why is this 'templates' instead of 'template' (note plural vs. singular')?
There was a problem hiding this comment.
Didn't name this method, but it's because it returns both job and pool template.
| if (this.poolTemplate && this.poolTemplate.parameters){ | ||
| poolParameters = Object.keys(this.poolTemplate.parameters); | ||
| } | ||
| let fg = {}; |
There was a problem hiding this comment.
not a big fan of abbreviated variables. I assume we can expand to formGroup?
| for (let key of parameterKeys) { | ||
|
|
||
| for (let key of jobParameters) { | ||
| if ("defaultValue" in this.jobTemplate.parameters[key]) { |
There was a problem hiding this comment.
shouldn't "defaultValue" be a const?
There was a problem hiding this comment.
this is actually would not be very useful because we do object.defaultValue after to access it.
There was a problem hiding this comment.
changed to if (this.jobTemplate.parameters[key].defaultValue)
| for (let key of poolParameters) { | ||
| if ("defaultValue" in this.poolTemplate.parameters[key]) { | ||
| const defaultValue = String(this.poolTemplate.parameters[key].defaultValue); | ||
| fg[key] = new FormControl(defaultValue); |
There was a problem hiding this comment.
@t-anjam , how will the UX changes affect this? Is there something that we need to discuss in the UX which will affect our decision to keep the job and pool sections of the template separate?
| delete expandedPoolTemplate.id; | ||
| this.jobTemplate.job.properties.poolInfo = { | ||
| autoPoolSpecification: { | ||
| autoPoolIdPrefix: "jobname", |
There was a problem hiding this comment.
should the prefix be the actual job name, not the string "jobname"?
Also, consider what kinds of constraints you will run into here. Batch has limitations on what values are allowed for this. It would be worth taking a look at the Batch docs to know what issues you may run into: https://docs.microsoft.com/en-us/rest/api/batchservice/
| </bl-complex-form> | ||
| </div> | ||
|
|
||
| <div *ngIf="mode_state == 'PoolNJob'"> |
There was a problem hiding this comment.
Inconsistent spacing around operators throught the file. In some cases you are using
'a==b'and in others
'a == b'There was a problem hiding this comment.
There is also an inconsistent use of ' and ".
Is the linter not catching these?
| </div> | ||
|
|
||
| <button *ngIf="mode_state!='None'" style="width:100px;background-color:#3e81b0;" (click) = "onSubmit()" type="button" md-raised-button>Submit</button> | ||
|
|
There was a problem hiding this comment.
nitpick: lots of empty lines here.
python/controllers/ncj_controller.py
Outdated
|
|
||
| @app.procedure("submit-ncj-job") | ||
| def submitNcjJob(request: JsonRpcRequest, template, parameters): | ||
| print("Got template", template) |
python/controllers/ncj_controller.py
Outdated
| print("Job is", job) | ||
| client.job.add(job) | ||
| return job_json | ||
| return {"what": "it works"} |
There was a problem hiding this comment.
Was this just for debugging? Change it back?
python/controllers/ncj_controller.py
Outdated
| job_json = client.job.expand_template(template, parameters) | ||
| print("Job json", job_json) | ||
| job = client.job.jobparameter_from_json(job_json) | ||
| print("Job is", job) |
| import * as inflection from "inflection"; | ||
| import "./submit-market-application.scss"; | ||
|
|
||
| enum NcjParameterExtendedType { |
There was a problem hiding this comment.
This enum was there before you should keep it and add more types
| } | ||
|
|
||
| class NcjParameterWrapper { | ||
| public type: NcjParameterExtendedType; |
There was a problem hiding this comment.
Same this class should still be here instead of the function
| return obs; | ||
| } | ||
|
|
||
| private _redirectToJob(data) { |
There was a problem hiding this comment.
As mentioned above, I think we need to pass a parameter back in here.
Regarding this API, I think passing in a 'data' object is a poor design. The method only requires the jobId, and should not need to know about the structure of some random data structure. If the data structure ever changes, then this method would need to get updated with it, which doesn't make sense. The interface should be kept as clean and simple as possible.
There was a problem hiding this comment.
I agree, I didn't create this function. I removed the data parameter for now till I know where to find the jobID/poolID for all three modes.
|
This is a pretty significant change, and I did not see any unit tests for it. I would be wary about letting this go into master without having unit tests come along with it. Also, our naming schema for feature branches follows the pattern feature/. Please follow that convention in the future. It helps us identify what kind of work is within the branch. |
| private _propagateChange: (value: any) => void = null; | ||
|
|
||
| constructor() { | ||
| console.log("Contructor:", this.parameter, this.type); |
There was a problem hiding this comment.
this._sub = this.parameterValue.valueChanges.subscribe((value) => {
if(propage) {propagate(value)};
});
| </md-input-container> | ||
| </div> | ||
| <div *ngFor="let param of poolParametersWrapper"> | ||
| <bl-parameter-input [formControlName]="param.id" [parameter]="param" [type]="types" [parameterValues]="poolParams.value"> </bl-parameter-input> |
|
|
||
| public ngOnInit(): void { | ||
| this.parameterValue.setValue(this.parameter.defaultValue); | ||
| // do not need |
There was a problem hiding this comment.
remove this one if not using
| import { NcjParameterRawType } from "app/models"; | ||
| import { BatchApplication, NcjParameterRawType } from "app/models"; | ||
| import { StorageService } from "app/services"; | ||
| import { Subject } from "rxjs"; |
There was a problem hiding this comment.
move the library import in the first group above. i.e @angular/... rxjs ...
|
|
||
| describe("text parameter type", () => { | ||
| let inputEl: DebugElement; | ||
| const initialInput: string = "initial input value"; |
There was a problem hiding this comment.
don't define the type here is is a bit too verbose. Only do the type if it is not obvious, on a class attribute or is not assigned right away(Like debugElement above).
Same for all variables below being number or string
There was a problem hiding this comment.
removed types for simple variables
| }); | ||
| }); | ||
|
|
||
| describe("fileinput parameter type", () => { |
There was a problem hiding this comment.
for this type you alos want to check the containerId given match what's in the formValues
paselem
left a comment
There was a problem hiding this comment.
Overall, looks pretty good! I have added a few comments to the review to consider. Thanks!
| <md-option *ngFor="let opt of parameter.allowedValues" [value]="opt"> {{ opt }} </md-option> | ||
| </md-select> | ||
| </div> | ||
| <div *ngSwitchCase="NcjParameterExtendedType.int"> |
There was a problem hiding this comment.
Should we add a specific type for 'bool'?
There was a problem hiding this comment.
I think bool scenario can be covered under dropdown case with two options: ['true', 'false'].
| export enum Modes { | ||
| None, | ||
| NewPoolAndJob, | ||
| OldPoolAndJob, |
There was a problem hiding this comment.
Nitpick: "ExistingPoolAndJob" instead of "OldPoolAndJob". Thoughts?
| } | ||
| this.jobParametersWrapper = jobTempWrapper; | ||
| const poolParameters = this.poolTemplate.parameters; | ||
| const poolTempWrapper: any[] = []; |
There was a problem hiding this comment.
shouldn't this be 'let' instead of 'const' if you are going to append to it later?
There was a problem hiding this comment.
Since the array variable is not being reassigned then it's safe to use const. Even though its contents are changing.
| defaultValue: 4, | ||
| }); | ||
| expect(parameter.type).toBe(NcjParameterExtendedType.int); | ||
| }); |
There was a problem hiding this comment.
May want to add a unit test here to check for the value as well (since this is an int which is a different case than what you have above for string).
There was a problem hiding this comment.
Same goes for cases below.
| <div [ngSwitch]="parameter.type"> | ||
| <div *ngSwitchCase="NcjParameterExtendedType.string"> | ||
| <md-input-container class="form-element"> | ||
| <input mdInput type="text" name="parameter.name" [formControl]="parameterValue" [placeholder]="parameter.name"> |
There was a problem hiding this comment.
remove the name= attribute here
| } | ||
|
|
||
| public getContainerFromFileGroup(fileGroup: string) { | ||
| return fileGroup && `fgrp-${fileGroup}`; |
There was a problem hiding this comment.
This is in StorageService.ncjFileGroupPrefix
We could move it into Constants if you like. We shouldn't hard code this anywhere.

I added mode selection option to the Market feature in BatchLabs. Now users can create pools, job + old pool, job + new pool submissions.





