Skip to content

Commit

Permalink
WIP- #131: Complete Integration Test for JSON Imports(Only works for …
Browse files Browse the repository at this point in the history
…models without dropout layers)
  • Loading branch information
umesh-timalsina committed Nov 7, 2019
1 parent 6c257ce commit 1cd436a
Showing 1 changed file with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/*globals requireJS*/
/*eslint-env node, mocha*/
'use strict';

Expand All @@ -11,7 +10,6 @@ describe('Imported JSON to Code', function () {
assert = require('assert'),
gmeConfig = testFixture.getGmeConfig(),
executePython = testFixture.executePython,
expect = testFixture.expect,
path = testFixture.path,
logger = testFixture.logger.fork('ImportedArchitectureToCode'),
PluginCliManager = testFixture.WebGME.PluginCliManager,
Expand Down Expand Up @@ -65,9 +63,11 @@ describe('Imported JSON to Code', function () {
await gmeAuth.unload();
});

const modelsToTest = fs.readdirSync(JSON_DIR).filter((targetFile) => {
return targetFile.endsWith('.json');
});
// let modelsToTest = fs.readdirSync(JSON_DIR).filter((targetFile) => {
// return targetFile.endsWith('.json');
// });

let modelsToTest = ['sequential_dense.json'];

modelsToTest.forEach((modelJSON) => {
describe(`Import JSON and generate Code For ${modelJSON}`, function () {
Expand All @@ -77,9 +77,9 @@ describe('Imported JSON to Code', function () {
});

it(`should run the python code generated for ${modelJSON}`, () => {
let execResult = executePython(generatedCode);
// assert(execResult.success);
})
let execResult = executePython(generatedCode);
assert(execResult.success);
}).timeout(5000);
})
});

Expand All @@ -92,27 +92,22 @@ describe('Imported JSON to Code', function () {
project: project,
activeNode: '',
branchName: 'test',
commitHash: commitHash,
namespace: ''
};
let data = fs.readFileSync(path.join(JSON_DIR, fileName), 'utf-8');

assert(data !== null);
pluginConfig.srcModel = await blobClient.putFile(fileName, data);
let importJSONPluginResult = await executePlugin(ImportPluginName, pluginConfig, context);

assert(importJSONPluginResult.success);
await executePlugin(ImportPluginName, pluginConfig, context);

let newBranchHash = await project.getBranchHash('test');
commitHash = newBranchHash;
let newCommitObj = await awaitableLoadObject(newBranchHash);

let newRootNode = await importPlugin.core.loadRoot(newCommitObj.root);
const addedArchitectureNode = (await importPlugin.core.loadChildren(newRootNode)).filter((node) => {
return importPlugin.core.getAttribute(node, 'name') === fileName.replace('.json', '');
return importPlugin.core.getAttribute(node, 'name') === fileName.replace('.json', '');
})[0];
assert(addedArchitectureNode);

assert(importPlugin.core.getBase(addedArchitectureNode), importPlugin.META['Architecuture']);

context = {
project: project,
Expand All @@ -121,9 +116,11 @@ describe('Imported JSON to Code', function () {
activeNode: importPlugin.core.getPath(addedArchitectureNode),
namespace: ''
};
// pluginConfig = {};
//
// let generateCodePluginResult = await executePlugin(CodeGenerationPluginName, pluginConfig, context);
// assert(generateCodePluginResult.success)
pluginConfig = {};
let generateCodePluginResult = await executePlugin(CodeGenerationPluginName, pluginConfig, context);
assert(generateCodePluginResult.success);
const codeHash = generateCodePluginResult.artifacts[0];
const codeObj = await blobClient.getObject(codeHash);
return String.fromCharCode.apply(null, new Uint8Array(codeObj));
};
});

0 comments on commit 1cd436a

Please sign in to comment.