Skip to content

Commit

Permalink
Add QuantME4VAR constructs and fix deployment model issues (#46)
Browse files Browse the repository at this point in the history
* integrate new quantme constructs

* use label to make entries in selectbox visible

* update objectiveFunctionEntry

* fix replacement error for circuitcuttingsubprocess

* fix transformation for elements with connector

* Enable config of Github token via env vars

* Fix getter and validater of deployment model

---------

Co-authored-by: LaviniaStiliadou <livia_16@live.de>
Co-authored-by: Martin Beisel <beiselmn@gmail.com>
  • Loading branch information
3 people authored May 19, 2023
1 parent e52b7f1 commit e0a437a
Show file tree
Hide file tree
Showing 20 changed files with 2,101 additions and 865 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -594,44 +594,20 @@ export function setDocumentation(element, newDocumentation, bpmnFactory) {
* @returns {{extensionElements: elementType}} The updated extension elements
*/
export function addEntry(businessObject, element, entry, bpmnFactory) {
const commands = [];

let extensionElements = businessObject.get('extensionElements');

// if there is no extensionElements list, create one
if (!extensionElements) {

extensionElements = createElement('bpmn:ExtensionElements', {values: [entry]}, businessObject, bpmnFactory);

commands.push({
cmd: 'element.updateModdleProperties',
context: {
element,
moddleElement: businessObject,
properties: {
extensionElements
}
}
});

return {extensionElements: extensionElements};
}
entry.$parent = extensionElements;

// (2) add extension element to list
commands.push({
cmd: 'element.updateModdleProperties',
context: {
element,
moddleElement: extensionElements,
properties: {
values: [...extensionElements.get('values'), entry]
}
}
});

const commandStack = useService('commandStack');
commandStack.execute('properties-panel.multi-command-executor', commands);
// add extension element to list if it exists
entry.$parent = extensionElements;
let values = extensionElements.get('values');
values.push(entry);
extensionElements.set('values', values);
return {extensionElements: extensionElements};
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,31 @@ export function setQRMUserName(userName) {
}
}

/**
* Get the GitHub token used to access the QRM repository
*
* @return {string} the specified username
*/
export function getGithubToken() {
if (config.githubToken === undefined) {
setGithubToken(
getPluginConfig('quantme').githubToken
|| defaultConfig.githubToken);
}
return config.githubToken;
}

/**
* Set the GitHub token used to access the QRM repository
*
* @param githubToken the username
*/
export function setGithubToken(githubToken) {
if (githubToken !== null && githubToken !== undefined) {
config.githubToken = githubToken;
}
}

/**
* Get the endpoint of the Qiskit Runtime Handler
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const defaultConfig = {
githubRepositoryName: process.env.QRM_REPONAME,
githubUsername: process.env.QRM_USERNAME,
githubRepositoryPath: process.env.QRM_REPOPATH,
githubToken: process.env.GITHUB_TOKEN,
hybridRuntimeProvenance: process.env.PROVENANCE_COLLECTION
};
export default defaultConfig;
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@
*/

import BpmnFactory from 'bpmn-js/lib/features/modeling/BpmnFactory';
import {isQuantMETask} from '../utilities/Utilities';
import {READOUT_ERROR_MITIGATION_TASK} from '../Constants';
import { isQuantMETask } from '../utilities/Utilities';
import {
CIRCUIT_CUTTING_SUBPROCESS,
PARAMETER_OPTIMIZATION_TASK,
READOUT_ERROR_MITIGATION_TASK,
RESULT_EVALUATION_TASK,
VARIATIONAL_QUANTUM_ALGORITHM_TASK,
WARM_STARTING_TASK
} from '../Constants';

/**
* This class implements functionality when creating shapes representing QuantME tasks
Expand Down Expand Up @@ -40,7 +47,31 @@ export default class QuantMEFactory extends BpmnFactory {
element.mitigationMethod = 'matrixInversion';
element.calibrationMethod = 'fullMatrix';
}

if (element.$type === CIRCUIT_CUTTING_SUBPROCESS) {
element.cuttingMethod = 'qiskit';
}

if (element.$type === WARM_STARTING_TASK) {
element.warmStartingMethod = 'initialStateWarmStartEgger';
}

if (element.$type === PARAMETER_OPTIMIZATION_TASK) {
element.optimizer = 'cobyla';
}

if (element.$type === RESULT_EVALUATION_TASK) {
element.objectiveFunction = 'expectationValue';
}

if (element.$type === VARIATIONAL_QUANTUM_ALGORITHM_TASK) {
element.objectiveFunction = 'expectationValue';
element.optimizer = 'cobyla';
element.mitigationMethod = '';
element.cuttingMethod = '';
element.warmStartingMethod = '';
}
}
}

QuantMEFactory.$inject = ['moddle'];
QuantMEFactory.$inject = ['moddle'];
Loading

0 comments on commit e0a437a

Please sign in to comment.