Skip to content

Conversation

@johan-andruejol
Copy link

@fedorov, @jcfr, @thewtex: This is the pull request to add ParameterSerializer and the JsonCpp support.
This PR also adds a test to make sure we can properly serialize/deserialize a CLI with Slicer.

Now, someone can serialize their CLI by doing:

Slicer.exe --launch /path/to/CLI/MyCLI.exe arg1 arg2 ... --serialize /path/to/json/MyCLISerialized.json

and re-run that CLI with the same arguments using only the JSON file:

Slicer.exe --launch /path/to/CLI/MyCLI.exe --deserialize /path/to/json/MyCLISerialized.json

# Install JsonCpp
# -------------------------------------------------------------------------
if(Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT
AND NOT "${JsonCpp_DIR}" STREQUAL "" AND EXISTS "${JsonCpp_DIR}/CMakeCache.txt")
Copy link
Member

@jcfr jcfr Aug 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for later, I created open-source-parsers/jsoncpp#526 to associate components with JsonCpp install rules

@jcfr
Copy link
Member

jcfr commented Aug 31, 2016

Very nice 👍

Beside of a small nitpick in the test, looks good

note that since the PR updates SuperBuild files, you should not expect the CI to be green.

I will also try to build locally and report back


ExternalProject_Add(${proj}
${${proj}_EP_ARGS}
GIT_REPOSITORY "${git_protocol}://github.com/KitwareMedical/jsoncpp.git"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the differences of this from upstream summarized somewhere?

I really don't like the divergence from the main repository.

open-source-parsers/jsoncpp#467 mentioned in KitwareMedical/jsoncpp#2 has been merged long time ago.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

I started to work on contributing some of the changes upstream ... see open-source-parsers/jsoncpp#467 . A fresh look on it would be nice.

@vovythevov Make sure to document different in the commit message. We should also properly name the branch in KitwareMedical/jsoncpp

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcfr I am not clear about your comment. open-source-parsers/jsoncpp#467 is integrated.

Are you saying that you have your comment open-source-parsers/jsoncpp#467 (comment) about bumping up minimum version of cmake addressed too? Is that the unresolved issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcfr I am not clear about your comment. open-source-parsers/jsoncpp#467 is integrated.

Great. This was on oversight. In that case, we should have look at the other commits to also integrate them if relevant.

My other comment was some suggestion to alleviate the concern raised.

We are all set then.

The two other commits are quit minor.

@vovythevov Could you look into using the latest release of jsoncpp ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

Note this https://github.com/open-source-parsers/jsoncpp/tree/0.y.z#a-note-on-backward-compatibility. Should we use 0.y.z branch?

In dcmqi, we use 0.y.z branch (amalgamated version of 0.y.z, to be precise), since I thought C++11 is not supported in Slicer.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcfr, @fedorov:
I think we should use the backward compatible branch.
I'll update the PR with the official repository and the test tweaks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version 0.10.6 should indeed be used

since I thought C++11 is not supported in Slicer.

That is correct. It is currently not supported.

@johan-andruejol johan-andruejol force-pushed the ParameterSerializerSupport branch from 40341a9 to 3fccb7e Compare August 31, 2016 20:43
@johan-andruejol
Copy link
Author

@jcfr, @fedorov: I updated the PR with the json official repository and the tweaks suggested.

@jcfr
Copy link
Member

jcfr commented Aug 31, 2016

Looks good 👍 I am building locally and will report shortly.

@fedorov
Copy link
Member

fedorov commented Sep 1, 2016

Let me know if you haven't tested on Mac and would like me to do that.

@jcfr
Copy link
Member

jcfr commented Sep 1, 2016

@fedorov If you have the time, doing a build enabling option -DSlicer_BUILD_PARAMETERSERIALIZER_SUPPORT:BOOL=1 would be great.

@vovythevov Look like the test if failing on Linux:

$ ctest -R py_nomainwindow_CLISerializationTest -V
[...]
580: Test command: /home/jcfr/Projects/Slicer-Release/python-install/bin/SlicerPython "/home/jcfr/Projects/Slicer/Applications/SlicerApp/Testing/Python/CLISerializationTest.py" "/home/jcfr/Projects/Slicer-Release/Slicer-build/Slicer" "/home/jcfr/Projects/Slicer/Testing/Data/Input" "/home/jcfr/Projects/Slicer-Release/Slicer-build/Testing/Temporary"
580: Test timeout computed to be: 1800
580: Slicer --launch ExecutionModelTour --serialize /home/jcfr/Projects/Slicer-Release/Slicer-build/Testing/Temporary/ExecutionModelTour.json --transform1 '/home/jcfr/Projects/Slicer/Testing/Data/Input/ExecutionModelTourTest.mrml#vtkMRMLLinearTransformNode1' --transform2 '/home/jcfr/Projects/Slicer/Testing/Data/Input/ExecutionModelTourTest.mrml#vtkMRMLLinearTransformNode2' /home/jcfr/Projects/Slicer/Testing/Data/Input/MRHeadResampled.nhdr /home/jcfr/Projects/Slicer/Testing/Data/Input/CTHeadAxial.nhdr --integer 30 --double 30 -f 1.3,2,-14 --files 1.does,2.not,3.matter --string_vector foo,bar,foobar --enumeration Bill --boolean1
580: Slicer --launch ExecutionModelTour --deserialize /home/jcfr/Projects/Slicer-Release/Slicer-build/Testing/Temporary/ExecutionModelTour.json
580: Serialize and deserialize stdout are different: ERROR: In /home/jcfr/Projects/Slicer/Modules/Loadable/Markups/MRML/vtkMRMLMarkupsFiducialStorageNode.cxx, line 467
580: vtkMRMLMarkupsFiducialStorageNode (0x1e0c470): vtkMRMLMarkupsFiducialStorageNode: File name not specified
580: 
580:  != ERROR: In /home/jcfr/Projects/Slicer/Modules/Loadable/Markups/MRML/vtkMRMLMarkupsFiducialStorageNode.cxx, line 467
580: vtkMRMLMarkupsFiducialStorageNode (0xcf4780): vtkMRMLMarkupsFiducialStorageNode: File name not specified
580: 
580: 
580: Error with the execution model tour
1/1 Test #580: py_nomainwindow_CLISerializationTest ...***Failed    0.49 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.52 sec

The following tests FAILED:
    580 - py_nomainwindow_CLISerializationTest (Failed)
Errors while running CTest

@jcfr
Copy link
Member

jcfr commented Sep 1, 2016

@vovythevov When comparing the output, it is normal to have different memory address ... you should make the comparison more robust.

@jcfr
Copy link
Member

jcfr commented Sep 1, 2016

Adding , verbose=True to the run calls, look like this command is failing:

./Slicer --launch ExecutionModelTour --serialize /home/jcfr/Projects/Slicer-Release/Slicer-build/Testing/Temporary/ExecutionModelTour.json \
  --transform1 '/home/jcfr/Projects/Slicer/Testing/Data/Input/ExecutionModelTourTest.mrml#vtkMRMLLinearTransformNode1' \
  --transform2 '/home/jcfr/Projects/Slicer/Testing/Data/Input/ExecutionModelTourTest.mrml#vtkMRMLLinearTransformNode2' \
  /home/jcfr/Projects/Slicer/Testing/Data/Input/MRHeadResampled.nhdr \
  /home/jcfr/Projects/Slicer/Testing/Data/Input/CTHeadAxial.nhdr \
  --integer 30 --double 30 -f 1.3,2,-14 --files 1.does,2.not,3.matter \
  --string_vector foo,bar,foobar \
  --enumeration Bill \
  --boolean1

The error is this one:

Input file = 
Files size = 3
Output file = 
Boolean 1 = 1
Boolean 2 = 0
Boolean 3 = 0
Transform1 filename: /home/jcfr/Projects/Slicer/Testing/Data/Input/ExecutionModelTourTest.mrml
Transform1 ID: vtkMRMLLinearTransformNode1
Transform2 filename: /home/jcfr/Projects/Slicer/Testing/Data/Input/ExecutionModelTourTest.mrml
Transform2 ID: vtkMRMLLinearTransformNode2
Have an input seed list of size 0
ERROR: In /home/jcfr/Projects/Slicer/Modules/Loadable/Markups/MRML/vtkMRMLMarkupsFiducialStorageNode.cxx, line 467
vtkMRMLMarkupsFiducialStorageNode (0x1c3e480): vtkMRMLMarkupsFiducialStorageNode: File name not specified

@johan-andruejol
Copy link
Author

@jcfr: This actually caught an error, I did not see that message on
Windows, otherwise I would not have done that comparison.

Did you build in Debug mode ? I am thinking that this is a Debug output
from the fiducial node that I did not see because my build is Release.
I'll strengthen the test tomorrow by making running the CLI with parameters
that output something and then comparing them.

On Wednesday, August 31, 2016, Jean-Christophe Fillion-Robin <
notifications@github.com> wrote:

@vovythevov https://github.com/vovythevov When comparing the output, it
is normal to have different memory address ... you should make the
comparison more robust.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
Slicer/Slicer#576 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAaDkpJJxX80Uk8I_sFRvCW-JlA6j1Abks5qliBugaJpZM4Jx6Gz
.

Sent from Gmail Mobile

@jcfr
Copy link
Member

jcfr commented Sep 1, 2016

Did you build in Debug mode ?

It is

Debug output from the fiducial node

The error is always reported

No particular rush, let me know what you find out later tomorrow.

@fedorov
Copy link
Member

fedorov commented Sep 1, 2016

No build errors on mac 10.10.5

@fedorov
Copy link
Member

fedorov commented Sep 1, 2016

While trying to compile an external code against SlicerExecutionModel built from this branch, I ran into the following error:

In file included from /Users/fedorov/github/Iowa2DICOM/SingleTimepoint/EncodeMeasurementsSR.cxx:37:
/Users/fedorov/local/builds/Iowa2DICOM/SingleTimepoint/EncodeMeasurementsSRCLP.h:299:26: error: expected ';' after
      top level declarator
"                                       \"Default\" : \"\\"1\\"\",\n"
                                                           ^
                                                           ;
1 warning and 1 error generated.

I believe this may be related to the changes introduced, since this code used to compile with the older Slicer. The code I tried to compile is here: https://github.com/qiicr/Iowa2DICOM

@johan-andruejol
Copy link
Author

@fedorov: Thanks, this is really helpful ! I'll look into this.

@johan-andruejol
Copy link
Author

@jcfr, @fedorov: Thanks for you help guys ! Your feedback helped to dig some bugs so that was really good. I addressed them in the SlicerExecutionModel PR# 77 (Slicer/SlicerExecutionModel#77).

As soon as this is merged, I'll update this PR with the new hash and ping you.

CMakeLists.txt Outdated
"Slicer_BUILD_ITKPython" OFF)
mark_as_superbuild(Slicer_INSTALL_ITKPython)

