Version: 9.16.0
YACS::ENGINE::PythonNode Class Reference

#include <PythonNode.hxx>

Inheritance diagram for YACS::ENGINE::PythonNode:
Collaboration diagram for YACS::ENGINE::PythonNode:

Public Member Functions

 PythonNode (const PythonNode &other, ComposedNode *father)
 
 PythonNode (const std::string &name)
 
virtual ~PythonNode ()
 
virtual void checkBasicConsistency () const
 
virtual void execute ()
 
virtual void load ()
 
virtual void loadRemote ()
 
virtual void loadLocal ()
 
virtual void executeRemote ()
 
virtual void executeLocal ()
 
virtual void shutdown (int level)
 Stop all pending activities of the node. More...
 
void imposeResource (const std::string &resource_name, const std::string &container_name) override
 
bool canAcceptImposedResource () override
 
bool hasImposedResource () const override
 
bool isUsingPythonCache () const
 
std::string getContainerLog ()
 returns a string that contains the name of the container log file if it exists More...
 
PythonNodecloneNode (const std::string &name)
 Create a new node of same type with a given name. More...
 
virtual std::string typeName ()
 
void applyDPLScope (ComposedNode *gfn)
 
void setSqueezeStatusWithExceptions (bool sqStatus, const std::vector< std::string > &squeezeExceptions)
 
void setSqueezeStatus (bool sqStatus)
 
bool getSqueezeStatus () const
 
void squeezeMemorySafe ()
 
- Public Member Functions inherited from YACS::ENGINE::InlineNode
virtual void setScript (const std::string &script)
 Set the script (as a string) to execute. More...
 
virtual std::string getScript ()
 
virtual InlineNodecloneNode (const std::string &name)
 Return a new InlineNode node by making a copy of this node. More...
 
virtual void accept (Visitor *visitor)
 
virtual ~InlineNode ()
 
virtual std::string typeName ()
 
virtual void setExecutionMode (const std::string &mode)
 
virtual std::string getExecutionMode ()
 
virtual void setContainer (Container *container)
 
virtual ContainergetContainer ()
 
void performDuplicationOfPlacement (const Node &other)
 performs a duplication of placement using clone method of containers and components. clone behaviour is driven by attachOnCloning attribute. More...
 
void performShallowDuplicationOfPlacement (const Node &other)
 performs a also duplication of placement but here containers and components are not copied at all whatever the value of attachedOnCloning. More...
 
bool isDeployable () const
 
int getMaxLevelOfParallelism () const
 
- Public Member Functions inherited from YACS::ENGINE::ElementaryNode
virtual ~ElementaryNode ()
 
void exUpdateState ()
 Update the node state. More...
 
void init (bool start=true)
 
bool isDeployable () const
 
ComponentInstancegetComponent ()
 
const ComponentInstancegetComponent () const
 
ContainergetContainer ()
 
YACS::StatesForNode getState () const
 
void getReadyTasks (std::vector< Task * > &tasks)
 
void edRemovePort (Port *port)
 
std::list< ElementaryNode * > getRecursiveConstituents () const
 
std::list< ProgressWeightgetProgressWeight () const
 Get the progress weight for all elementary nodes. More...
 
NodegetChildByName (const std::string &name) const
 
virtual void checkBasicConsistency () const
 
ComposedNodegetDynClonerIfExists (const ComposedNode *levelToStop) const
 
int getNumberOfInputPorts () const
 
int getNumberOfOutputPorts () const
 
std::string getInPortName (const InPort *) const
 
std::string getOutPortName (const OutPort *) const
 
InputPortgetInputPort (const std::string &name) const
 
OutputPortgetOutputPort (const std::string &name) const
 
std::list< InputPort * > getSetOfInputPort () const
 
std::list< OutputPort * > getSetOfOutputPort () const
 
std::list< InputPort * > getLocalInputPorts () const
 
std::list< OutputPort * > getLocalOutputPorts () const
 
std::set< OutPort * > getAllOutPortsLeavingCurrentScope () const
 
std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope () const
 
virtual std::vector< std::pair< OutPort *, InPort * > > getSetOfLinksLeavingCurrentScope () const
 
virtual std::vector< std::pair< InPort *, OutPort * > > getSetOfLinksComingInCurrentScope () const
 
std::list< InputDataStreamPort * > getSetOfInputDataStreamPort () const
 
std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort () const
 
InputDataStreamPortgetInputDataStreamPort (const std::string &name) const
 
OutputDataStreamPortgetOutputDataStreamPort (const std::string &name) const
 
virtual InputPortcreateInputPort (const std::string &inputPortName, TypeCode *type)
 
virtual OutputPortcreateOutputPort (const std::string &outputPortName, TypeCode *type)
 
virtual InputDataStreamPortcreateInputDataStreamPort (const std::string &inputPortDSName, TypeCode *type)
 
virtual OutputDataStreamPortcreateOutputDataStreamPort (const std::string &outputPortDSName, TypeCode *type)
 
virtual InputPortedAddInputPort (const std::string &inputPortName, TypeCode *type)
 
virtual OutputPortedAddOutputPort (const std::string &outputPortName, TypeCode *type)
 
virtual InputDataStreamPortedAddInputDataStreamPort (const std::string &inputPortDSName, TypeCode *type)
 
virtual OutputDataStreamPortedAddOutputDataStreamPort (const std::string &outputPortDSName, TypeCode *type)
 
virtual void edOrderInputPorts (const std::list< InputPort * > &ports)
 
virtual void edOrderOutputPorts (const std::list< OutputPort * > &ports)
 
virtual std::string typeName ()
 
virtual void edUpdateState ()
 update the status of the node More...
 
virtual void ensureLoading ()
 Put this node into TOLOAD state when possible. More...
 
int getMaxLevelOfParallelism () const
 
ComplexWeightgetWeight ()
 
void setWeight (double elementaryWeight)
 
void getWeightRegardingDPL (ComplexWeight *weight)
 
void partitionRegardingDPL (const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)
 
void begin ()
 
bool isReady ()
 
void finished ()
 
void aborted ()
 
void loaded ()
 Notify this node that it is loaded. More...
 
void connected ()
 Notify this node that it is connected. More...
 
virtual std::string getErrorDetails ()
 Give a description of error when node status is ERROR. More...
 
virtual void initService ()
 
virtual void connectService ()
 
virtual void disconnectService ()
 
virtual void load ()
 
virtual void getCoupledTasks (std::set< Task * > &coupledSet)
 Calls getCoupledNodes for Task interface. More...
 
virtual void getCoupledNodes (std::set< Task * > &coupledSet)
 Put all nodes that are coupled to this node in coupledSet. More...
 
void accept (Visitor *visitor)
 
virtual void addDatastreamPortToInitMultiService (const std::string &port_name, int number)
 
- Public Member Functions inherited from YACS::ENGINE::Node
virtual ~Node ()
 
virtual void init (bool start=true)
 
virtual void shutdown (int level)
 Stop all pending activities of the node. More...
 
virtual void resetState (int level)
 Reset the node state depending on the parameter level. More...
 
