Skip to content

Commit

Permalink
Adjust fields submitted for pipeline.json, as part of #751.
Browse files Browse the repository at this point in the history
  • Loading branch information
donkirkby committed Jan 31, 2019
1 parent 29e33b0 commit 827ced7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
16 changes: 7 additions & 9 deletions kive/container/static/container/io/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ function serializeInputs(pipeline_inputs: (CdtNode|RawNode)[], canvas_dimensions

// Slap this input into the form data
serialized_inputs[i] = {
structure: structure,
dataset_name: input.label,
dataset_idx: i + 1,
x: input.x / x_ratio,
y: input.y / y_ratio
};
Expand All @@ -100,7 +98,6 @@ function serializeSteps(pipeline_steps: MethodNode[], canvas_dimensions: [ numbe

// Add arguments for input cabling
for (let i = 0; i < pipeline_steps.length; i++) {
// TODO: Make this work for nested pipelines

let step = pipeline_steps[i];

Expand All @@ -118,7 +115,9 @@ function serializeSteps(pipeline_steps: MethodNode[], canvas_dimensions: [ numbe
}

// retrieve Connectors
serialized_steps[i].cables_in = serializeInMagnets(step.in_magnets, pipeline_steps);
serialized_steps[i].inputs = serializeInMagnets(step.in_magnets, pipeline_steps);
serialized_steps[i].outputs = step.out_magnets.map(
magnet => magnet.label);
}

return serialized_steps;
Expand All @@ -140,11 +139,10 @@ function serializeInMagnets(in_magnets: Magnet[], pipeline_steps: MethodNode[]):

serialized_cables[j] = {
source_dataset_name: connector.source.label,
dest_dataset_name: connector.dest.label,
source_step: CanvasState.isMethodNode(source) ? pipeline_steps.indexOf(source) + 1 : 0,
keep_output: false, // in the future this can be more flexible
custom_wires: [] // no wires for a raw cable
};
dataset_name: connector.dest.label,
source_step: CanvasState.isMethodNode(source)
? pipeline_steps.indexOf(source) + 1
: 0};
}

return serialized_cables;
Expand Down
28 changes: 23 additions & 5 deletions kive/container/tests/pipeline_functions.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,16 @@ describe("Container pipeline functions", function() {
});

it('should match original pipeline steps', function() {
var self = this,
let self = this,
serialized = loadAndSerialize(
this.canvasState,
this.api_pipeline
);

expect(serialized.pipeline.steps.length).toBe(
self.api_pipeline.pipeline.steps.length);
$.each(serialized.pipeline.steps, function(index, ser_step){
var api_step = self.api_pipeline.pipeline.steps[index];
let api_step = self.api_pipeline.pipeline.steps[index];

expect(ser_step.driver).toBe(api_step.driver);
expect(ser_step.x).toBeCloseTo(api_step.x, 8);
Expand All @@ -321,24 +323,40 @@ describe("Container pipeline functions", function() {
});

it('should match original pipeline steps (cables_in)', function() {
var self = this,
let self = this,
serialized = loadAndSerialize(
this.canvasState,
this.api_pipeline
);

$.each(serialized.pipeline.steps, function(index, ser_step){
var api_step = self.api_pipeline.pipeline.steps[index];
let api_step = self.api_pipeline.pipeline.steps[index];

expect(ser_step.inputs.length).toBe(api_step.inputs.length);
$.each(ser_step.inputs, function(cable_index, ser_cable){
var api_cable = api_step.inputs[cable_index];
let api_cable = api_step.inputs[cable_index];

expect(ser_cable.dataset_name).toBe(api_cable.dataset_name);
expect(ser_cable.source_step).toBe(api_cable.source_step);
expect(ser_cable.source_dataset_name).toBe(api_cable.source_dataset_name);
});
});
});

it('should match original pipeline steps (cables_out)', function() {
let self = this,
serialized = loadAndSerialize(
this.canvasState,
this.api_pipeline
);

$.each(serialized.pipeline.steps, function(index, ser_step){
let api_step = self.api_pipeline.pipeline.steps[index];

expect(ser_step.outputs).toEqual(api_step.outputs);
});
});

it('should match original pipeline output', function() {
let self = this,
serialized = loadAndSerialize(
Expand Down
14 changes: 0 additions & 14 deletions kive/container/tests/pipeline_submit.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,6 @@ describe("Container Pipeline Submit class", function() {
expect(requestData.pipeline.outputs[0].dataset_name).toEqual("output_node");
});

it('should handle API errors for pipeline family', function() {
built_submit(new Event('submit'));

jasmine.Ajax.requests.mostRecent().respondWith({
status: 500,
statusText: 'HTTP/1.1 500 Internal Server Error',
contentType: 'application/json;charset=UTF-8',
responseText: "{ \"non_field_errors\": [ \"custom error message\" ] }"
});

expect($error).toContainText("custom error message");
expect($error).toBeVisible();
});

it('should handle API errors for pipeline revision', function() {
built_submit(new Event('submit'));

Expand Down

0 comments on commit 827ced7

Please sign in to comment.