option(Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT "Build Slicer with parameter serializer support" OFF)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it OFF by default?

This means we won't have jsoncpp in the nightly, and we will need it in the default configuration for some of the things done in the Segmentations module (at least).

Cc: @cpinter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a first round of nightly with the option OFF, we will turn it ON

Copy link
Contributor

@lassoan lassoan Sep 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that jsoncpp is shipped with VTK as well. In the Slicer core we should rather depend on VTK only (Slicer may be built using CLI support disabled), unless there is a strong reason against it.
Is the jsoncpp version in VTK will be synchronized with jsconcpp in SlicerExecutionModel? Or maybe we can build Slicer's VTK with an external jsoncpp (provided by Slicer superbuild).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lassoan: @cpinter raised this issue earlier.

As @jcfr explained in his response at the time: "As of today, VTK dependencies are internal and not intended to be used externally."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcfr: 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly the SlicerExecutionModel should not depend on VTK. We are talking about how Slicer modules will access jsoncpp and how to make sure the same jsoncpp version is used by SlicerExecutionModel, VTK, and Slicer modules. One solution could be that Slicer superbuild builds jsoncpp and passes it to both SlicerExecutionModel and VTK.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Andras, yes I agree. If there is something to be improved it is factoring out jsoncpp from VTK.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VTK can already accept an external jsoncpp (VTK_USE_SYSTEM_JSONCPP option).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Then they should definitely use the same jsoncpp build.

