Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add examples to the template. #46

Conversation

jhlegarreta
Copy link
Member

@jhlegarreta jhlegarreta commented Dec 23, 2018

Add a hint to foster writing examples for the contributed classes.

Resolves #34.

Add a hint to foster writing examples for the contributed classes.
@jhlegarreta
Copy link
Member Author

jhlegarreta commented Dec 23, 2018

A few comments:

  • Not sure whether the folder will get contents in most cases. If you feel that the risk of leaving the folder empty is greater than the benefit of having the template, discard the PR. Another option would be to just leave the call to itk_module_examples() in the CMakeLists.txt.
  • Not sure about the right place to set the itk_module_examples() call in the CMakeLists.txt (i.e. building inside ITK vs. as a remote). I just took this as a recent example.
  • Not sure about any naming convention we should be using for the examples.
  • As opposed to the tests, the examples may become involved, so I preferred not do write any code in them, and just write some instructions. Feel free to modify.
  • The same applies to the examples/CMakeLists.txt dependencies.

@jhlegarreta
Copy link
Member Author

jhlegarreta commented Dec 24, 2018

I've further thinking about this. In absence of any elaborated examples, a fairly easy solution, and a nice and much needed addition could be to write a performance benchmark. Considering the way the ITKPerformanceBenchmarking is structured, an example reporting the performance could fit into that framework. Otherwise, if we think that performance benchmarks should be made more explicit and deserve a separate module, we may need to further think how we can propose this. In either case, I'd be happy to work on that.

Also, the example pointed in #34 embeds the example binary data within the same folder, instead of using the test/Input. May be another folder should be created within the examples folder to host the data. Locating binary data in test/Input that is not actually used by tests may be misleading, even if it allows to keep all data in one place. Suggestions are welcome.

Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

I think that adding the example to the module template is useful.


find_package(ITK REQUIRED
COMPONENTS
ITKImageIO
Copy link
Member

Choose a reason for hiding this comment

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

This is problematic if the example is built as part of ITK. See this.

Copy link
Member

Choose a reason for hiding this comment

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

@fbudin69500 do you think we should add this to the module template?

Choose a reason for hiding this comment

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

This seems difficult to address cleanly for now as the template would have to explicitly instantiate certain IOs and it is not possible to know ahead of time which IOs should be instantiated. There could be hints in the CMakeLists.txt with commented out lines of code with the IO names that the developer could either uncomment or remove, but that doesn't seem ideal. @dzenanz : Was an issue created in the issue tracker for that Meta module IO issue?

Copy link
Member

Choose a reason for hiding this comment

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

I just created an issue: InsightSoftwareConsortium/ITK#359

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

PR #163.

@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.10.2)
project({{ cookiecutter.module_name }}Examples)
Copy link
Member Author

Choose a reason for hiding this comment

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

Do we need to add CXX or does this help CMake somehow exclude any Python example file that is added along?

Copy link
Member

Choose a reason for hiding this comment

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

Python examples don't need to be built -- the default include CXX -> this is good.

Copy link
Member Author

Choose a reason for hiding this comment

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

🤔 So do we need to use

project({{ cookiecutter.module_name }}Examples CXX)

explicitly then?

@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.10.2)
project({{ cookiecutter.module_name }}Examples)
Copy link
Member Author

Choose a reason for hiding this comment

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

Also, do we need to enable and add tests for the examples?

Copy link
Member

Choose a reason for hiding this comment

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

If the example does something, we can use it to write a test, see this. Having test data in there is harder to properly support, that's why I removed it.

@thewtex
Copy link
Member

thewtex commented Jan 3, 2019

Awesome @jhlegarreta ! This is a great contribution. Examples are essential.

For the testing data, perhaps we can use the CMake FetchContent module? It requires CMake 3.11, but we could just add cmake_minimum_required(VERSION 3.11) in examples/CMakeLists.txt only.

@jhlegarreta
Copy link
Member Author

Awesome @jhlegarreta ! This is a great contribution. Examples are essential.

For the testing data, perhaps we can use the CMake FetchContent module? It requires CMake 3.11, but we could just add cmake_minimum_required(VERSION 3.11) in examples/CMakeLists.txt only.

🤔 Not sure how the CMake FetchContent module plays a role here or how does it fit with having tests for the examples.

@thewtex
Copy link
Member

thewtex commented Jan 4, 2019

Not sure how the CMake FetchContent module plays a role here or how does it fit with having tests for the examples.

FetchContent can be used inside an example so the example can be copied outside the module as a starting point for a new independent application. Configuration with FetchContent is much simpler than CMake ExternalData, so the example can remain simple.

@hjmjohnson
Copy link
Member

@jhlegarreta This is more than a year out of date. Can it be abandoned?

@jhlegarreta
Copy link
Member Author

You're right Hans, it's been a while. I have not found the time to investigate more.

IMHO, having the ITKModuleTemplate a mechanism to make room for examples is useful, since we will want remotes to be as complete as possible. I do not foresee that I will have time to pick this up any time soon, so if you feel like it should be abandoned, go ahead.

If at some point someone has the cycles to tackle this, unless we delete the branch, they will be able to re-open it or to get some inspiration from this.

@hjmjohnson
Copy link
Member

@dzenanz Can you please re-address your concerns with this issue? If it is an incremental improvement with known deficencies, could it be merged? If not, let's make it into an issue and close this PR.

@dzenanz
Copy link
Member

dzenanz commented Feb 21, 2020

It is not a simple fix. I updated the issue #34.

@dzenanz dzenanz closed this Feb 21, 2020
@dzenanz
Copy link
Member

dzenanz commented Jul 1, 2024

This PR was fairly close to working. Applying solution from https://github.com/InsightSoftwareConsortium/ITKMontage/blob/v0.8.2/examples/CMakeLists.txt#L4-L22, along with a general update should make it work. Jon, can you revive it?

@jhlegarreta
Copy link
Member Author

This PR was fairly close to working. Applying solution from https://github.com/InsightSoftwareConsortium/ITKMontage/blob/v0.8.2/examples/CMakeLists.txt#L4-L22, along with a general update should make it work. Jon, can you revive it?

PR #163.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add examples folder content to the module template
5 participants