taichi icon indicating copy to clipboard operation
taichi copied to clipboard

Put examples into a new repo and include it as a submodule

Open neozhaoliang opened this issue 3 years ago • 8 comments

Hi, the current examples folder is hidden far from the top directory, shall we make it visible as a top-level directory? @feisuzhu WDYT?

neozhaoliang avatar Jul 19 '22 08:07 neozhaoliang

Maybe an easier solution is to add a soft link at the top level in the existing repo?

yuanming-hu avatar Jul 26 '22 13:07 yuanming-hu

Maybe an easier solution is to add a soft link at the top level in the existing repo?

Symlinks can be problematic on Windows. Git does not use symlinks unless configured core.symlinks=true.

I'm proposing below change:

  1. Spin off examples directory to a dedicated repo.
  2. Put examples repo as submodule at top level in taichi repo.
  3. Put a symlink at original location points to top-level examples directory.

This solution

  1. Improved examples visibility as intended.
  2. release-tests-runner now can treat examples the same as others (DiffTaichi/QuanTaichi/etc.).
  3. The symlink serves as an indicator for 'examples actually should be here'.(IIRC it's @ailzhang 's wish?)
  4. URLs in docs still have to be changed since Github will not chase symlinks.

feisuzhu avatar Jul 27 '22 10:07 feisuzhu

My 2 cents: The biggest concern I have with submodules is that it somewhat complicates the dependency management. The repo separation would increase the likelihood for these two repos to go out of sync, and for devs to be dealing with problems like "Taichi@commit-X cannot support TaichiExamples@commit-Y". From my past experience, submodules are mostly useful when used as a dependency, i.e. we have a necessity to pin this module at a specific version, and roll it up from time to time.

That said, we are maintaining several repos this way, so I don't hold strong opinions on this. But I am curious about why we cannot move examples/ to the top level?

k-ye avatar Jul 28 '22 13:07 k-ye

I would also vote for making examples a top-level directory.

neozhaoliang avatar Jul 28 '22 14:07 neozhaoliang

But I am curious about why we cannot move examples/ to the top level?

I feel like one major reason is that we don't wish to invalidate existing links to python/taichi/examples/simulation/X.py :-)

yuanming-hu avatar Jul 28 '22 15:07 yuanming-hu

But I am curious about why we cannot move examples/ to the top level?

I feel like one major reason is that we don't wish to invalidate existing links to python/taichi/examples/simulation/X.py :-)

Hmm, I see. From @feisuzhu 's answer, URLs still has to be changed, though... And I share the same worry about symlink supports in Git.

k-ye avatar Jul 28 '22 15:07 k-ye

To give a bit context on why we moved examples from top level into python dir: When we had examples in top level, everytime you build taichi it copies the examples folder into python/taichi folder so you'll have two copies. Developers get confused where these examples come from, and they'll have to be aware that changing the examples in top level in develop mode won't update the real script getting called in ti example.

I feel like there might be a way that by changing setup.py we can keep examples in top level, but avoid the explicit copy into python/taichi folder when packaging. @feisuzhu wdyt?

W.r.t invalid links, IMHO we can't avoid it if we want examples in top level and not using symlinks. Probably it's good to start using permanent links for code pointers in the future?

ailzhang avatar Jul 28 '22 16:07 ailzhang

W.r.t invalid links, IMHO we can't avoid it if we want examples in top level and not using symlinks. Probably it's good to start using permanent links for code pointers in the future?

I feel like we have to update the links anyway. Otherwise it's broken links vs stale links :joy:

k-ye avatar Jul 29 '22 05:07 k-ye