@johan-andruejol johan-andruejol force-pushed the ParameterSerializerSupport branch from 3fccb7e to 6ca130e Compare September 2, 2016 19:20
@johan-andruejol
Copy link
Author

johan-andruejol commented Sep 2, 2016

@fedorov, @jcfr: Pushed the updated branch.
With:

@jcfr
Copy link
Member

jcfr commented Sep 2, 2016

Thanks 👍

Locally building now.

@jcfr
Copy link
Member

jcfr commented Sep 2, 2016

This is a release build / Ubuntu 15.10

580: Test command: /home/jcfr/Projects/Slicer-Release/python-install/bin/SlicerPython "/home/jcfr/Projects/Slicer/Applications/SlicerApp/Testing/Python/CLISerializationTest.py" "/home/jcfr/Projects/Slicer-Release/Slicer-build/Slicer" "/home/jcfr/Projects/Slicer/Testing/Data/Input" "/home/jcfr/Projects/Slicer-Release/Slicer-build/Testing/Temporary"
580: Test timeout computed to be: 1800
580: STDERR: terminate called after throwing an instance of 'Json::LogicError'
580:   what():  Type is not convertible to string
580: error: [/home/jcfr/Projects/Slicer-Release/Slicer-build/lib/Slicer-4.5/cli-modules/././ExecutionModelTour] exit abnormally - Report the problem.
580: 
580: Slicer --launch ExecutionModelTour --serialize /home/jcfr/Projects/Slicer-Release/Slicer-build/Testing/Temporary/ExecutionModelTourSerialized.json --integer 30 --double 30 -f 1.3,2,-14 --files 1.does,2.not,3.matter --string_vector foo,bar,foobar --enumeration Bill --boolean1 --seed 1.0,0.0,-1.0 --seedsOutFile /home/jcfr/Projects/Slicer-Release/Slicer-build/Testing/Temporary/SeedsSerialized.acsv --transform1 '/home/jcfr/Projects/Slicer/Testing/Data/Input/ExecutionModelTourTest.mrml#vtkMRMLLinearTransformNode1' --transform2 '/home/jcfr/Projects/Slicer/Testing/Data/Input/ExecutionModelTourTest.mrml#vtkMRMLLinearTransformNode2' /home/jcfr/Projects/Slicer/Testing/Data/Input/MRHeadResampled.nhdr /home/jcfr/Projects/Slicer/Testing/Data/Input/CTHeadAxial.nhdr
580: Slicer --launch ExecutionModelTour --deserialize /home/jcfr/Projects/Slicer-Release/Slicer-build/Testing/Temporary/ExecutionModelTourSerialized.json --seedsOutFile /home/jcfr/Projects/Slicer-Release/Slicer-build/Testing/Temporary/SeedsDeSerialized.acsv
580: Problem while deserializing the CLI: 
1/1 Test #580: py_nomainwindow_CLISerializationTest ...***Failed    0.55 sec