Nodeclone (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
NodecloneWithoutCompAndContDeepCpy (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
void setState (YACS::StatesForNode theState)
 Sets the given state for node. More...
 
virtual YACS::StatesForNode getState () const
 
virtual YACS::StatesForNode getEffectiveState () const
 Return the node state in the context of its father. More...
 
virtual YACS::StatesForNode getEffectiveState (const Node *) const
 Return the effective state of a node in the context of this one (its father) More...
 
std::string getColorState (YACS::StatesForNode state) const
 Return the color associated to a state. More...
 
InGategetInGate ()
 
OutGategetOutGate ()
 
const std::string & getName () const
 
void setName (const std::string &name)
 Change the name of the node. More...
 
ComposedNodegetFather () const
 
const std::string getId () const
 
bool exIsControlReady () const
 
std::list< Node * > getOutNodes () const
 
virtual void writeDot (std::ostream &os) const
 Dump to the input stream a dot representation of the node. More...
 
void writeDotInFile (const std::string &fileName) const
 
virtual void exUpdateState ()
 Update the node state. More...
 
virtual void exFailedState ()
 Notify this node that its execution has failed. More...
 
virtual void exDisabledState ()
 Notify this node that it has been disabled. More...
 
virtual void getReadyTasks (std::vector< Task * > &tasks)=0
 
virtual std::list< ElementaryNode * > getRecursiveConstituents () const =0
 
virtual std::list< ProgressWeightgetProgressWeight () const =0
 
virtual int getNumberOfInputPorts () const =0
 
virtual int getNumberOfOutputPorts () const =0
 
std::list< InPort * > getSetOfInPort () const
 
std::list< OutPort * > getSetOfOutPort () const
 
virtual std::list< InputPort * > getSetOfInputPort () const =0
 
virtual std::list< OutputPort * > getSetOfOutputPort () const =0
 
virtual std::list< InputPort * > getLocalInputPorts () const =0
 
virtual std::list< OutputPort * > getLocalOutputPorts () const =0
 
virtual std::set< InputPort * > edGetSetOfUnitializedInputPort () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
virtual bool edAreAllInputPortInitialized () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
virtual std::string getInPortName (const InPort *) const =0
 
virtual std::string getOutPortName (const OutPort *) const =0
 
virtual std::list< InputDataStreamPort * > getSetOfInputDataStreamPort () const =0
 
virtual std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort () const =0
 
InPortgetInPort (const std::string &name) const
 
InPropertyPortgetInPropertyPort () const
 
virtual OutPortgetOutPort (const std::string &name) const
 
virtual std::set< OutPort * > getAllOutPortsLeavingCurrentScope () const =0
 
virtual std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope () const =0
 
virtual std::vector< std::pair< OutPort *, InPort * > > getSetOfLinksLeavingCurrentScope () const =0
 
virtual std::vector< std::pair< InPort *, OutPort * > > getSetOfLinksComingInCurrentScope () const =0
 
virtual InputPortgetInputPort (const std::string &name) const
 
virtual OutputPortgetOutputPort (const std::string &name) const =0
 
virtual InputDataStreamPortgetInputDataStreamPort (const std::string &name) const =0
 
virtual OutputDataStreamPortgetOutputDataStreamPort (const std::string &name) const =0
 
std::list< ComposedNode * > getAllAscendanceOf (ComposedNode *levelToStop=0) const
 
bool operator> (const Node &other) const
 
bool operator< (const Node &other) const
 
std::string getImplementation () const
 
DynParaLoopgetClosestDPLAmongAncestors () const
 
virtual ComposedNodegetRootNode () const
 
virtual void setProperty (const std::string &name, const std::string &value)
 
virtual std::string getProperty (const std::string &name)
 
std::map< std::string, std::string > getProperties ()
 
std::map< std::string, std::string > getPropertyMap ()
 
virtual void setProperties (std::map< std::string, std::string > properties)
 
virtual NodegetChildByName (const std::string &name) const =0
 
virtual ProcgetProc ()
 
virtual const ProcgetProc () const
 
virtual void accept (Visitor *visitor)=0
 
virtual int getMaxLevelOfParallelism () const =0
 
virtual void getWeightRegardingDPL (ComplexWeight *weight)=0
 
virtual void partitionRegardingDPL (const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)=0
 
std::string getQualifiedName () const
 same as Node::getName() in most cases, but differs for children of switch More...
 
int getNumId ()
 return node instance identifiant, unique for each node instance More...
 
std::vector< std::pair< std::string, int > > getDPLScopeInfo (ComposedNode *gfn)
 
virtual void applyDPLScope (ComposedNode *gfn)
 
virtual void sendEvent (const std::string &event)
 emit notification to all observers registered with the dispatcher More...
 
virtual void sendEvent2 (const std::string &event, void *something)
 emit notification to all observers registered with the dispatcher More...
 
virtual std::string typeName ()
 
virtual std::string getErrorDetails () const
 
virtual void setErrorDetails (const std::string &error)
 
virtual void modified ()
 Sets Node in modified state and its father if it exists. More...
 
virtual int isModified ()
 
virtual int isValid ()
 indicates if the node is valid (returns 1) or not (returns 0) More...
 
virtual void edUpdateState ()
 update the status of the node More...
 
virtual std::string getErrorReport ()
 returns a string that contains an error report if the node is in error More...
 
virtual std::string getContainerLog ()
 returns a string that contains the name of the container log file if it exists More...
 
virtual void ensureLoading ()
 Put this node into TOLOAD state when possible. More...
 
virtual void getCoupledNodes (std::set< Task * > &coupledNodes)
 
virtual void cleanNodes ()
 Clean the node in case of not clean exit. More...
 
- Public Member Functions inherited from YACS::ENGINE::Task
virtual void begin ()=0
 
virtual bool isReady ()=0
 
virtual void execute ()=0
 
virtual void load ()=0
 
virtual void loaded ()=0
 
virtual void connected ()=0
 
virtual void initService ()=0
 
virtual void connectService ()=0
 
virtual void disconnectService ()=0
 
virtual void getCoupledTasks (std::set< Task * > &coupledSet)=0
 
virtual bool isDeployable () const =0
 
virtual ComponentInstancegetComponent ()=0
 
virtual const ComponentInstancegetComponent () const =0
 
virtual ContainergetContainer ()=0
 
virtual YACS::StatesForNode getState () const =0
 
virtual void finished ()=0
 
virtual void aborted ()=0
 
virtual void imposeResource (const std::string &resource_name, const std::string &container_name)
 
virtual bool canAcceptImposedResource ()
 
virtual bool hasImposedResource () const
 
virtual ~Task ()
 

Static Public Member Functions

static void ExecuteLocalInternal (const std::string &codeStr, PyObject *context, std::string &errorDetails)
 
- Static Public Member Functions inherited from YACS::ENGINE::Node
static std::string getStateName (YACS::StatesForNode state)
 Return the name of a state. More...
 
static void checkValidityOfNodeName (const std::string &name)
 
- Static Public Member Functions inherited from YACS::ENGINE::PythonEntry
static bool IsProxy (PyObject *ob)
 
static bool GetDestroyStatus (PyObject *ob)
 
static void DoNotTouchFileIfProxy (PyObject *ob)
 
static void UnlinkOnDestructorIfProxy (PyObject *ob)
 
static void IfProxyDoSomething (PyObject *ob, const char *meth)
 

Static Public Attributes

static const char KIND [] ="Python"
 
static const char IMPL_NAME [] ="Python"
 
static const char SCRIPT_FOR_SERIALIZATION []
 
static const char REMOTE_NAME [] ="remote"
 
static const char DPL_INFO_NAME [] ="my_dpl_localization"
 
- Static Public Attributes inherited from YACS::ENGINE::InlineNode
static const char LOCAL_STR [] ="local"
 
static const char REMOTE_STR [] ="remote"
 
- Static Public Attributes inherited from YACS::ENGINE::Node
static std::map< int, Node * > idMap
 
- Static Public Attributes inherited from YACS::ENGINE::PythonEntry
static const char SCRIPT_FOR_SIMPLE_SERIALIZATION []
 

Protected Member Functions

NodesimpleClone (ComposedNode *father, bool editionOnly) const
 
void createRemoteAdaptedPyInterpretor (Engines::Container_ptr objContainer)
 returns an object, you have to deal with (UnRegister) More...
 
Engines::PyNodeBase_var retrieveDftRemotePyInterpretorIfAny (Engines::Container_ptr objContainer) const
 returns (if any) an object, you have to deal with (UnRegister) More...
 
void assignRemotePyInterpretor (Engines::PyNodeBase_var remoteInterp)
 
Engines::PyNodeBase_var getRemoteInterpreterHandle ()
 
const char * getSerializationScript () const
 
std::string pythonEntryName () const
 
void squeezeMemory ()
 
void squeezeMemoryRemote ()
 
void freeKernelPynode ()
 
- Protected Member Functions inherited from YACS::ENGINE::InlineNode
 InlineNode (const InlineNode &other, ComposedNode *father)
 
 InlineNode (const std::string &name)
 
- Protected Member Functions inherited from YACS::ENGINE::ElementaryNode
 ElementaryNode (const std::string &name)
 
 ElementaryNode (const ElementaryNode &other, ComposedNode *father)
 
void performDuplicationOfPlacement (const Node &other)
 performs a duplication of placement using clone method of containers and components. clone behaviour is driven by attachOnCloning attribute. More...
 
void performShallowDuplicationOfPlacement (const Node &other)
 performs a also duplication of placement but here containers and components are not copied at all whatever the value of attachedOnCloning. More...
 
void initCommonPartWithoutStateManagement (bool start)
 
virtual void createMultiDatastreamPorts ()
 
void edDisconnectAllLinksWithMe ()
 
bool areAllInputPortsValid () const
 
template<class PORT >
PORT * getPort (const std::string &name, const std::list< PORT * > &setOfPorts) const
 
template<class PORT , class ENUMTYPE >
PORT * edAddPort (const std::string &portName, std::list< PORT * > &setOfPorts, ENUMTYPE type)
 
template<class PORT , class ENUMTYPE >
bool edCheckAddPort (const std::string &portName, std::list< PORT * > &setOfPorts, ENUMTYPE type)
 
- Protected Member Functions inherited from YACS::ENGINE::Node
 Node (const std::string &name)
 
 Node (const Node &other, ComposedNode *father)
 
virtual void performDuplicationOfPlacement (const Node &other)=0
 performs a duplication of placement using clone method of containers and components. clone behaviour is driven by attachOnCloning attribute. More...
 
virtual void performShallowDuplicationOfPlacement (const Node &other)=0
 performs a also duplication of placement but here containers and components are not copied at all whatever the value of attachedOnCloning. More...
 
virtual NodesimpleClone (ComposedNode *father, bool editionOnly=true) const =0
 
virtual void exForwardFailed ()
 
virtual void exForwardFinished ()
 
virtual void edDisconnectAllLinksWithMe ()
 
- Protected Member Functions inherited from YACS::ENGINE::PythonEntry
 PythonEntry ()
 
 ~PythonEntry ()
 
virtual void assignRemotePyInterpretor (Engines::PyNodeBase_var remoteInterp)=0
 
virtual Engines::PyNodeBase_var retrieveDftRemotePyInterpretorIfAny (Engines::Container_ptr objContainer) const =0
 returns (if any) an object, you have to deal with (UnRegister) More...
 
virtual void createRemoteAdaptedPyInterpretor (Engines::Container_ptr objContainer)=0
 returns an object, you have to deal with (UnRegister) More...
 
virtual Engines::PyNodeBase_var getRemoteInterpreterHandle ()=0
 
virtual const char * getSerializationScript () const =0
 
void commonRemoteLoad (InlineNode *reqNode)
 
void loadRemoteContainer (InlineNode *reqNode)
 
Engines::Container_var loadPythonAdapter (InlineNode *reqNode, bool &isInitializeRequested)
 
void loadRemoteContext (InlineNode *reqNode, Engines::Container_ptr objContainer, bool isInitializeRequested)
 
virtual bool hasImposedResource () const
 

Protected Attributes

bool _autoSqueeze = false
 
std::set< std::string > _nonSqueezableOutputNodes
 list on output port name excluded from the squeeze mecanism More...
 
Engines::PyScriptNode_var _pynode
 
- Protected Attributes inherited from YACS::ENGINE::InlineNode
std::string _script
 
std::string _mode
 
Container_container
 
- Protected Attributes inherited from YACS::ENGINE::ElementaryNode
std::list< InputPort * > _setOfInputPort
 
std::list< OutputPort * > _setOfOutputPort
 
std::list< InputDataStreamPort * > _setOfInputDataStreamPort
 
std::list< OutputDataStreamPort * > _setOfOutputDataStreamPort
 
ComplexWeight _weight
 
bool _createDatastreamPorts
 
bool _multi_port_node
 
- Protected Attributes inherited from YACS::ENGINE::Node
InGate _inGate
 
OutGate _outGate
 
InPropertyPort_inPropertyPort
 
std::string _name
 
ComposedNode_father
 
YACS::StatesForNode _state
 
int _modified
 
std::string _errorDetails
 
int _numId
 
std::string _implementation
 
std::map< std::string, std::string > _propertyMap
 
Node_eventReceiver =nullptr
 
- Protected Attributes inherited from YACS::ENGINE::PythonEntry
PyObject * _context
 
PyObject * _pyfuncSer
 
PyObject * _pyfuncUnser
 
PyObject * _pyfuncSimpleSer
 
std::string _imposedResource
 
std::string _imposedContainer
 

Private Member Functions

void executeLocalInternal (const std::string &codeStr)
 

Additional Inherited Members

- Public Attributes inherited from YACS::ENGINE::Node
YACS::Colour _colour
 
- Static Protected Member Functions inherited from YACS::ENGINE::ElementaryNode
template<class PORT >
static void edRemovePortTypedFromSet (PORT *port, std::list< PORT * > &setOfPorts)
 
template<class PORT >
static bool isPortNameAlreadyExist (const std::string &portName, const std::list< PORT * > &setOfPorts)
 
- Static Protected Member Functions inherited from YACS::ENGINE::Node
static void checkValidityOfPortName (const std::string &name)
 
static ComposedNodecheckHavingCommonFather (Node *node1, Node *node2)
 
- Static Protected Member Functions inherited from YACS::ENGINE::PythonEntry
static std::string GetContainerLog (const std::string &mode, Container *container, const Task *askingTask)
 
- Static Protected Attributes inherited from YACS::ENGINE::Node
static const char SEP_CHAR_IN_PORT [] ="."
 
static int _total = 0
 
- Static Protected Attributes inherited from YACS::ENGINE::PythonEntry
static PyObject * _pyClsBigObject = nullptr
 

Detailed Description

Definition at line 75 of file PythonNode.hxx.

Constructor & Destructor Documentation

◆ PythonNode() [1/2]

PythonNode::PythonNode ( const PythonNode other,
ComposedNode father 
)

Definition at line 418 of file PythonNode.cxx.

418 :
420{
421 _pynode = Engines::PyScriptNode::_nil();
423 {
424 AutoGIL agil;
425 _context=PyDict_New();
426 if( PyDict_SetItemString( _context, "__builtins__", getSALOMERuntime()->getBuiltins() ))
427 {
428 stringstream msg;
429 msg << "Impossible to set builtins" << __FILE__ << ":" << __LINE__;
430 _errorDetails=msg.str();
431 throw Exception(msg.str());
432 }
433 }
434}
InlineNode(const InlineNode &other, ComposedNode *father)
Definition: InlineNode.hxx:46
std::string _implementation
Definition: Node.hxx:97
std::string _errorDetails
Definition: Node.hxx:93
Engines::PyScriptNode_var _pynode
Definition: PythonNode.hxx:131
static const char IMPL_NAME[]
Definition: PythonNode.hxx:123
std::set< std::string > _nonSqueezableOutputNodes
list on output port name excluded from the squeeze mecanism
Definition: PythonNode.hxx:130
YACSRUNTIMESALOME_EXPORT RuntimeSALOME * getSALOMERuntime()

References YACS::ENGINE::PythonEntry::_context, YACS::ENGINE::Node::_errorDetails, YACS::ENGINE::Node::_implementation, _pynode, YACS::ENGINE::getSALOMERuntime(), and IMPL_NAME.

Referenced by cloneNode(), and simpleClone().

◆ PythonNode() [2/2]

PythonNode::PythonNode ( const std::string &  name)

Definition at line 436 of file PythonNode.cxx.

436 :InlineNode(name)
437{
438 _pynode = Engines::PyScriptNode::_nil();
440 {
441 AutoGIL agil;
442 _context=PyDict_New();
443 if( PyDict_SetItemString( _context, "__builtins__", getSALOMERuntime()->getBuiltins() ))
444 {
445 stringstream msg;
446 msg << "Impossible to set builtins" << __FILE__ << ":" << __LINE__;
447 _errorDetails=msg.str();
448 throw Exception(msg.str());
449 }
450 }
451}

References YACS::ENGINE::PythonEntry::_context, YACS::ENGINE::Node::_errorDetails, YACS::ENGINE::Node::_implementation, _pynode, YACS::ENGINE::getSALOMERuntime(), and IMPL_NAME.

◆ ~PythonNode()

PythonNode::~PythonNode ( )
virtual

Definition at line 453 of file PythonNode.cxx.

454{
456}

References freeKernelPynode().

Member Function Documentation

◆ applyDPLScope()

void PythonNode::applyDPLScope ( ComposedNode gfn)
virtual

Method called by the Executor only if the executor is sensitive of scope of DynParaLoop. This method is virtual and empty because by default nothing is done.

Reimplemented from YACS::ENGINE::Node.

Definition at line 1050 of file PythonNode.cxx.

1051{
1052 std::vector< std::pair<std::string,int> > ret(getDPLScopeInfo(gfn));
1053 if(ret.empty())
1054 return ;
1055 //
1056 PyObject *ob(0);
1057 {
1058 AutoGIL agil;
1059 std::size_t sz(ret.size());
1060 ob=PyList_New(sz);
1061 for(std::size_t i=0;i<sz;i++)
1062 {
1063 const std::pair<std::string,int>& p(ret[i]);
1064 PyObject *elt(PyTuple_New(2));
1065 PyTuple_SetItem(elt,0,PyUnicode_FromString(p.first.c_str()));
1066 PyTuple_SetItem(elt,1,PyLong_FromLong(p.second));
1067 PyList_SetItem(ob,i,elt);
1068 }
1069 }
1070 if(_mode==REMOTE_NAME)
1071 {
1072 Engines::pickledArgs_var serializationInputCorba(new Engines::pickledArgs);
1073 {
1074 AutoGIL agil;
1075 PyObject *serializationInput(PyObject_CallFunctionObjArgs(_pyfuncSimpleSer,ob,NULL));
1076 Py_XDECREF(ob);
1077 char *serializationInputC(0);
1078 Py_ssize_t len;
1079 if (PyBytes_AsStringAndSize(serializationInput, &serializationInputC, &len))
1080 throw Exception("DistributedPythonNode problem in python pickle");
1081 serializationInputCorba->length(len);
1082 for(int i=0; i < len ; i++)
1083 serializationInputCorba[i]=serializationInputC[i];
1084 Py_XDECREF(serializationInput);
1085 }
1086 _pynode->defineNewCustomVar(DPL_INFO_NAME,serializationInputCorba);
1087 }
1088 else
1089 {
1090 AutoGIL agil;
1091 PyDict_SetItemString(_context,DPL_INFO_NAME,ob);
1092 Py_XDECREF(ob);
1093 }
1094}
int Py_ssize_t
Definition: PythonNode.cxx:45
std::vector< std::pair< std::string, int > > getDPLScopeInfo(ComposedNode *gfn)
Definition: Node.cxx:660
static const char REMOTE_NAME[]
Definition: PythonNode.hxx:125
static const char DPL_INFO_NAME[]
Definition: PythonNode.hxx:126
Proc * p
Definition: driver.cxx:216

References YACS::ENGINE::PythonEntry::_context, YACS::ENGINE::InlineNode::_mode, YACS::ENGINE::PythonEntry::_pyfuncSimpleSer, _pynode, DPL_INFO_NAME, YACS::ENGINE::Node::getDPLScopeInfo(), yacsorb.CORBAEngineTest::i, p, and REMOTE_NAME.

◆ assignRemotePyInterpretor()

void PythonNode::assignRemotePyInterpretor ( Engines::PyNodeBase_var  remoteInterp)
protectedvirtual

Implements YACS::ENGINE::PythonEntry.

Definition at line 1005 of file PythonNode.cxx.

1006{
1007 if(CORBA::is_nil(_pynode))
1008 _pynode=Engines::PyScriptNode::_narrow(remoteInterp);
1009 else
1010 {
1011 Engines::PyScriptNode_var tmpp(Engines::PyScriptNode::_narrow(remoteInterp));
1012 if(!_pynode->_is_equivalent(tmpp))
1013 {
1015 _pynode=Engines::PyScriptNode::_narrow(remoteInterp);
1016 }
1017 }
1018 _pynode->assignNewCompiledCode(getScript().c_str());
1019}
virtual std::string getScript()
Definition: InlineNode.hxx:51

References _pynode, freeKernelPynode(), and YACS::ENGINE::InlineNode::getScript().

◆ canAcceptImposedResource()

bool PythonNode::canAcceptImposedResource ( )
overridevirtual

Reimplemented from YACS::ENGINE::Task.

Definition at line 941 of file PythonNode.cxx.

942{
943 return _container != nullptr && _container->canAcceptImposedResource();
944}
virtual bool canAcceptImposedResource()
Definition: Container.cxx:59

References YACS::ENGINE::InlineNode::_container, and YACS::ENGINE::Container::canAcceptImposedResource().

◆ checkBasicConsistency()

void PythonNode::checkBasicConsistency ( ) const
virtual

Reimplemented from YACS::ENGINE::ElementaryNode.

Definition at line 458 of file PythonNode.cxx.

459{
460 DEBTRACE("checkBasicConsistency");
462 {
463 AutoGIL agil;
464 PyObject* res;
465 res=Py_CompileString(_script.c_str(),getName().c_str(),Py_file_input);
466 if(res == NULL)
467 {
468 std::string error="";
469 PyObject* new_stderr = newPyStdOut(error);
470 PySys_SetObject((char*)"stderr", new_stderr);
471 PyErr_Print();
472 PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
473 Py_DECREF(new_stderr);
474 throw Exception(error);
475 }
476 else
477 Py_XDECREF(res);
478 }
479}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
virtual void checkBasicConsistency() const
const std::string & getName() const
Definition: Node.hxx:125
PyObject * newPyStdOut(std::string &out)
Definition: PyStdout.cxx:129

References YACS::ENGINE::InlineNode::_script, YACS::ENGINE::ElementaryNode::checkBasicConsistency(), DEBTRACE, YACS::ENGINE::Node::getName(), and YACS::ENGINE::newPyStdOut().

◆ cloneNode()

PythonNode * PythonNode::cloneNode ( const std::string &  name)
virtual

Create a new node of same type with a given name.

Reimplemented from YACS::ENGINE::InlineNode.

Definition at line 1027 of file PythonNode.cxx.

1028{
1029 PythonNode* n=new PythonNode(name);
1030 n->setScript(_script);
1031 list<InputPort *>::iterator iter;
1032 for(iter = _setOfInputPort.begin(); iter != _setOfInputPort.end(); iter++)
1033 {
1034 InputPyPort *p=(InputPyPort *)*iter;
1035 DEBTRACE( "port name: " << p->getName() );
1036 DEBTRACE( "port kind: " << p->edGetType()->kind() );
1037 n->edAddInputPort(p->getName(),p->edGetType());
1038 }
1039 list<OutputPort *>::iterator iter2;
1040 for(iter2 = _setOfOutputPort.begin(); iter2 != _setOfOutputPort.end(); iter2++)
1041 {
1042 OutputPyPort *p=(OutputPyPort *)*iter2;
1043 DEBTRACE( "port name: " << p->getName() );
1044 DEBTRACE( "port kind: " << p->edGetType()->kind() );
1045 n->edAddOutputPort(p->getName(),p->edGetType());
1046 }
1047 return n;
1048}
std::string getName() const
std::list< InputPort * > _setOfInputPort
std::list< OutputPort * > _setOfOutputPort
Class for Python Ports.
Definition: PythonPorts.hxx:74
PythonNode(const PythonNode &other, ComposedNode *father)
Definition: PythonNode.cxx:418

References YACS::ENGINE::InlineNode::_script, YACS::ENGINE::ElementaryNode::_setOfInputPort, YACS::ENGINE::ElementaryNode::_setOfOutputPort, DEBTRACE, YACS::ENGINE::ComposedNode::getName(), gui.Appli::n, p, and PythonNode().

◆ createRemoteAdaptedPyInterpretor()

void PythonNode::createRemoteAdaptedPyInterpretor ( Engines::Container_ptr  objContainer)
protectedvirtual

returns an object, you have to deal with (UnRegister)

Implements YACS::ENGINE::PythonEntry.

Definition at line 988 of file PythonNode.cxx.

989{
991 _pynode=objContainer->createPyScriptNode(pythonEntryName().c_str(),getScript().c_str());
992 _pynode->Register();
993}
std::string pythonEntryName() const
Definition: PythonNode.cxx:951

References _pynode, freeKernelPynode(), YACS::ENGINE::InlineNode::getScript(), and pythonEntryName().

◆ execute()

void PythonNode::execute ( )
virtual

Implements YACS::ENGINE::Task.

Definition at line 501 of file PythonNode.cxx.

502{
505 else
506 executeLocal();
507}
virtual void executeRemote()
Definition: PythonNode.cxx:509
virtual void executeLocal()
Definition: PythonNode.cxx:778

References YACS::ENGINE::InlineNode::_mode, executeLocal(), executeRemote(), and REMOTE_NAME.

◆ executeLocal()

void PythonNode::executeLocal ( )
virtual

Definition at line 778 of file PythonNode.cxx.

779{
780 DEBTRACE( "++++++++++++++ PyNode::executeLocal: " << getName() << " ++++++++++++++++++++" );
781 {
782 AutoGIL agil;
783 std::ostringstream unpxy; unpxy << "from SALOME_PyNode import UnProxyObjectSimpleLocal" << std::endl;
784 DEBTRACE( "---------------PyNode::inputs---------------" );
785 list<InputPort *>::iterator iter2;
786 for(iter2 = _setOfInputPort.begin(); iter2 != _setOfInputPort.end(); iter2++)
787 {
788 InputPyPort *p=(InputPyPort *)*iter2;
789 DEBTRACE( "port name: " << p->getName() );
790 DEBTRACE( "port kind: " << p->edGetType()->kind() );
791 PyObject* ob=p->getPyObj();
792 DEBTRACE( "ob refcnt: " << ob->ob_refcnt );
793 unpxy << p->getName() << " = UnProxyObjectSimpleLocal( " << p->getName() << " )" << std::endl;
794#ifdef _DEVDEBUG_
795 PyObject_Print(ob,stderr,Py_PRINT_RAW);
796 cerr << endl;
797#endif
798 int ier=PyDict_SetItemString(_context,p->getName().c_str(),ob);
799 DEBTRACE( "after PyDict_SetItemString:ob refcnt: " << ob->ob_refcnt );
800 }
801
802 DEBTRACE( "---------------End PyNode::inputs---------------" );
803
804 //calculation
805 DEBTRACE( "----------------PyNode::calculation---------------" );
806
807 if( ! getSqueezeStatus() )
808 executeLocalInternal( unpxy.str() );
809
811
812 DEBTRACE( "-----------------PyNode::outputs-----------------" );
813 list<OutputPort *>::iterator iter;
814 try
815 {
816 for(iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); iter++)
817 {
818 OutputPyPort *p=(OutputPyPort *)*iter;
819 DEBTRACE( "port name: " << p->getName() );
820 DEBTRACE( "port kind: " << p->edGetType()->kind() );
821 PyObject *ob=PyDict_GetItemString(_context,p->getName().c_str());
822 if(ob==NULL)
823 {
824 std::string msg="Error during execution: there is no variable ";
825 msg=msg+p->getName()+" in node context";
826 _errorDetails=msg;
827 throw Exception(msg);
828 }
829 DEBTRACE( "PyNode::outputs::ob refcnt: " << ob->ob_refcnt );
830#ifdef _DEVDEBUG_
831 PyObject_Print(ob,stderr,Py_PRINT_RAW);
832 cerr << endl;
833#endif
834 p->put(ob);
835 if(!isUsingPythonCache())
836 PyDict_DelItemString(_context,p->getName().c_str());
837 }
838 }
839 catch(ConversionException& ex)
840 {
841 _errorDetails=ex.what();
842 throw;
843 }
844 if(_autoSqueeze)
846 DEBTRACE( "-----------------End PyNode::outputs-----------------" );
847 if(!isUsingPythonCache())
848 {
849 for(iter2 = _setOfInputPort.begin(); iter2 != _setOfInputPort.end(); iter2++)
850 {
851 AutoPyRef pStr = PyUnicode_FromString( (*iter2)->getName().c_str() );
852 if( PyDict_Contains(_context,pStr) == 1 )
853 { PyDict_DelItem(_context,pStr); }
854 }
855 }
856 }
857 DEBTRACE( "++++++++++++++ End PyNode::execute: " << getName() << " ++++++++++++++++++++" );
858}
bool isUsingPythonCache() const
Definition: PythonNode.cxx:959
void executeLocalInternal(const std::string &codeStr)
Definition: PythonNode.cxx:773
bool getSqueezeStatus() const
Definition: PythonNode.hxx:112

References _autoSqueeze, YACS::ENGINE::PythonEntry::_context, YACS::ENGINE::Node::_errorDetails, YACS::ENGINE::InlineNode::_script, YACS::ENGINE::ElementaryNode::_setOfInputPort, YACS::ENGINE::ElementaryNode::_setOfOutputPort, DEBTRACE, testCppPluginInvokation::ex, executeLocalInternal(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getName(), getSqueezeStatus(), isUsingPythonCache(), p, and squeezeMemory().

Referenced by execute().

◆ executeLocalInternal()

void PythonNode::executeLocalInternal ( const std::string &  codeStr)
private

Definition at line 773 of file PythonNode.cxx.

774{
776}
static void ExecuteLocalInternal(const std::string &codeStr, PyObject *context, std::string &errorDetails)
Definition: PythonNode.cxx:733

References YACS::ENGINE::PythonEntry::_context, YACS::ENGINE::Node::_errorDetails, and ExecuteLocalInternal().

Referenced by executeLocal().

◆ ExecuteLocalInternal()

void PythonNode::ExecuteLocalInternal ( const std::string &  codeStr,
PyObject *  context,
std::string &  errorDetails 
)
static

Definition at line 733 of file PythonNode.cxx.

734{
735 DEBTRACE( code );
736 DEBTRACE( "context refcnt: " << context->ob_refcnt );
737 std::ostringstream stream;
738 stream << "/tmp/PythonNode_";
739 stream << getpid();
740 AutoPyRef code=Py_CompileString(codeStr.c_str(), stream.str().c_str(), Py_file_input);
741 if(code == NULL)
742 {
743 errorDetails="";
744 AutoPyRef new_stderr = newPyStdOut(errorDetails);
745 PySys_SetObject((char*)"stderr", new_stderr);
746 PyErr_Print();
747 PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
748 throw YACS::Exception("Error during execution");
749 }
750 {
751 AutoPyRef res = PyEval_EvalCode( code, context, context);
752 }
753 DEBTRACE( "context refcnt: " << context->ob_refcnt );
754 fflush(stdout);
755 fflush(stderr);
756 if(PyErr_Occurred ())
757 {
758 errorDetails="";
759 AutoPyRef new_stderr = newPyStdOut(errorDetails);
760 PySys_SetObject((char*)"stderr", new_stderr);
761 ofstream errorfile(stream.str().c_str());
762 if (errorfile.is_open())
763 {
764 errorfile << codeStr;
765 errorfile.close();
766 }
767 PyErr_Print();
768 PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
769 throw YACS::Exception("Error during execution");
770 }
771}

References DEBTRACE, and YACS::ENGINE::newPyStdOut().

Referenced by executeLocalInternal(), and YACS::ENGINE::RuntimeSALOME::launchSubProcess().

◆ executeRemote()

void PythonNode::executeRemote ( )
virtual

Definition at line 509 of file PythonNode.cxx.

510{
511 DEBTRACE( "++++++++++++++ PyNode::executeRemote: " << getName() << " ++++++++++++++++++++" );
512 if(!_pyfuncSer)
513 throw Exception("PythonNode badly loaded");
514 //
515 if(dynamic_cast<HomogeneousPoolContainer *>(getContainer()))
516 {
517 bool dummy;
518 loadPythonAdapter(this,dummy);
519 _pynode->assignNewCompiledCode(getScript().c_str());
520 }
521 // not managed by unique_ptr here because destructed by the order of client.
522 SenderByteImpl *serializationInputCorba = nullptr;
523 AutoPyRef serializationInput;
524 {
525#if PY_VERSION_HEX < 0x03070000
526 std::unique_lock<std::mutex> lock(data_mutex);
527#endif
528 AutoGIL agil;
529 PyObject *args(0),*ob(0);
530 //===========================================================================
531 // Get inputs in input ports, build a Python dict and pickle it
532 //===========================================================================
533 args = PyDict_New();
534 std::list<InputPort *>::iterator iter2;
535 int pos(0);
536 for(iter2 = _setOfInputPort.begin(); iter2 != _setOfInputPort.end(); ++iter2)
537 {
538 InputPyPort *p=(InputPyPort *)*iter2;
539 ob=p->getPyObj();
540 PyDict_SetItemString(args,p->getName().c_str(),ob);
541 pos++;
542 }
543#ifdef _DEVDEBUG_
544 PyObject_Print(args,stderr,Py_PRINT_RAW);
545 std::cerr << endl;
546#endif
547 serializationInput.set(PyObject_CallFunctionObjArgs(_pyfuncSer,args,nullptr));
548 Py_DECREF(args);
549 //The pickled string may contain NULL characters so use PyString_AsStringAndSize
550 char *serializationInputC(nullptr);
551 Py_ssize_t len;
552 if (PyBytes_AsStringAndSize(serializationInput, &serializationInputC, &len))
553 throw Exception("DistributedPythonNode problem in python pickle");
554 // no copy here. The C byte array of Python is taken as this into CORBA sequence to avoid copy
555 serializationInputCorba = new SenderByteImpl(serializationInputC,len);
556 }
557
558 //get the list of output argument names
559 std::list<OutputPort *>::iterator iter;
560 Engines::listofstring myseq;
561 myseq.length(getNumberOfOutputPorts());
562 int pos=0;
563 for(iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); ++iter)
564 {
565 OutputPyPort *p=(OutputPyPort *)*iter;
566 myseq[pos]=p->getName().c_str();
567 DEBTRACE( "port name: " << p->getName() );
568 DEBTRACE( "port kind: " << p->edGetType()->kind() );
569 DEBTRACE( "port pos : " << pos );
570 pos++;
571 }
572 //===========================================================================
573 // Execute in remote Python node
574 //===========================================================================
575 DEBTRACE( "-----------------starting remote python invocation-----------------" );
576 std::unique_ptr<SALOME::SenderByteSeq> resultCorba;
577 try
578 {
579 //pass outargsname and dict serialized
580 SALOME::SenderByte_var serializationInputRef = serializationInputCorba->_this();
581 DEBUG_YACSTRACE("Before execute first of " << getId());
582 _pynode->executeFirst(serializationInputRef);
583 //serializationInput and serializationInputCorba are no more needed for server. Release it.
584 {
585 AutoGIL agil;
586 serializationInput.set(nullptr);
587 }
588 resultCorba.reset( _pynode->executeSecond(myseq) );
589 DEBUG_YACSTRACE("After execute second of " << getId());
590 }
591 catch( const SALOME::SALOME_Exception& ex )
592 {
593 std::ostringstream msg; msg << "Exception on remote python invocation" << std::endl << ex.details.text.in() << std::endl;
594 msg << "PyScriptNode CORBA ref : ";
595 {
596 CORBA::ORB_ptr orb(getSALOMERuntime()->getOrb());
597 if(!CORBA::is_nil(orb))
598 {
599 CORBA::String_var IOR(orb->object_to_string(_pynode));
600 msg << IOR;
601 }
602 }
603 msg << std::endl;
604 _errorDetails=msg.str();
605 throw Exception(msg.str());
606 }
607 catch(CORBA::COMM_FAILURE& ex)
608 {
609 std::ostringstream msg;
610 msg << "Exception on remote python invocation." << std::endl ;
611 msg << "Caught system exception COMM_FAILURE -- unable to contact the "
612 << "object." << std::endl;
613 _errorDetails=msg.str();
614 throw Exception(msg.str());
615 }
616 catch(CORBA::SystemException& ex)
617 {
618 std::ostringstream msg;
619 msg << "Exception on remote python invocation." << std::endl ;
620 msg << "Caught a CORBA::SystemException." ;
621 CORBA::Any tmp;
622 tmp <<= ex;
623 CORBA::TypeCode_var tc = tmp.type();
624 const char *p = tc->name();
625 if ( *p != '\0' )
626 msg <<p;
627 else
628 msg << tc->id();
629 msg << std::endl;
630 _errorDetails=msg.str();
631 throw Exception(msg.str());
632 }
633 catch(CORBA::Exception& ex)
634 {
635 std::ostringstream msg;
636 msg << "Exception on remote python invocation." << std::endl ;
637 msg << "Caught CORBA::Exception. " ;
638 CORBA::Any tmp;
639 tmp <<= ex;
640 CORBA::TypeCode_var tc = tmp.type();
641 const char *p = tc->name();
642 if ( *p != '\0' )
643 msg <<p;
644 else
645 msg << tc->id();
646 msg << std::endl;
647 _errorDetails=msg.str();
648 throw Exception(msg.str());
649 }
650 catch(omniORB::fatalException& fe)
651 {
652 std::ostringstream msg;
653 msg << "Exception on remote python invocation." << std::endl ;
654 msg << "Caught omniORB::fatalException:" << std::endl;
655 msg << " file: " << fe.file() << std::endl;
656 msg << " line: " << fe.line() << std::endl;
657 msg << " mesg: " << fe.errmsg() << std::endl;
658 _errorDetails=msg.str();
659 throw Exception(msg.str());
660 }
661 DEBTRACE( "-----------------end of remote python invocation-----------------" );
662 //===========================================================================
663 // Get results, unpickle and put them in output ports
664 //===========================================================================
665 {
666#if PY_VERSION_HEX < 0x03070000
667 std::unique_lock<std::mutex> lock(data_mutex);
668#endif
669 AutoGIL agil;
670 DEBTRACE( "-----------------PythonNode::outputs-----------------" );
671 int nres( resultCorba->length() );
672
673 if(getNumberOfOutputPorts() != nres)
674 {
675 std::string msg="Number of output arguments : Mismatch between definition and execution";
676 _errorDetails=msg;
677 throw Exception(msg);
678 }
679 pos=0;
680 try
681 {
682 for(iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); ++iter)
683 {
684 OutputPyPort *p=(OutputPyPort *)*iter;
685 DEBUG_YACSTRACE("Start of dealing with output " << p->getName() << " of "<< getId());
686 DEBTRACE( "port name: " << p->getName() );
687 DEBTRACE( "port kind: " << p->edGetType()->kind() );
688 DEBTRACE( "port pos : " << pos );
689 SALOME::SenderByte_var elt = (*resultCorba)[pos];
690 SeqByteReceiver recv(elt);
691 unsigned long length = 0;
692 char *resultCorbaC = recv.data(length);
693 {
694 AutoPyRef resultPython=PyMemoryView_FromMemory(resultCorbaC,length,PyBUF_READ);
695 AutoPyRef args = PyTuple_New(1);
696 PyTuple_SetItem(args,0,resultPython.retn());
697 AutoPyRef ob = PyObject_CallObject(_pyfuncUnser,args);
698 if (!ob)
699 {
700 std::stringstream msg;
701 msg << "Conversion with pickle of output ports failed !";
702 msg << " : " << __FILE__ << ":" << __LINE__;
703 _errorDetails=msg.str();
704 throw YACS::ENGINE::ConversionException(msg.str());
705 }
707 DEBUG_YACSTRACE("Assign PyObj output " << p->getName() << " of "<< getId());
708 p->put( ob );
709 DEBUG_YACSTRACE("End of assign PyObj output " << p->getName() << " of "<< getId());
710 }
711 pos++;
712 }
713 }
714 catch(ConversionException& ex)
715 {
716 _errorDetails=ex.what();
717 throw;
718 }
719 if(_autoSqueeze)
721 }
722 //
723 if(!isUsingPythonCache())
724 {
726 bool dummy;
727 Engines::Container_var cont(GetContainerObj(this,dummy));
728 cont->removePyScriptNode(getId().c_str());
729 }
730 DEBTRACE( "++++++++++++++ ENDOF PyNode::executeRemote: " << getName() << " ++++++++++++++++++++" );
731}
static std::mutex data_mutex
Definition: PythonNode.cxx:90
Engines::Container_var GetContainerObj(InlineNode *reqNode, bool &isStandardCont)
Definition: PythonNode.cxx:139
#define DEBUG_YACSTRACE(msg)
Definition: YacsTrace.hxx:53
virtual Container * getContainer()
Definition: InlineNode.cxx:100
const std::string getId() const
Definition: Node.cxx:478
static void UnlinkOnDestructorIfProxy(PyObject *ob)
Definition: PythonNode.cxx:413
Engines::Container_var loadPythonAdapter(InlineNode *reqNode, bool &isInitializeRequested)
Definition: PythonNode.cxx:165
CORBA::ORB_ptr orb
Definition: yacsSrv.cxx:39

