Scripting issues "Creation of Capabilities" ,"Creation of Operational Activities"

Hello everyone,
While using Python4Capella I had a common problem while creating of some elements such as Operational Capabilities,Capabilities,Operational Activities.As an example the console error for operational capability creation is as the following:

java.lang.ArrayStoreException: org.polarsys.capella.core.data.oa.impl.OperationalCapabilityImpl
at org.eclipse.emf.common.util.BasicEList.assign(BasicEList.java:118)
at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:417)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.doAddUnique(NotifyingListImpl.java:325)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:282)
at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:304)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
at py4j.Gateway.invoke(Gateway.java:282)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.ClientServerConnection.sendCommand(ClientServerConnection.java:244)
at py4j.CallbackClient.sendCommand(CallbackClient.java:384)
at py4j.CallbackClient.sendCommand(CallbackClient.java:356)
at py4j.reflection.PythonProxyHandler.invoke(PythonProxyHandler.java:106)
at com.sun.proxy.$Proxy25.executeScript(Unknown Source)
at org.eclipse.ease.lang.python.py4j.internal.Py4jScriptEngine.internalExecute(Py4jScriptEngine.java:236)
at org.eclipse.ease.lang.python.py4j.internal.Py4jScriptEngine.execute(Py4jScriptEngine.java:226)
at org.eclipse.ease.AbstractScriptEngine.inject(AbstractScriptEngine.java:245)
at org.eclipse.ease.AbstractScriptEngine.run(AbstractScriptEngine.java:309)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

Thanks.

What is the Python code that generate this Java exception ?

Hello @YvanLussaud thanks for your response, in my python code I am creating Operational Capabilities and assigning them names using a defined list. The code is below:

OpCap = [" have videophone", " receive a message when my home care nurse is on her way", “be able to zoom into visual content”," decide who has access to my vital data"]

include needed for the Capella modeller API

include(‘workspace://Python4Capella/simplified_api/capella.py’)
if False:
from simplified_api.capella import *

change this path to execute the script on your model (here is the IFE sample).

comment it if you want to use the “Run configuration” instead

aird_path = ‘/My_1stProject/My_1stProject.aird’

model = CapellaModel()
model.open(aird_path)

gets the SystemEngineering and print its name

se = model.get_system_engineering()
print(“Model opened:” + se.get_name())

get the OperationalCapabilityPackage

ocap_pkg = se.get_operational_analysis().get_operational_capability_pkg()

start a transaction to modify the Capella model

model.start_transaction()
try:
# create operational capability with the list of names in the pre-defined list
for c in OpCap:
# create a Operational Capability
ocap=OperationalCapability()
ocap.set_name© #set its name
ocap_pkg.get_owned_operational_capability_pkgs().add(ocap)
except:
# if something went wrong we rollback the transaction
model.rollback_transaction()
raise
else:
# if everything is ok we commit the transaction
model.commit_transaction()

save the Capella model

model.save()

Thanks.

This should be:

ocap_pkg.get_owned_operational_capabilities().add(ocap)
1 Like

Hello Yvan
I’m in this thread looking for " ‘include’ is not defined

This is my very first experience in python and my purpose is to prepare scripts to export all needed data for excel model analysis. Then my first try was to adapt sample “export_capabilities_and_owned_scenarios_to_xlsx”
On line 21 and 27 it says include(workspace:[path]), then I have put the path to my workspace where are both my capella project and my python4capella project
And on line 35: it says aird_path=[path/name.aird] which I replaced with my capella project path/aird file.
To be honest I did not understand clearly the discussion content and the link to the error I want to solve but as this thread appeared

Thanks for any help
Thierry Poupon

The include() instruction is not a Python instruction, it comes from EASE. This instruction is not recognized by the PyDev environment. You can find more explanation about this here.

You will need to run the script in the EASE context see the documentation here and for the run part here (make sure you followed the write script documentation first).

Tanks
Running as EASE gives another response:
"org.eclipse.ease.ScriptExecutionException: TypeError: required field “type_ignores” missing from Module

org.eclipse.ease.ScriptExecutionException: TypeError: required field “type_ignores” missing from Module

org.eclipse.ease.ScriptExecutionException: TypeError: required field “type_ignores” missing from Module"

I have three lines of same text as you can see
 What is “type_ignores”?
Thanks for your help

Thierry Poupon

I didn’t experienced this error but someone else did see this discution.

I did read there, and found elsewhere information about validation and it was saying 5.0.0 was KO

I’m running Capella 5.2 and EASE 1.0.1. My python engine is 3.7 (update back after trying 3.8: if was written somewhere that 3.8 was not compatible until massive EASE update was done
 I hope Windows could go back to 3.7, but to be honest I don’t know where to figure out, it was installed by IT dept tool, on my requests
 Everything is in folder Anaconda3.).
If anyone knows about compatibility versions, let me know

The versions provided by Pyhton4Cappella are the following:

  • Capella 1.4.x or 5.x (version 6.x should work but need to be tested)
  • EASE 0.7.0 (but you can upgrade to 0.8.0 version after that should be tested)
  • Python 3.7.x (EASE 0.8.0 and lower have a known issue with newer versions of Python)
    • see #119 (which is your issue
 I missed that earlier)
  • problem with numpy see #112

Thanks, still not checked: it seems that I had both version on my PC
 Just ask to remove 3.8 now. done during next night I suppose

Regards
Thierry