@jcfr
Copy link
Member

jcfr commented Sep 2, 2016

$ ./Slicer --launch ExecutionModelTour --serialize /home/jcfr/Projects/Slicer-Release/Slicer-build/Testing/Temporary/ExecutionModelTourSerialized.json --integer 30 --double 30 -f 1.3,2,-14 --files 1.does,2.not,3.matter --string_vector foo,bar,foobar --enumeration Bill --boolean1 --seed 1.0,0.0,-1.0 --seedsOutFile /home/jcfr/Projects/Slicer-Release/Slicer-build/Testing/Temporary/SeedsSerialized.acsv --transform1 '/home/jcfr/Projects/Slicer/Testing/Data/Input/ExecutionModelTourTest.mrml#vtkMRMLLinearTransformNode1' --transform2 '/home/jcfr/Projects/Slicer/Testing/Data/Input/ExecutionModelTourTest.mrml#vtkMRMLLinearTransformNode2' /home/jcfr/Projects/Slicer/Testing/Data/Input/MRHeadResampled.nhdr /home/jcfr/Projects/Slicer/Testing/Data/Input/CTHeadAxial.nhdr
Input file = 
Files size = 3
Output file = 
Boolean 1 = 1
Boolean 2 = 0
Boolean 3 = 0
Transform1 filename: /home/jcfr/Projects/Slicer/Testing/Data/Input/ExecutionModelTourTest.mrml
Transform1 ID: vtkMRMLLinearTransformNode1
Transform2 filename: /home/jcfr/Projects/Slicer/Testing/Data/Input/ExecutionModelTourTest.mrml
Transform2 ID: vtkMRMLLinearTransformNode2
Have an input seed list of size 1
0   1   0   -1
Copying seed list to output file list: 1, 0, -1
Warning: In /home/jcfr/Projects/Slicer/Modules/Loadable/Markups/MRML/vtkMRMLMarkupsNode.cxx, line 1121
vtkMRMLMarkupsFiducialNode (0xd9e740): GetNthMarkupLabelForStorage: no storage node to do the conversion!

