cookiecutter-data-science
cookiecutter-data-science copied to clipboard
Initialize Git repository on creation
Could we add a post-generate hook to run git init after repository creation? It's not a make-or-break, just a nice convenience.
This is a cool idea. Two potential concerns here:
- Git-centricity. Even though this project uses git+Github as the VCS, we actually don't make assumptions about what version control the data science project will be using.
- Platform compatibility. Even if we're not directly calling out using
subprocessor the like (not to mention assuming a binary calledgitis on the system path), then even using a Python git wrapper I fear we are assuminglibgitis installed.
I'm inclined to give this a discussion label for a while and see if people feel strongly.
That all makes total sense. I think you're right, it's wrong to assume everyone is going to use Git.
It might be nice to give users a choice of which VCS they want to use (or do nothing if no input is provied) and then roll from there. That removes the Git-centricity at the cost of having to handle at least some of the more common options (Git, Mercurial, Subversion, etc.).
To address the platform compatibility issue, we could add some exception handling for missing installations:
# Bad pseudocode
try:
setup_vcs(vcs)
except ExceptionThatNeedsToBeHandled:
print('{0} binary not found. Is {0} installed?'.format(vcs))
What do you think?
For those interested, I'm doing this in my fork of the cookiecutter with the following bash script
I then added a command to the Makefile:
## Push to GitHub repo
push:
git add -A
git commit -m 'Make Git update'
git push
Nice, I like it @ConstantinoSchillebeeckx!
@isms What do you think about a plug-and-play way to initialize a version control system?
@mattayes Cool idea - what do you think an implementation might look like?
Also, just a note here, I've been holding off on optional features while I watch: https://github.com/audreyr/cookiecutter/pull/848
Unfortunately, that issue is currently stalled because the cookiecutter project needs sponsorship.
For things like VCS where we want options and may have fields that are conditional on your choice, it's pretty tough to manage with the current cookiecutter workflow, which doesn't really do branching. I was hoping that the PR referenced above would get pulled in for these kinds of features, but that's not super likely.
The one thing we could look at is doing is conditional files using this kind of syntax: https://github.com/audreyr/cookiecutter/issues/723
We'd need to map out the files that would conditionally added if you chose git as your VCS (e.g., the bash to set up a repo).
Thanks @pjbull for the context. It's too bad audreyr/cookiecutter#848 is held up.
My thought is we provide a general API:
class VCS(object):
...
def initialize(self):
<creates the repo>
Then a (very rough) Git implementation:
import git
class GitVCS(VCS):
def initialize(self, dir):
r = git.Repo.init(repo_dir)
<potentially add initial commit>
We would ask folks which VCS they want (if any), then run the appropriate VCS subclass.