labs4capella / python4capella

Python for Capella
Eclipse Public License 2.0
53 stars 10 forks source link

py4j.Py4JException: Method getDeployingNodePC([]) does not exist #105

Closed mtu95 closed 2 years ago

mtu95 commented 2 years ago

Hello, I got the follow message when I try to apply the method getDeployingNodePC() to behaviorPC. Could you please check it ? py4j.Py4JException: Method getDeployingNodePC([]) does not exist

Context: Get the deploying node PC from the 'deployed behavior PC' in physical architecture.

if isinstance(elem, BehaviorPC): n_target = elem.get_deploying_node_p_c()

Is it a bug or am I applying it incorrectly ? Besides, in which file can i find this method ?

Thanks in advance.

ylussaud commented 2 years ago

Not all methods are working at the moment. you can check the status in the Word document attached to the release. In the next release you will be able to check the status directly in the documentation of the method. The method you are looking for is in the capella.py file. In the PyDev editor you can CRTL+Click on the method call to nativage to its definition.

mtu95 commented 2 years ago

Thank you, I can't wait for the next release! According to word document, the method i'm looking for is not implemented yet. I did not understand one thing: even we have the method 'get_deploying_node_p_c()' in the class Behavior PC that uses 'getDeployingNodePC' method, does it not necessarily means that it is implemented ? And I've noticed that CRTL+click does not work on the methods just after self.get_java_object(). In this case 'getDeployingNodePC()' method. Can I find them in a specific file or are they not implement yet?

def get_deploying_node_p_c(self):
    value =  self.get_java_object().getDeployingNodePC()
    if value is None:
        return value
    else:
        e_object_class = getattr(sys.modules["__main__"], "EObject")
        specific_cls = e_object_class.get_class(value)
        return specific_cls(value)
ylussaud commented 2 years ago

The getDeployingNodePC() is a Java method that we can access thanks to EASE. By default we create a call with the same name between the simplified Python API and the Java Capella API. But there are some differences and this call is one of them. And yes the CTRL+Click on getDeployingNodePC() will not give you the declaration in the Java code and in this case the Java method doesn't exist.

If you plan to implement it in Python let me know. You can have a look at the capella_query_by_name or the capella_query calls to access data shown in the Capella semantic browser.

mtu95 commented 2 years ago

Hello @ylussaud, I've implemented the getDeployingNodePC method and it's working! I used the capella_query_by_name. Thank you