Warning: In /home/jcfr/Projects/Slicer/Modules/Loadable/Markups/MRML/vtkMRMLMarkupsNode.cxx, line 1164
vtkMRMLMarkupsFiducialNode (0xd9e740): GetNthMarkupDescriptionForStorage: no storage node to do the conversion!

vtkDebugLeaks has found no leaks.

$ ./Slicer --launch ExecutionModelTour --deserialize /home/jcfr/Projects/Slicer-Release/Slicer-build/Testing/Temporary/ExecutionModelTourSerialized.json --seedsOutFile /home/jcfr/Projects/Slicer-Release/Slicer-build/Testing/Temporary/SeedsDeSerialized.acsvterminate called after throwing an instance of 'Json::LogicError'
  what():  Type is not convertible to string
error: [/home/jcfr/Projects/Slicer-Release/Slicer-build/lib/Slicer-4.5/cli-modules/././ExecutionModelTour] exit abnormally - Report the problem.

@jcfr
Copy link
Member

jcfr commented Sep 2, 2016

And the corresponding Json:

$ cat /home/jcfr/Projects/Slicer-Release/Slicer-build/Testing/Temporary/ExecutionModelTourSerialized.json
{
    "Parameters" : 
    {
        "Boolean Parameters" : 
        {
            "boolean1" : true,
            "boolean2" : false,
            "boolean3" : false
        },
        "Enumeration Parameters" : 
        {
            "stringChoice" : "Bill"
        },
        "File, Directory and Image Parameters" : 
        {
            "directory1" : "",
            "file1" : "",
            "files" : [ "1.does", "2.not", "3.matter" ],
            "image1" : "",
            "image2" : "",
            "outputFile1" : "",
            "seed" : 
            [
                [ 1, 0, -1 ]
            ],
            "seedsFile" : "",
            "seedsOutFile" : "/home/jcfr/Projects/Slicer-Release/Slicer-build/Testing/Temporary/SeedsSerialized.acsv",
            "transform1" : "/home/jcfr/Projects/Slicer/Testing/Data/Input/ExecutionModelTourTest.mrml#vtkMRMLLinearTransformNode1",
            "transform2" : "/home/jcfr/Projects/Slicer/Testing/Data/Input/ExecutionModelTourTest.mrml#vtkMRMLLinearTransformNode2"
        },
        "Generic Tables" : 
        {
            "inputDT" : "",
            "outputDT" : ""
        },
        "Index Parameters" : 
        {
            "arg0" : "/home/jcfr/Projects/Slicer/Testing/Data/Input/MRHeadResampled.nhdr",
            "arg1" : "/home/jcfr/Projects/Slicer/Testing/Data/Input/CTHeadAxial.nhdr"
        },
        "Measurements" : 
        {
            "inputFA" : "",
            "outputFA" : ""
        },
        "Regions of interest" : 
        {
            "regions" : []
        },
        "Scalar Parameters" : 
        {
            "doubleVariable" : 30,
            "integerVariable" : 30
        },
        "Simple return types" : 
        {
            "abooleanreturn" : false,
            "adoublereturn" : 14,
            "afloatreturn" : 7,
            "anintegerreturn" : 5,
            "anintegervectorreturn" : [],
            "astringchoicereturn" : "Bill",
            "astringreturn" : "Hello"
        },
        "Vector Parameters" : 
        {
            "floatVector" : [ 1.2999999523162842, 2, -14 ],
            "stringVector" : [ "foo", "bar", "foobar" ]
        }
    }
}

@jcfr
Copy link
Member

jcfr commented Sep 2, 2016

Good news.

The issue was that the code wasn't regenerated ... forcing a clean build ensure the test pass

@jcfr
Copy link
Member

jcfr commented Sep 2, 2016

side note, there are few warnings:

In file included from /home/jcfr/Projects/Slicer-Release/Slicer-build/Modules/CLI/ExecutionModelTour/ExecutionModelTourCLP.h:16:0,
                 from /home/jcfr/Projects/Slicer/Modules/CLI/ExecutionModelTour/ExecutionModelTour.cxx:1:
/home/jcfr/Projects/Slicer-Release/SlicerExecutionModel/ModuleDescriptionParser/JsonSerializationUtilities.h:23:6: warning: ‘void {anonymous}::ReadJsonParameter(const Json::Value&, int&)’ defined but not used [-Wunused-function]
 void ReadJsonParameter( const Json::Value & parameter, int & value )
      ^
