View Issue Details

IDProjectCategoryView StatusLast Update
0004462Slicer4Core: Scripting (Wrapping, Python)public2017-11-16 11:11
ReporterpinterAssigned Tojcfr 
PriorityhighSeverityblockReproducibilityalways
Status assignedResolutionopen 
Product VersionSlicer 4.9.0 
Target VersionSlicer 4.9.0Fixed in Version 
Summary0004462: Python wrapping of VTK classes in extensions does not work properly
Description

The VTK classes don’t seem to be recognized as their proper class, similarly to the vtkSegmentationCore classes without importing the python module, but this time even when I import it specifically the type is wrong (which means that their methods cannot be called):

import vtkSlicerDicomRtImportExportModuleLogicPython
slicer.modules.dicomrtimportexport.logic() # DicomRtImportExport logic is only recognized as its base class
(SlicerBaseLogicPython.vtkSlicerModuleLogic)0000019BF9E1DB88
slicer.modules.volumes.logic() # Volumes logic is recognized correctly
(vtkSlicerVolumesModuleLogicPython.vtkSlicerVolumesLogic)0000019BF9E1DBE8

Steps To Reproduce

In SlicerRT:

TagsNo tags attached.

Relationships

has duplicate 0004448 closedjcfr Python wrapping of MRML classes not working with VTK8 build 

Activities

Davide

Davide

2017-10-31 09:02

developer   ~0015369

Hi Jc, do you have any news regarding this? do we have to update the extensions in some ways or it will be handled by the wrapping macro?

pinter

pinter

2017-10-31 10:58

developer   ~0015370

I'm happy to look into it if I know where to look.
Jc if you're too busy to work on this in the next few days, please send me your ideas and I'll start from those. Thanks!

Davide

Davide

2017-11-01 05:22

developer   ~0015371

I guess should be related to this: https://www.slicer.org/wiki/Documentation/Labs/Qt5-and-VTK8#VTK8:_Use_hierarchy_files_for_VTK_Python_wrapping
However, I have no idea how to proceed.

pinter

pinter

2017-11-01 09:29

developer   ~0015373

Thanks, Davide, I'll take a closer look at these hierarchy files. When I read this page, it seems I conveniently skipped through this section and thought the type macros should cut it...

jcfr

jcfr

2017-11-01 10:33

administrator   ~0015374

Hi,

Hierarchy files should also be generated within extensions. See [1]

I don't know what is happening yet, my understanding was that after the fix of Andras (see r26418 [2]) we were in good shape.

[1] https://github.com/Slicer/Slicer/blob/e77630416ec79c7cb6a8145c6286b39a25ebaec1/CMake/vtkMacroKitPythonWrap.cmake#L113-L215

[2] See viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=26418

pinter

pinter

2017-11-01 11:00

developer   ~0015375

The hierarchy fines are indeed generated. In Slicer-build I found the SlicerRT hierarchy files, for example vtkSlicerDicomRtImportExportModuleLogicHierarchy.txt. It is very big and contains more than 4000 classes, but the classes that I mention in the issue description are there as well:

vtkSlicerDicomRtImportExportModuleLogic : vtkSlicerModuleLogic ; vtkSlicerDicomRtImportExportModuleLogic.h ; vtkSlicerDicomRtImportExportModuleLogic
vtkSlicerDicomRtImportExportModuleLogic::Superclass = vtkSlicerModuleLogic ; vtkSlicerDicomRtImportExportModuleLogic.h ; vtkSlicerDicomRtImportExportModuleLogic

The class however is still not recognized. I'm on a 5 days old revision, and the same thing happens as what I describe above.

Davide

Davide

2017-11-01 11:09

developer   ~0015376

Hi jc and Csaba, thanks for checking it.

I tested again with last version of Slicer (master at e77630416ec79c7cb6a8145c6286b39a25ebaec1) on my local build (ubuntu 17.10).
When I build the extension I can actually find the hierarchy files, but they are in the Slicer folder build (Slicer-SuperBuild-Debug/Slicer-build).
However if I try in the python console to call a MRML class of my extension, I get still the same error:

import slicer
slicer.vtkMRMLAstroVolumeNode()

I get the error:
AttributeError: 'module' object has no attribute 'vtkMRMLAstroVolumeNode'

Davide

Davide

2017-11-01 11:10

developer   ~0015377

ah you found that as well (:

pinter

pinter

2017-11-01 11:11

developer   ~0015378

Yep, same thing. What we need to figure out I guess is why those seemingly correct hierarchy files are ignored.

Davide

Davide

2017-11-14 05:11

developer   ~0015405

Hi, I just come back from a conference, so I didn't have the time to check this further up to now. I just wanted to check again if you have any news.

pinter

pinter

2017-11-16 10:12

developer   ~0015407

Unfortunately no news, I'm waiting for some pointers from Jc to have an idea where to start.

Davide

Davide

2017-11-16 11:11

developer   ~0015408

Ok, thanks for letting me know. I have to say that I also have no clue where to start (:

Issue History

Date Modified Username Field Change
2017-10-19 11:38 pinter New Issue
2017-10-19 11:38 pinter Status new => assigned
2017-10-19 11:38 pinter Assigned To => jcfr
2017-10-31 06:07 Davide Relationship added has duplicate 0004448
2017-10-31 09:02 Davide Note Added: 0015369
2017-10-31 10:58 pinter Note Added: 0015370
2017-11-01 05:22 Davide Note Added: 0015371
2017-11-01 09:29 pinter Note Added: 0015373
2017-11-01 10:33 jcfr Note Added: 0015374
2017-11-01 11:00 pinter Note Added: 0015375
2017-11-01 11:09 Davide Note Added: 0015376
2017-11-01 11:10 Davide Note Added: 0015377
2017-11-01 11:11 pinter Note Added: 0015378
2017-11-14 05:11 Davide Note Added: 0015405
2017-11-16 10:12 pinter Note Added: 0015407
2017-11-16 11:11 Davide Note Added: 0015408