Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -98,44 +98,7 @@ qx.Class.define("osparc.study.CreateFunction", {
column = 0;
row++;

const filePickers = osparc.study.Utils.extractFilePickers(this.__studyData["workbench"]);
filePickers.forEach(filePicker => {
const fpLabel = new qx.ui.basic.Label(filePicker["label"]);
inputsLayout.add(fpLabel, {
row,
column,
});
column++;

const fpType = new qx.ui.basic.Label("FileID");
inputsLayout.add(fpType, {
row,
column,
});
column++;

const fpExposed = new qx.ui.form.CheckBox().set({ value: true });
inputsLayout.add(fpExposed, {
row,
column,
});
exposedInputs[filePicker["label"]] = true;
fpExposed.addListener("changeValue", e => exposedInputs[filePicker["label"]] = e.getData());
column++;

const outputValue = osparc.file.FilePicker.getOutput(filePicker);
const fpDefaultValue = new qx.ui.basic.Label(outputValue && outputValue["path"] ? outputValue["path"] : "");
inputsLayout.add(fpDefaultValue, {
row,
column,
});
column++;

column = 0;
row++;
});

const parameters = osparc.study.Utils.extractParameters(this.__studyData["workbench"]);
const parameters = osparc.study.Utils.extractFunctionableParameters(this.__studyData["workbench"]);
parameters.forEach(parameter => {
const parameterLabel = new qx.ui.basic.Label(parameter["label"]);
inputsLayout.add(parameterLabel, {
Expand Down Expand Up @@ -208,7 +171,7 @@ qx.Class.define("osparc.study.CreateFunction", {
column = 0;
row++;

const probes = osparc.study.Utils.extractProbes(this.__studyData["workbench"]);
const probes = osparc.study.Utils.extractFunctionableProbes(this.__studyData["workbench"]);
probes.forEach(probe => {
const parameterLabel = new qx.ui.basic.Label(probe["label"]);
outputsLayout.add(parameterLabel, {
Expand Down Expand Up @@ -305,19 +268,7 @@ qx.Class.define("osparc.study.CreateFunction", {
"default_inputs": {},
};

const filePickers = osparc.study.Utils.extractFilePickers(templateData["workbench"]);
filePickers.forEach(filePicker => {
const fpLabel = filePicker["label"];
if (exposedInputs[fpLabel]) {
functionData["input_schema"]["schema_dict"]["properties"][fpLabel] = {
"type": "FileID",
};
const outputValue = osparc.file.FilePicker.getOutput(filePicker);
functionData["default_inputs"][fpLabel] = outputValue && outputValue["path"] ? outputValue["path"] : null;
}
});

const parameters = osparc.study.Utils.extractParameters(templateData["workbench"]);
const parameters = osparc.study.Utils.extractFunctionableParameters(templateData["workbench"]);
parameters.forEach(parameter => {
const parameterLabel = parameter["label"];
if (exposedInputs[parameterLabel]) {
Expand All @@ -331,7 +282,7 @@ qx.Class.define("osparc.study.CreateFunction", {
}
});

const probes = osparc.study.Utils.extractProbes(templateData["workbench"]);
const probes = osparc.study.Utils.extractFunctionableProbes(templateData["workbench"]);
probes.forEach(probe => {
const probeLabel = probe["label"];
if (exposedOutputs[probeLabel]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,24 @@ qx.Class.define("osparc.study.Utils", {
},

extractParameters: function(workbench) {
const parameters = Object.values(workbench).filter(srv => srv["key"].includes("simcore/services/frontend/parameter/"));
const parameters = Object.values(workbench).filter(srv => osparc.data.model.Node.isParameter(srv));
return parameters;
},

extractFunctionableParameters: function(workbench) {
// - for now, only float types are allowed
const parameters = Object.values(workbench).filter(srv => osparc.data.model.Node.isParameter(srv) && srv["key"].includes("parameter/float"));
return parameters;
},

extractProbes: function(workbench) {
const parameters = Object.values(workbench).filter(srv => srv["key"].includes("simcore/services/frontend/iterator-consumer/probe/"));
const parameters = Object.values(workbench).filter(srv => osparc.data.model.Node.isProbe(srv));
return parameters;
},

extractFunctionableProbes: function(workbench) {
// - for now, only float types are allowed
const parameters = Object.values(workbench).filter(srv => osparc.data.model.Node.isProbe(srv) && srv["key"].includes("probe/float"));
return parameters;
},

Expand All @@ -253,10 +265,16 @@ qx.Class.define("osparc.study.Utils", {
// in order to create a function, the pipeline needs:
// - at least one parameter (or file-picker (file type parameter))
// - at least one probe
const filePickers = osparc.study.Utils.extractFilePickers(workbench);
const parameters = osparc.study.Utils.extractParameters(workbench);
const probes = osparc.study.Utils.extractProbes(workbench);
return (filePickers.length + parameters.length) && probes.length;

// const filePickers = osparc.study.Utils.extractFilePickers(workbench);
// const parameters = osparc.study.Utils.extractParameters(workbench);
// const probes = osparc.study.Utils.extractProbes(workbench);
// return (filePickers.length + parameters.length) && probes.length;

// - for now, only float types are allowed
const parameters = osparc.study.Utils.extractFunctionableParameters(workbench);
const probes = osparc.study.Utils.extractFunctionableProbes(workbench);
return parameters.length && probes.length;
},

getCantExecuteServices: function(studyServices = []) {
Expand Down
Loading