/home/jcfr/Projects/Slicer-Release/SlicerExecutionModel/ModuleDescriptionParser/JsonSerializationUtilities.h:27:6: warning: ‘void {anonymous}::ReadJsonParameter(const Json::Value&, unsigned int&)’ defined but not used [-Wunused-function]
 void ReadJsonParameter( const Json::Value & parameter, unsigned int & value )
      ^
/home/jcfr/Projects/Slicer-Release/SlicerExecutionModel/ModuleDescriptionParser/JsonSerializationUtilities.h:31:6: warning: ‘void {anonymous}::ReadJsonParameter(const Json::Value&, float&)’ defined but not used [-Wunused-function]
 void ReadJsonParameter( const Json::Value & parameter, float & value )
      ^
/home/jcfr/Projects/Slicer-Release/SlicerExecutionModel/ModuleDescriptionParser/JsonSerializationUtilities.h:35:6: warning: ‘void {anonymous}::ReadJsonParameter(const Json::Value&, double&)’ defined but not used [-Wunused-function]
 void ReadJsonParameter( const Json::Value & parameter, double & value )
      ^
/home/jcfr/Projects/Slicer-Release/SlicerExecutionModel/ModuleDescriptionParser/JsonSerializationUtilities.h:39:6: warning: ‘void {anonymous}::ReadJsonParameter(const Json::Value&, bool&)’ defined but not used [-Wunused-function]
 void ReadJsonParameter( const Json::Value & parameter, bool & value )
      ^
/home/jcfr/Projects/Slicer-Release/SlicerExecutionModel/ModuleDescriptionParser/JsonSerializationUtilities.h:43:6: warning: ‘void {anonymous}::ReadJsonParameter(const Json::Value&, std::__cxx11::string&)’ defined but not used [-Wunused-function]
 void Re

@jcfr
Copy link
Member

jcfr commented Sep 2, 2016

It turns out that GENERATECLP macro create a custom command depending on ${GENERATECLP_EXE} but in our case the variable GENERATECLP_EXE is to GenerateCLPLauncher and not GenerateCLP, this explains why the new parsing code was not regenerated ...

@jcfr
Copy link
Member

jcfr commented Sep 2, 2016

Investigating further with @vovythevov , it turns out that within SlicerExecutionModel, modifiying the source GenerateCLP.cxx doesn't trigger the rebuild of GenerateCLPLauncher:

$ touch ../SlicerExecutionModel/GenerateCLP/GenerateCLP.cxx 
jcfr@CerroTorre:SlicerExecutionModel-build $ touch ../SlicerExecutionModel/GenerateCLP/GenerateCLP.cxx 
jcfr@CerroTorre:SlicerExecutionModel-build $ make
[ 75%] Built target ModuleDescriptionParser
Scanning dependencies of target GenerateCLP
[ 81%] Building CXX object GenerateCLP/CMakeFiles/GenerateCLP.dir/GenerateCLP.cxx.o
[ 87%] Linking CXX executable bin/GenerateCLP
[ 87%] Built target GenerateCLP

$ make
[ 75%] Built target ModuleDescriptionParser
Scanning dependencies of target GenerateCLP
[ 81%] Building CXX object GenerateCLP/CMakeFiles/GenerateCLP.dir/GenerateCLP.cxx.o
[ 87%] Linking CXX executable bin/GenerateCLP
[ 87%] Built target GenerateCLP
[100%] Built target GenerateCLPLauncher

@johan-andruejol
Copy link
Author

@jcfr: It's ugly, but it works:

add_custom_command(TARGET GenerateCLP POST_BUILD
  COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/GenerateCLPLauncher.c
  COMMENT "Force GenerateCLPLauncher to rebuild after GenerateCLP was modified"
  )

$ git shortlog --no-merges 26a62a0b..9a74e80a
Jean-Christophe Fillion-Robin (7):
      STYLE: CMakeLists: Consistently requires version 2.8.6
      STYLE: CMakeLists: Simplify code removing unneeded setting of CMP0016 to NEW
      STYLE: CMakeLists: Simplify code removing unneeded setting of CMP0017
      STYLE: CMakeLists: Simplify buildsystem using FindThreads module
      STYLE: CMakeLists: Remove obsolete option ModuleDescriptionParser_USE_PYTHON
      STYLE: CMakeLists: Finding of threading library is not needed anymore
      JsonSerializationUtilities: Remove unused method