References _autoSqueeze, YACS::ENGINE::Node::_errorDetails, YACS::ENGINE::PythonEntry::_pyfuncSer, YACS::ENGINE::PythonEntry::_pyfuncUnser, _pynode, YACS::ENGINE::ElementaryNode::_setOfInputPort, YACS::ENGINE::ElementaryNode::_setOfOutputPort, driver_internal::args, data_mutex, DEBTRACE, DEBUG_YACSTRACE, testCppPluginInvokation::ex, freeKernelPynode(), YACS::ENGINE::InlineNode::getContainer(), GetContainerObj(), YACS::ENGINE::Node::getId(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getName(), YACS::ENGINE::ElementaryNode::getNumberOfOutputPorts(), YACS::ENGINE::getSALOMERuntime(), YACS::ENGINE::InlineNode::getScript(), isUsingPythonCache(), YACS::ENGINE::PythonEntry::loadPythonAdapter(), orb, p, squeezeMemoryRemote(), and YACS::ENGINE::PythonEntry::UnlinkOnDestructorIfProxy().

Referenced by execute().

◆ freeKernelPynode()

void PythonNode::freeKernelPynode ( )
protected

Definition at line 967 of file PythonNode.cxx.

968{
969 if(!CORBA::is_nil(_pynode))
970 {
971 try
972 {
973 _pynode->UnRegister();
974 }
975 catch(...)
976 {
977 DEBTRACE("Trouble when pynode->UnRegister!")
978 }
979 _pynode = Engines::PyScriptNode::_nil();
980 }
981}

References _pynode, and DEBTRACE.

Referenced by assignRemotePyInterpretor(), createRemoteAdaptedPyInterpretor(), executeRemote(), shutdown(), and ~PythonNode().

◆ getContainerLog()

std::string PythonNode::getContainerLog ( )
virtual

returns a string that contains the name of the container log file if it exists

Do nothing here. To subclass

Reimplemented from YACS::ENGINE::Node.

Definition at line 915 of file PythonNode.cxx.

916{
918}
static std::string GetContainerLog(const std::string &mode, Container *container, const Task *askingTask)
Definition: PythonNode.cxx:283

References YACS::ENGINE::InlineNode::_container, YACS::ENGINE::InlineNode::_mode, and YACS::ENGINE::PythonEntry::GetContainerLog().

◆ getRemoteInterpreterHandle()

Engines::PyNodeBase_var PythonNode::getRemoteInterpreterHandle ( )
protectedvirtual

Implements YACS::ENGINE::PythonEntry.

Definition at line 1021 of file PythonNode.cxx.

1022{
1023 return Engines::PyNodeBase::_narrow(_pynode);
1024}

References _pynode.

◆ getSerializationScript()

const char * YACS::ENGINE::PythonNode::getSerializationScript ( ) const
inlineprotectedvirtual

Implements YACS::ENGINE::PythonEntry.

Definition at line 84 of file PythonNode.hxx.

static const char SCRIPT_FOR_SERIALIZATION[]
Definition: PythonNode.hxx:124

◆ getSqueezeStatus()

bool YACS::ENGINE::PythonNode::getSqueezeStatus ( ) const
inline

Definition at line 112 of file PythonNode.hxx.

112{ return _autoSqueeze; }

Referenced by executeLocal().

◆ hasImposedResource()

bool PythonNode::hasImposedResource ( ) const
overridevirtual

Reimplemented from YACS::ENGINE::PythonEntry.

Definition at line 946 of file PythonNode.cxx.

947{
949}
virtual bool hasImposedResource() const
Definition: PythonNode.cxx:326

References YACS::ENGINE::PythonEntry::hasImposedResource().

◆ imposeResource()

void PythonNode::imposeResource ( const std::string &  resource_name,
const std::string &  container_name 
)
overridevirtual

Reimplemented from YACS::ENGINE::Task.

Definition at line 931 of file PythonNode.cxx.

933{
934 if(!resource_name.empty() && !container_name.empty())
935 {
936 _imposedResource = resource_name;
937 _imposedContainer = container_name;
938 }
939}
std::string _imposedResource
Definition: PythonNode.hxx:69
std::string _imposedContainer
Definition: PythonNode.hxx:70

References YACS::ENGINE::PythonEntry::_imposedContainer, and YACS::ENGINE::PythonEntry::_imposedResource.

◆ isUsingPythonCache()

bool PythonNode::isUsingPythonCache ( ) const

Definition at line 959 of file PythonNode.cxx.

960{
961 bool found = false;
962 if(_container)
964 return found;
965}
virtual bool isUsingPythonCache()
Definition: Container.cxx:109

References YACS::ENGINE::InlineNode::_container, and YACS::ENGINE::Container::isUsingPythonCache().

Referenced by executeLocal(), executeRemote(), and pythonEntryName().

◆ load()

void PythonNode::load ( )
virtual

Reimplemented from YACS::ENGINE::ElementaryNode.

Definition at line 481 of file PythonNode.cxx.

482{
483 DEBTRACE( "---------------PyNode::load function---------------" );
485 loadRemote();
486 else
487 loadLocal();
488}
virtual void loadLocal()
Definition: PythonNode.cxx:490
virtual void loadRemote()
Definition: PythonNode.cxx:496

References YACS::ENGINE::InlineNode::_mode, DEBTRACE, loadLocal(), loadRemote(), and REMOTE_NAME.

◆ loadLocal()

void PythonNode::loadLocal ( )
virtual

Definition at line 490 of file PythonNode.cxx.

491{
492 DEBTRACE( "---------------PyNode::loadLocal function---------------" );
493 // do nothing
494}

References DEBTRACE.

Referenced by load().

◆ loadRemote()

void PythonNode::loadRemote ( )
virtual

Definition at line 496 of file PythonNode.cxx.

497{
498 commonRemoteLoad(this);
499}
void commonRemoteLoad(InlineNode *reqNode)
Definition: PythonNode.cxx:318

References YACS::ENGINE::PythonEntry::commonRemoteLoad().

Referenced by load().

◆ pythonEntryName()

std::string PythonNode::pythonEntryName ( ) const
protected

Definition at line 951 of file PythonNode.cxx.

952{
954 return "DEFAULT_NAME_FOR_UNIQUE_PYTHON_NODE_ENTRY";
955 else
956 return getId();
957}

References YACS::ENGINE::Node::getId(), and isUsingPythonCache().

Referenced by createRemoteAdaptedPyInterpretor(), and retrieveDftRemotePyInterpretorIfAny().

◆ retrieveDftRemotePyInterpretorIfAny()

Engines::PyNodeBase_var PythonNode::retrieveDftRemotePyInterpretorIfAny ( Engines::Container_ptr  objContainer) const
protectedvirtual

returns (if any) an object, you have to deal with (UnRegister)

Implements YACS::ENGINE::PythonEntry.

Definition at line 995 of file PythonNode.cxx.

996{
997 Engines::PyScriptNode_var ret(objContainer->getDefaultPyScriptNode(pythonEntryName().c_str()));
998 if(!CORBA::is_nil(ret))
999 {
1000 ret->Register();
1001 }
1002 return Engines::PyNodeBase::_narrow(ret);
1003}

References pythonEntryName().

◆ setSqueezeStatus()

void YACS::ENGINE::PythonNode::setSqueezeStatus ( bool  sqStatus)
inline

Definition at line 111 of file PythonNode.hxx.

111{ _autoSqueeze=sqStatus; }

Referenced by main(), and setSqueezeStatusWithExceptions().

◆ setSqueezeStatusWithExceptions()

void PythonNode::setSqueezeStatusWithExceptions ( bool  sqStatus,
const std::vector< std::string > &  squeezeExceptions 
)

[EDF28562]

Parameters
insqueezeExceptions list on output port name excluded from the squeeze mecanism

Definition at line 864 of file PythonNode.cxx.

865{
866 this->setSqueezeStatus(sqStatus);
867 this->_nonSqueezableOutputNodes = std::set<std::string>(squeezeExceptions.begin(), squeezeExceptions.end());
868}
void setSqueezeStatus(bool sqStatus)
Definition: PythonNode.hxx:111

References _nonSqueezableOutputNodes, and setSqueezeStatus().

◆ shutdown()

void PythonNode::shutdown ( int  level)
virtual

Stop all pending activities of the node.

This method should be called when a Proc is finished and must be deleted from the YACS server

Reimplemented from YACS::ENGINE::Node.

Definition at line 920 of file PythonNode.cxx.

921{
922 DEBTRACE("PythonNode::shutdown " << level);
923 if(_mode=="local")return;
924 if(_container)
925 {
927 _container->shutdown(level);
928 }
929}
virtual void shutdown(int level)=0

References YACS::ENGINE::InlineNode::_container, YACS::ENGINE::InlineNode::_mode, DEBTRACE, freeKernelPynode(), and YACS::ENGINE::Container::shutdown().

◆ simpleClone()

Node * PythonNode::simpleClone ( ComposedNode father,
bool  editionOnly 
) const
protectedvirtual

Implements YACS::ENGINE::Node.

Definition at line 983 of file PythonNode.cxx.

984{
985 return new PythonNode(*this,father);
986}

References PythonNode().

◆ squeezeMemory()

void PythonNode::squeezeMemory ( )
protected

Definition at line 879 of file PythonNode.cxx.

880{
881 for(auto p : _setOfInputPort)
882 {
883 PyDict_DelItemString(_context,p->getName().c_str());
884 InputPyPort *p2(static_cast<InputPyPort *>(p));
885 if(p2->canSafelySqueezeMemory())
886 p2->put(Py_None);
887 }
888 for(auto p : _setOfOutputPort)
889 {
890 if (!this->_nonSqueezableOutputNodes.empty() && this->_nonSqueezableOutputNodes.find(p->getName()) != this->_nonSqueezableOutputNodes.end())
891 continue;
892 PyDict_DelItemString(_context,p->getName().c_str());
893 OutputPyPort *p2(static_cast<OutputPyPort *>(p));
894 p2->putWithoutForward(Py_None);
895 }
896}

References YACS::ENGINE::PythonEntry::_context, _nonSqueezableOutputNodes, YACS::ENGINE::ElementaryNode::_setOfInputPort, YACS::ENGINE::ElementaryNode::_setOfOutputPort, YACS::ENGINE::InPort::canSafelySqueezeMemory(), YACS::ENGINE::ComposedNode::getName(), p, YACS::ENGINE::InputPyPort::put(), and YACS::ENGINE::OutputPyPort::putWithoutForward().

Referenced by executeLocal(), and squeezeMemorySafe().

◆ squeezeMemoryRemote()

void PythonNode::squeezeMemoryRemote ( )
protected

Definition at line 898 of file PythonNode.cxx.

899{
900 for(auto p : _setOfInputPort)
901 {
902 InputPyPort *p2(static_cast<InputPyPort *>(p));
903 if(p2->canSafelySqueezeMemory())
904 p2->put(Py_None);
905 }
906 for(auto p : _setOfOutputPort)
907 {
908 if (!this->_nonSqueezableOutputNodes.empty() && this->_nonSqueezableOutputNodes.find(p->getName()) != this->_nonSqueezableOutputNodes.end())
909 continue;
910 OutputPyPort *p2(static_cast<OutputPyPort *>(p));
911 p2->putWithoutForward(Py_None);
912 }
913}

References _nonSqueezableOutputNodes, YACS::ENGINE::ElementaryNode::_setOfInputPort, YACS::ENGINE::ElementaryNode::_setOfOutputPort, YACS::ENGINE::InPort::canSafelySqueezeMemory(), YACS::ENGINE::ComposedNode::getName(), p, YACS::ENGINE::InputPyPort::put(), and YACS::ENGINE::OutputPyPort::putWithoutForward().

Referenced by executeRemote(), and squeezeMemorySafe().

◆ squeezeMemorySafe()

void PythonNode::squeezeMemorySafe ( )

Definition at line 870 of file PythonNode.cxx.

871{
872 AutoGIL agil;
874 this->squeezeMemoryRemote();
875 else
876 this->squeezeMemory();
877}

References YACS::ENGINE::InlineNode::_mode, REMOTE_NAME, squeezeMemory(), and squeezeMemoryRemote().

◆ typeName()

virtual std::string YACS::ENGINE::PythonNode::typeName ( )
inlinevirtual

Reimplemented from YACS::ENGINE::InlineNode.

Definition at line 108 of file PythonNode.hxx.

108{ return "YACS__ENGINE__PythonNode"; }

Member Data Documentation

◆ _autoSqueeze

bool YACS::ENGINE::PythonNode::_autoSqueeze = false
protected

Definition at line 128 of file PythonNode.hxx.

Referenced by executeLocal(), and executeRemote().

◆ _nonSqueezableOutputNodes

std::set<std::string> YACS::ENGINE::PythonNode::_nonSqueezableOutputNodes
protected

list on output port name excluded from the squeeze mecanism

Definition at line 130 of file PythonNode.hxx.

Referenced by setSqueezeStatusWithExceptions(), squeezeMemory(), and squeezeMemoryRemote().

◆ _pynode

Engines::PyScriptNode_var YACS::ENGINE::PythonNode::_pynode
protected

◆ DPL_INFO_NAME

const char PythonNode::DPL_INFO_NAME ="my_dpl_localization"
static

Definition at line 126 of file PythonNode.hxx.

Referenced by applyDPLScope().

◆ IMPL_NAME

◆ KIND

◆ REMOTE_NAME

const char PythonNode::REMOTE_NAME ="remote"
static

◆ SCRIPT_FOR_SERIALIZATION

const char PythonNode::SCRIPT_FOR_SERIALIZATION
static
Initial value:
="import pickle\n"
"def pickleForDistPyth2009(kws):\n"
" return pickle.dumps(((),kws),-1)\n"
"\n"
"def unPickleForDistPyth2009(st):\n"
" args=pickle.loads(st)\n"
" return args\n"

Definition at line 124 of file PythonNode.hxx.


The documentation for this class was generated from the following files: