Skip to content

Commit

Permalink
fix for runtime pattern combination
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeisel committed Jul 31, 2024
1 parent f8df392 commit c54a479
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import fetch from "node-fetch";
import getHardwareSelectionForm from "../../extensions/quantme/replacement/hardware-selection/HardwareSelectionForm";
import JSZip from "jszip";
import NotificationHandler from "../ui/notifications/NotificationHandler";
import {checkEnabledStatus, getActivePlugins} from "../plugin/PluginHandler";
import { getActivePlugins } from "../plugin/PluginHandler";
import { getServiceTasksToDeploy } from "../../extensions/opentosca/deployment/DeploymentUtils";
import { getRootProcess } from "./ModellingUtilities";
import { getWineryEndpoint } from "../../extensions/opentosca/framework-config/config-manager";
Expand Down Expand Up @@ -618,7 +618,7 @@ export async function saveQAA(
let openToscaActive = false;
for (let plugin of getActivePlugins()) {
console.log(plugin.name);
if (plugin.name === pluginNames.OPENTOSCA){
if (plugin.name === pluginNames.OPENTOSCA) {
openToscaActive = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ export async function startPatternReplacementProcess(xml) {
);
console.log("Begin of measurement of step F: ");
startTime = Date.now();
let optimizationCandidates = [];
if (behaviorReplacementConstructs.length !== 0 ) {
let optimizationCandidates = [];
if (behaviorReplacementConstructs.length !== 0) {
optimizationCandidates = await findOptimizationCandidates(modeler);
}

Expand Down Expand Up @@ -296,7 +296,7 @@ export async function startPatternReplacementProcess(xml) {
}
replacementSuccess = true;
optimizationCandidates = await findOptimizationCandidates(modeler);
console.log("optimization candidates: ", optimizationCandidates)
console.log("optimization candidates: ", optimizationCandidates);
}
if (replacementConstruct.task.$type === constants.PRE_DEPLOYED_EXECUTION) {
console.log("Replace pre-deployed execution");
Expand Down Expand Up @@ -449,14 +449,14 @@ export async function startPatternReplacementProcess(xml) {

// remove duplicate patterns from elementsToDelete
let elementsToDeleteNoDuplicates = [];
for (let i = 0; i < elementsToDelete.length; i++){
for (let i = 0; i < elementsToDelete.length; i++) {
let contains = false;
for (let j = 0; j < elementsToDeleteNoDuplicates.length; j++){
if (elementsToDeleteNoDuplicates[j].id === elementsToDelete[i].id ) {
for (let j = 0; j < elementsToDeleteNoDuplicates.length; j++) {
if (elementsToDeleteNoDuplicates[j].id === elementsToDelete[i].id) {
contains = true;
}
}
if (!contains && elementsToDelete[i].parent !== null){
if (!contains && elementsToDelete[i].parent !== null) {
elementsToDeleteNoDuplicates.push(elementsToDelete[i]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import NotificationHandler from "../../../../editor/ui/notifications/Notificatio
import { findSplittingCandidates } from "../../../quantme/ui/splitting/CandidateDetector";
import { rewriteWorkflow } from "../../../quantme/ui/splitting/WorkflowRewriter";
import { invokeScriptSplitter } from "../../../quantme/ui/splitting/splitter/ScriptSplitterHandler";
import {generateQrms, handleQrmUpload} from "../../../quantme/utilities/Utilities";
import { uploadMultipleToGitHub } from "../../../quantme/qrm-manager/git-handler";
import { handleQrmUpload } from "../../../quantme/utilities/Utilities";

const defaultState = {
patternOverviewOpen: false,
Expand Down Expand Up @@ -221,7 +220,6 @@ export default class PatternSelectionPlugin extends PureComponent {
qrmsActivities = result.qrmActivities;
if (qrmsActivities.length > 0) {
handleQrmUpload(qrmsActivities, this.modeler);

}
} else {
let collapsedSubprocessStartEvent = elementFactory.createShape({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,11 @@ export async function startQuantmeReplacementProcess(
console.log("Searching for splitting candidates after transformation");
const splittingCandidates = await findSplittingCandidates(modeler);
if (splittingCandidates.length > 0) {
console.log("Found {} splitting candidates after transformation", splittingCandidates.length);
console.log(splittingCandidates)
console.log(
"Found {} splitting candidates after transformation",
splittingCandidates.length
);
console.log(splittingCandidates);
let qrmActivities = [];
for (let i = 0; i < splittingCandidates.length; i++) {
let programGenerationResult = await invokeScriptSplitter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ export default class AdaptationPlugin extends PureComponent {
const rewriteStartDate = Date.now();

let rewriteCandidate = result.candidates[result.rewriteCandidateId];
let programGenerationResult = await this.invokeScriptSplitterForCandidate(rewriteCandidate, result.scriptSplitterName );
let programGenerationResult = await this.invokeScriptSplitterForCandidate(
rewriteCandidate,
result.scriptSplitterName
);

// check if hybrid program generation was successful
if (programGenerationResult.error) {
Expand Down Expand Up @@ -218,23 +221,22 @@ export default class AdaptationPlugin extends PureComponent {
this.setState({ rewriteOpen: false });
}


async invokeScriptSplitterForCandidate(rewriteCandidate, scriptSplitterName){
async invokeScriptSplitterForCandidate(rewriteCandidate, scriptSplitterName) {
let programGenerationResult;
switch (scriptSplitterName) {
case "Script Splitter":
console.log("Invoke script splitter");
programGenerationResult = await invokeScriptSplitter(
rewriteCandidate,
config,
getQRMs()
rewriteCandidate,
config,
getQRMs()
);
break;
default:
programGenerationResult = {
error:
"Unable to find suitable script splitter for: " +
scriptSplitterName,
"Unable to find suitable script splitter for: " +
scriptSplitterName,
};
}
return programGenerationResult;
Expand Down Expand Up @@ -268,4 +270,3 @@ export default class AdaptationPlugin extends PureComponent {
);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ export async function rewriteWorkflow(
isExpanded: true,
});

modeling.createShape(
collapsedSubprocess,
{ x: 50, y: 50 },
parent
);
modeling.createShape(collapsedSubprocess, { x: 50, y: 50 }, parent);

let copyResult = copyElementsToParent(
tempRootElement,
Expand All @@ -97,7 +93,7 @@ export async function rewriteWorkflow(
modeling,
elementRegistry,
collapsedSubprocess,
elementFactory
elementFactory
);

modeling.removeShape(element);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,6 @@ export async function handleQrmUpload(qrmsActivities, modeler) {
console.log("Iteration {}", tries);
await new Promise((r) => setTimeout(r, 8000));
await updateQRMs();
tries ++;
tries++;
}
}

0 comments on commit c54a479

Please sign in to comment.