Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 0 additions & 98 deletions e2e/data/LoopWithBranch.graph

Large diffs are not rendered by default.

39 changes: 21 additions & 18 deletions src/Daliuge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export namespace Daliuge {

//bash
COMMAND = "command",

// legacy
APP_CLASS = "appclass",
}

export enum DataType {
Expand Down Expand Up @@ -171,31 +174,31 @@ export namespace Daliuge {
}

// These are the canonical example definition of each field
export const groupStartField = new Field(null, FieldName.GROUP_START, "true", "true", "Is this node the start of a group?", false, DataType.Boolean, false, [], false, FieldType.Component, FieldUsage.NoPort);
export const groupEndField = new Field(null, FieldName.GROUP_END, "true", "true", "Is this node the end of a group?", false, DataType.Boolean, false, [], false, FieldType.Component, FieldUsage.NoPort);
export const groupStartField = new Field(null, FieldName.GROUP_START, "true", "Is this node the start of a group?", false, DataType.Boolean, false, [], false, FieldType.Component, FieldUsage.NoPort);
export const groupEndField = new Field(null, FieldName.GROUP_END, "true", "Is this node the end of a group?", false, DataType.Boolean, false, [], false, FieldType.Component, FieldUsage.NoPort);

export const branchYesField = new Field(null, FieldName.TRUE, "", "", "The affirmative output from a branch node", false, DataType.Object, false, [], false, FieldType.Component, FieldUsage.OutputPort);
export const branchNoField = new Field(null, FieldName.FALSE, "", "", "he negative output from a branch node", false, DataType.Object, false, [], false, FieldType.Component, FieldUsage.OutputPort);
export const branchYesField = new Field(null, FieldName.TRUE, "", "The affirmative output from a branch node", false, DataType.Object, false, [], false, FieldType.Component, FieldUsage.OutputPort);
export const branchNoField = new Field(null, FieldName.FALSE, "", "The negative output from a branch node", false, DataType.Object, false, [], false, FieldType.Component, FieldUsage.OutputPort);

export const dropClassField = new Field(null, FieldName.DROP_CLASS, "", "", "", false, DataType.String, false, [], false, FieldType.Component, FieldUsage.NoPort);
export const dropClassField = new Field(null, FieldName.DROP_CLASS, "", "", false, DataType.String, false, [], false, FieldType.Component, FieldUsage.NoPort);

export const executionTimeField = new Field(null, FieldName.EXECUTION_TIME, "5", "5", "", false, DataType.Float, false, [], false, FieldType.Constraint, FieldUsage.NoPort);
export const numCpusField = new Field(null, FieldName.NUM_OF_CPUS, "1", "1", "", false, DataType.Integer, false, [], false, FieldType.Constraint, FieldUsage.NoPort);
export const dataVolumeField = new Field(null, FieldName.DATA_VOLUME, "5", "5", "", false, DataType.Float, false, [], false, FieldType.Constraint, FieldUsage.NoPort);
export const executionTimeField = new Field(null, FieldName.EXECUTION_TIME, "5", "", false, DataType.Float, false, [], false, FieldType.Constraint, FieldUsage.NoPort);
export const numCpusField = new Field(null, FieldName.NUM_OF_CPUS, "1", "", false, DataType.Integer, false, [], false, FieldType.Constraint, FieldUsage.NoPort);
export const dataVolumeField = new Field(null, FieldName.DATA_VOLUME, "5", "", false, DataType.Float, false, [], false, FieldType.Constraint, FieldUsage.NoPort);

export const kField = new Field(null, FieldName.K, "1", "1", "", false, DataType.Integer, false, [], false, FieldType.Construct, FieldUsage.NoPort);
export const numCopiesField = new Field(null, FieldName.NUM_OF_COPIES, "1", "1", "", false, DataType.Integer, false, [], false, FieldType.Construct, FieldUsage.NoPort);
export const numInputsField = new Field(null, FieldName.NUM_OF_INPUTS, "1", "1", "", false, DataType.Integer, false, [], false, FieldType.Construct, FieldUsage.NoPort);
export const numIterationsField = new Field(null, FieldName.NUM_OF_ITERATIONS, "1", "1", "", false, DataType.Integer, false, [], false, FieldType.Construct, FieldUsage.NoPort);
export const kField = new Field(null, FieldName.K, "1", "", false, DataType.Integer, false, [], false, FieldType.Construct, FieldUsage.NoPort);
export const numCopiesField = new Field(null, FieldName.NUM_OF_COPIES, "1", "", false, DataType.Integer, false, [], false, FieldType.Construct, FieldUsage.NoPort);
export const numInputsField = new Field(null, FieldName.NUM_OF_INPUTS, "1", "", false, DataType.Integer, false, [], false, FieldType.Construct, FieldUsage.NoPort);
export const numIterationsField = new Field(null, FieldName.NUM_OF_ITERATIONS, "1", "", false, DataType.Integer, false, [], false, FieldType.Construct, FieldUsage.NoPort);

export const baseNameField = new Field(null, FieldName.BASE_NAME, "", "", "The base name of the class of this Member function", false, DataType.String, false, [], false, FieldType.Component, FieldUsage.NoPort);
export const selfField = new Field(null, FieldName.SELF, "", "", "", false, DataType.Object, false, [], false, FieldType.Component, FieldUsage.InputOutput);
export const baseNameField = new Field(null, FieldName.BASE_NAME, "", "The base name of the class of this Member function", false, DataType.String, false, [], false, FieldType.Component, FieldUsage.NoPort);
export const selfField = new Field(null, FieldName.SELF, "", "", false, DataType.Object, false, [], false, FieldType.Component, FieldUsage.InputOutput);

export const funcCodeField = new Field(null, FieldName.FUNC_CODE, "", "def func_name(args): return args", "Python function code", false, Daliuge.DataType.Python, false, [], false, Daliuge.FieldType.Component, FieldUsage.NoPort);
export const funcNameField = new Field(null, FieldName.FUNC_NAME, "", "func_name", "Python function name", false, Daliuge.DataType.Python, false, [], false, Daliuge.FieldType.Component, FieldUsage.NoPort);
export const funcCodeField = new Field(null, FieldName.FUNC_CODE, "def func_name(args): return args", "Python function code", false, Daliuge.DataType.Python, false, [], false, Daliuge.FieldType.Component, FieldUsage.NoPort);
export const funcNameField = new Field(null, FieldName.FUNC_NAME, "func_name", "Python function name", false, Daliuge.DataType.Python, false, [], false, Daliuge.FieldType.Component, FieldUsage.NoPort);

export const persistField = new Field(null, FieldName.PERSIST, "false", "false", "Specifies whether this data component contains data that should not be deleted after execution", false, Daliuge.DataType.Boolean, false, [], false, Daliuge.FieldType.Component, Daliuge.FieldUsage.NoPort);
export const streamingField = new Field(null, FieldName.STREAMING, "false", "false", "Specifies whether this data component streams input and output data", false, Daliuge.DataType.Boolean, false, [], false, Daliuge.FieldType.Component, Daliuge.FieldUsage.NoPort);
export const persistField = new Field(null, FieldName.PERSIST, "false", "Specifies whether this data component contains data that should not be deleted after execution", false, Daliuge.DataType.Boolean, false, [], false, Daliuge.FieldType.Component, Daliuge.FieldUsage.NoPort);
export const streamingField = new Field(null, FieldName.STREAMING, "false", "Specifies whether this data component streams input and output data", false, Daliuge.DataType.Boolean, false, [], false, Daliuge.FieldType.Component, Daliuge.FieldUsage.NoPort);

// This list defines the fields required for ALL nodes belonging to a given Category.Type
export const categoryTypeFieldsRequired = [
Expand Down
3 changes: 1 addition & 2 deletions src/Eagle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4153,7 +4153,6 @@ export class Eagle {
if (newType === Daliuge.DataType.Select){
if (field.getOptions().length === 0){
field.addOption(field.getValue());
field.addOption(field.getDefaultValue());
}
}

Expand Down Expand Up @@ -4616,7 +4615,7 @@ export class Eagle {
newNode.removeAllOutputPorts();

// add InputOutput port for dataType
const newInputOutputPort = new Field(Utils.generateFieldId(), srcPort.getDisplayText(), "", "", srcPort.getDescription(), false, srcPort.getType(), false, [], false, Daliuge.FieldType.Application, Daliuge.FieldUsage.InputOutput);
const newInputOutputPort = new Field(Utils.generateFieldId(), srcPort.getDisplayText(), "", srcPort.getDescription(), false, srcPort.getType(), false, [], false, Daliuge.FieldType.Application, Daliuge.FieldUsage.InputOutput);
newNode.addField(newInputOutputPort);

// set the parent of the new node
Expand Down
63 changes: 9 additions & 54 deletions src/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { Utils } from './Utils';
export class Field {
private displayText : ko.Observable<string>; // user-facing name
private value : ko.Observable<string>; // the current value
private defaultValue : ko.Observable<string>; // default value
private description : ko.Observable<string>;
private readonly : ko.Observable<boolean>;
private type : ko.Observable<Daliuge.DataType>; // NOTE: this is a little unusual (type can have more values than just the enum)
Expand Down Expand Up @@ -46,10 +45,9 @@ export class Field {

private issues : ko.ObservableArray<{issue:Errors.Issue, validity:Errors.Validity}>//keeps track of issues on the field

constructor(id: FieldId, displayText: string, value: string, defaultValue: string, description: string, readonly: boolean, type: Daliuge.DataType, precious: boolean, options: string[], positional: boolean, parameterType: Daliuge.FieldType, usage: Daliuge.FieldUsage){
constructor(id: FieldId, displayText: string, value: string, description: string, readonly: boolean, type: Daliuge.DataType, precious: boolean, options: string[], positional: boolean, parameterType: Daliuge.FieldType, usage: Daliuge.FieldUsage){
this.displayText = ko.observable(displayText);
this.value = ko.observable(value);
this.defaultValue = ko.observable(defaultValue);
this.description = ko.observable(description);
this.readonly = ko.observable(readonly);
this.type = ko.observable(type);
Expand Down Expand Up @@ -107,19 +105,6 @@ export class Field {
return this;
}

getDefaultValue = () : string => {
return this.defaultValue();
}

setDefaultValue = (value: string): Field => {
this.defaultValue(value);
return this;
}

hasDefaultValue = () : boolean => {
return this.value() === this.defaultValue();
}

getDescription = () : string => {
return this.description();
}
Expand All @@ -130,7 +115,7 @@ export class Field {
}

getDescriptionText : ko.PureComputed<string> = ko.pureComputed(() => {
return this.description() == "" ? "No description available" + " (" + this.type() + ", default value:'" + this.defaultValue() + "')" : this.description() + " (" + this.type() + ", default value:'" + this.defaultValue() + "')";
return this.description() == "" ? "No description available" + " (" + this.type() + ")" : this.description();
}, this);

getInputPosition = () : {x:number, y:number} => {
Expand Down Expand Up @@ -216,11 +201,6 @@ export class Field {
return this;
}

toggleDefault = (): Field => {
this.defaultValue((!Utils.asBool(this.defaultValue())).toString());
return this;
}

setType = (type: Daliuge.DataType) : Field => {
this.type(type);
return this;
Expand All @@ -245,13 +225,11 @@ export class Field {
}

editOption = (optionIndex: number, newVal: string) : Field => {
//if the option we are editing is selected well update the value or default value
// TODO: double check this, not sure I understand it fully
//if the option we are editing is selected well update the value
if(this.options()[optionIndex] === this.value()){
this.value(newVal)
}
if(this.options()[optionIndex] === this.defaultValue()){
this.defaultValue(newVal)
}

this.options()[optionIndex] = newVal
this.options.valueHasMutated()
Expand Down Expand Up @@ -283,13 +261,9 @@ export class Field {

//checking if a selected option is being deleted
let valueDeleted = false
let defaultValueDeleted = false;
if(this.options()[index] === this.value()){
valueDeleted = true
}
if(this.options()[index] === this.defaultValue()){
defaultValueDeleted = true
}

//deleting the option
this.options().splice(index,1)
Expand All @@ -298,9 +272,6 @@ export class Field {
if(valueDeleted){
this.value(this.options()[0])
}
if(defaultValueDeleted){
this.defaultValue(this.options()[0])
}
this.options.valueHasMutated()
return this;
}
Expand Down Expand Up @@ -437,7 +408,6 @@ export class Field {
clear = () : Field => {
this.displayText("");
this.value("");
this.defaultValue("");
this.description("");
this.readonly(false);
this.type(Daliuge.DataType.Unknown);
Expand All @@ -462,7 +432,7 @@ export class Field {
options.push(option);
}

const f = new Field(this.id(), this.displayText(), this.value(), this.defaultValue(), this.description(), this.readonly(), this.type(), this.precious(), options, this.positional(), this.parameterType(), this.usage());
const f = new Field(this.id(), this.displayText(), this.value(), this.description(), this.readonly(), this.type(), this.precious(), options, this.positional(), this.parameterType(), this.usage());
f.encoding(this.encoding());
f.isEvent(this.isEvent());
f.node(this.node());
Expand All @@ -474,12 +444,11 @@ export class Field {
}

shallowCopy = () : Field => {
const f = new Field(this.id(), this.displayText(), this.value(), this.defaultValue(), this.description(), this.readonly(), this.type(), this.precious(), this.options(), this.positional(), this.parameterType(), this.usage());
const f = new Field(this.id(), this.displayText(), this.value(), this.description(), this.readonly(), this.type(), this.precious(), this.options(), this.positional(), this.parameterType(), this.usage());

f.id = this.id;
f.displayText = this.displayText;
f.value = this.value;
f.defaultValue = this.defaultValue;
f.description = this.description;
f.readonly = this.readonly;
f.type = this.type;
Expand All @@ -497,11 +466,6 @@ export class Field {
return f;
}

resetToDefault = () : Field => {
this.value(this.defaultValue());
return this;
}

// TODO: rename this slightly so that it is more obvious that it is a user-facing version of the value
// as it is I get confused between this and getValue() when auto-completing
getFieldValue = () : string => {
Expand All @@ -515,7 +479,6 @@ export class Field {
copyWithIds = (src: Field, node: Node, id: FieldId) : Field => {
this.displayText(src.displayText());
this.value(src.value());
this.defaultValue(src.defaultValue());
this.description(src.description());
this.readonly(src.readonly());
this.type(src.type());
Expand Down Expand Up @@ -740,7 +703,6 @@ export class Field {
return {
name:field.displayText(),
value:Field.stringAsType(field.value(), field.type()),
defaultValue:field.defaultValue(),
description:field.description(),
readonly:field.readonly(),
type:field.isEvent() ? "Event" : field.type(),
Expand All @@ -758,7 +720,6 @@ export class Field {
return {
name:field.displayText(),
value:Field.stringAsType(field.value(), field.type()),
defaultValue:field.defaultValue(),
description:field.description(),
readonly:field.readonly(),
type:field.isEvent() ? "Event" : field.type(),
Expand All @@ -780,7 +741,6 @@ export class Field {
let readonly: boolean = false;
let type: Daliuge.DataType = Daliuge.DataType.Unknown;
let value: string = "";
let defaultValue: string = "";
let precious: boolean = false;
let options: string[] = [];
let positional: boolean = false;
Expand Down Expand Up @@ -809,8 +769,6 @@ export class Field {
}
if (typeof data.value !== 'undefined' && data.value !== null)
value = data.value.toString();
if (typeof data.defaultValue !== 'undefined' && data.defaultValue !== null)
defaultValue = data.defaultValue.toString();
if (typeof data.precious !== 'undefined')
precious = data.precious;
if (typeof data.options !== 'undefined')
Expand Down Expand Up @@ -858,7 +816,7 @@ export class Field {
isEvent = data.event;
if (typeof data.encoding !== 'undefined')
encoding = data.encoding;
const result = new Field(id, name, value, defaultValue, description, readonly, type, precious, options, positional, parameterType, usage);
const result = new Field(id, name, value, description, readonly, type, precious, options, positional, parameterType, usage);
result.isEvent(isEvent);
result.encoding(encoding);
return result;
Expand Down Expand Up @@ -887,7 +845,7 @@ export class Field {
name = data.IdText;
}

const f = new Field(data.Id, name, "", "", description, false, type, false, [], false, Daliuge.FieldType.Unknown, Daliuge.FieldUsage.NoPort);
const f = new Field(data.Id, name, "", description, false, type, false, [], false, Daliuge.FieldType.Unknown, Daliuge.FieldUsage.NoPort);
f.isEvent(event);
f.encoding(encoding);
return f;
Expand All @@ -897,7 +855,6 @@ export class Field {
let id: FieldId;
let name: string;
let value: string;
let defaultValue: string;
let description: string;
let readonly: boolean;
let type: Daliuge.DataType;
Expand All @@ -916,8 +873,6 @@ export class Field {
name = data.name;
if (typeof data.value !== 'undefined')
value = data.value.toString();
if (typeof data.defaultValue !== 'undefined')
defaultValue = data.defaultValue.toString();
if (typeof data.description !== 'undefined')
description = data.description;
if (typeof data.readonly !== 'undefined')
Expand All @@ -940,7 +895,7 @@ export class Field {
if (typeof data.encoding !== 'undefined')
encoding = data.encoding;

const f = new Field(id, name, value, defaultValue, description, readonly, type, precious, options, positional, parameterType, usage);
const f = new Field(id, name, value, description, readonly, type, precious, options, positional, parameterType, usage);
f.isEvent(event);
f.encoding(encoding);
return f;
Expand Down
Loading