Johan Andruejol (10):
      ENH: Improve JsonCpp support for SlicerExecutionModel
      ENH: Add JsonCpp path to the GenerateCLP launcher
      ENH: Do not pass the JsonCpp_DIR to the testing directly
      ENH: Allow CLI to deserialize without the required arguments
      ENH: Improve support for empty arrays
      ENH: ParameterSerializer: Use the longflag in priority
      ENH: ParameterSerializer: Fix multiple parameters handling for deserialization
      STYLE: GenerateCLP: Factorize out the CMakeLists of the testing CLIs
      ENH: ParameterSerializer: Improve escaping of the JSONModuleDescription
      ENH: GenerateCLP: Force GenerateCLPLauncher rebuild on GenerateCLP change
This allows Slicer to build JsonCpp. This is part of the integration of the
parameter serializer effort.
By default, the JsonCpp support is disabled.
With the paramater serializer support, one can now serialize and
deserialize CLIs with the command line. The python test
CLISerializationTest is added to make sure it works as expected.
@johan-andruejol johan-andruejol force-pushed the ParameterSerializerSupport branch from 6ca130e to 2dc535c Compare September 2, 2016 22:01
@johan-andruejol
Copy link
Author

@jcfr, @fedorov: Latest update with all the recent changes in SlicerExecutionModel:

@johan-andruejol
Copy link
Author

@jcfr, @fedorov, @lassoan: In the last commit I made VTK use the same JsonCpp as the SlicerExecutionModel and the ParameterSerializer if Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT is on.

@jcfr
Copy link
Member

jcfr commented Sep 7, 2016

Nice 👍

Could you also confirm that https://github.com/qiicr/Iowa2DICOM build ?

@jcfr
Copy link
Member

jcfr commented Sep 7, 2016

Re-building after:

  • Removing Jsoncpp* folders
  • Removing SlicerExecutionModel folders
  • Removing ParameterSerializer folders

fails with

make[6]: *** No rule to make target '/home/jcfr/Projects/Slicer-Release/JsonCpp-build/src/lib_json/Release/jsoncpp.so', needed by 'ModuleDescriptionParser/bin/libModuleDescriptionParser.so'.  Stop.

It turns out that on single config system the correct path is:

/home/jcfr/Projects/Slicer-Release/JsonCpp-build/src/lib_json/jsoncpp.so

Note that Release is not present

else()
set(lib_ext "so")
endif()
set(${proj}_LIBRARY ${${proj}_DIR}/src/lib_json/$<CONFIG>/jsoncpp.${lib_ext})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider this instead:

set(${proj}_LIBRARY ${${proj}_DIR}/src/lib_json/${CMAKE_CFG_INTDIR}/jsoncpp.${lib_ext})

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefix of the lib is also incorrect on unix, this patch seems to work:

diff --git a/SuperBuild/External_JsonCpp.cmake b/SuperBuild/External_JsonCpp.cmake
index 724f01d..f3a53ea 100644
--- a/SuperBuild/External_JsonCpp.cmake
+++ b/SuperBuild/External_JsonCpp.cmake
@@ -60,14 +60,17 @@ if(NOT DEFINED ${proj}_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
   set(${proj}_DIR ${CMAKE_BINARY_DIR}/${proj}-build)
   set(${proj}_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj})
   set(${proj}_INCLUDE_DIR ${${proj}_SOURCE_DIR}/include)
-  if (WIN32)
+  if(WIN32)
+    set(lib_prefix "")
     set(lib_ext "lib")
   elseif(APPLE)
+    set(lib_prefix "lib")
     set(lib_ext "dylib")
   else()
+    set(lib_prefix "lib")
     set(lib_ext "so")
   endif()
-  set(${proj}_LIBRARY ${${proj}_DIR}/src/lib_json/$<CONFIG>/jsoncpp.${lib_ext})
+  set(${proj}_LIBRARY ${${proj}_DIR}/src/lib_json/${CMAKE_CFG_INTDIR}/${lib_prefix}jsoncpp.${lib_ext})

   #-----------------------------------------------------------------------------
   # Launcher setting specific to build tree

For consistency the JsonCpp variables passed to the projects were changed
to JsonCpp_INCLUDE_DIR and JsonCpp_LIBRARY.

$ git shortlog 9a74e80ac..8692b09b6 --no-merges
Johan Andruejol (1):
      ENH: Uniformize the use of JsonCpp with VTK
@johan-andruejol johan-andruejol force-pushed the ParameterSerializerSupport branch from 9bcc554 to a8aff8b Compare September 7, 2016 23:00
@johan-andruejol
Copy link
Author

@jcfr: Thanks for the (very quick) patch !

I can confirm that the error that @fedorov reported Slicer/Slicer#576 (comment) is no longer present.

Howver, the build fails on my machine for unrelated linking issues, because I don't have the xml2 and z libraries in my path on windows. See: https://github.com/QIICR/Iowa2DICOM/blob/master/ConvertSegmentations/CMakeLists.txt#L7

The error:

1>------ Build started: Project: CIELabToRGBConvertLib, Configuration: Release x64 ------
2>------ Build started: Project: DCMTKSeriesReadImageWriteLib, Configuration: Release x64 ------
3>------ Build started: Project: EncodeMeasurementsSRLib, Configuration: Release x64 ------
4>------ Build started: Project: EncodeSEGLib, Configuration: Release x64 ------
5>------ Build started: Project: SEG2NRRDLib, Configuration: Release x64 ------
1>LINK : fatal error LNK1181: cannot open input file 'xml2.lib'
4>  EncodeSEG.cxx
3>LINK : fatal error LNK1181: cannot open input file 'xml2.lib'
2>LINK : fatal error LNK1181: cannot open input file 'xml2.lib'
6>------ Build started: Project: EncodeMeasurementsSR, Configuration
...

@jcfr
Copy link
Member

jcfr commented Sep 7, 2016

After confirming it compiles and packages on MacOSX, LGTM

@fedorov
Copy link
Member

fedorov commented Sep 8, 2016

the build fails on my machine for unrelated linking issues, because I don't have the xml2 and z libraries in my path on windows. See: https://github.com/QIICR/Iowa2DICOM/blob/master/ConvertSegmentations/CMakeLists.txt#L7

Have you tried commenting out those libs? It may or may not help - I have never tried to build that code on windows, and it won't be maintained, since the functionality migrates to dcmqi.

Thanks for resolving these remaining issues!

@jcfr
Copy link
Member

jcfr commented Sep 8, 2016

After confirming it compiles and packages on MacOSX, LGTM

@vovythevov

I confirm that MacOSX packaging works as expected.

Since configuring VTK with jsoncpp is not used/tested, it is only used in IO/Parallel and IO/GeoJSON which are currently disabled in Slicer. Revert the change to External_VTK7.cmake and integrate (with the serializer disabled).

Tomorrow, if dashboard looks reasonable, consider doing an other commit that switch it to ON.

Thanks

@johan-andruejol
Copy link
Author

johan-andruejol commented Sep 8, 2016

Integrated in r25335, r25336 and r25337

@jcfr
Copy link
Member

jcfr commented Sep 8, 2016

Very nice 👍

Note: I just started to rebuild the SlicerDocker images

@cpinter
Copy link
Member

cpinter commented Sep 8, 2016

Great, thank you! I'll try it right away!

@johan-andruejol
Copy link
Author

@cpinter: Note that it's not on by default for now, make sure to turn Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT on.

@jcfr
Copy link
Member

jcfr commented Sep 8, 2016

Great, thank you! I'll try it right away!

The plan is to enable Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT by default tomorrow

The parameter serializer support allows CLI to serialize/deserialize their
input from and to JSON file. For example, with the GaussianBlurImageFilter
one could do the following:
# Serialize, i.e. save the parameters to JSON:
./Slicer --lauunch GaussianBlurImageFilter MRHead.nrrd BlurredHead.nrrd
 --serialize GaussianBlurParameters.json

# Deserialize, i.e. load the parameters from JSON :
./Slicer --launch GaussianBlurImageFilter
 --deserialize GaussianBlurParameters.json

This follows the changes made in r25335, r25336 and r25337.
@johan-andruejol
Copy link
Author

@jcfr: I pushed a commit to turn on the parameter serializer by default: Slicer/Slicer@a095ced.
As far as I can tell, it looks like the Nightly are fine.

@jcfr
Copy link
Member

jcfr commented Sep 9, 2016

LGTM 👍

@johan-andruejol
Copy link
Author

@jcfr: Integrated with r25340

@thewtex
Copy link
Member

thewtex commented Sep 9, 2016

Well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants