Closed hxin closed 3 years ago
It seems that the dictionary parameter cannot be passed via the command line...?
so there are a few approach for this I guess...
this is actually a new feature which was implemented in May 2020, it was planned to be in the v2.0 release but yet to come... this will basically allow providing a .json file and which you can create by adding something like {{ cookiecutter | jsonify }}
we can use what is currently available, --replay
option, which will read the json, but this might be a be tricky to implement. see 1.1.89 on page 21
we can use the python version of the cookie-cutter, which accept the dictionary parameter. Something like below:
from cookiecutter.main import cookiecutter
cookiecutter('/home/xinhe/Projects/cookiecutter-de_analysis_skeleton',
no_input=True,
extra_context={
"project_name": 'name',
"projects_base": 'Projects',
"gtf_files": {
"mouse": "Mus_musculus.GRCm38.95.gtf",
"human": "Homo_sapiens.GRCh38.95.gtf",
"rat": "Rattus_norvegicus.Rnor_6.0.95.gtf"
}
})
Since this is a new feature already in the cookie-cutter master branch, should we update cookie-cutter to use this, or should we try the python approach which a similar task? @lweasel
So weirdly, although I couldn't actually find it in the documentation, it seems that you can supply extra context on the command line, e.g.,
> cookiecutter https://github.com/sidbdri/cookiecutter-de_analysis_skeleton
You've cloned /home/odando/.cookiecutters/cookiecutter-de_analysis_skeleton before. Is it okay to delete and re-clone it? [yes]:
project_name [newproject]:
but...
cookiecutter https://github.com/sidbdri/cookiecutter-de_analysis_skeleton project_name=hello
You've cloned /home/odando/.cookiecutters/cookiecutter-de_analysis_skeleton before. Is it okay to delete and re-clone it? [yes]:
project_name [hello]:
So, perhaps we could use a post-hook to take a JSON file that has been created with {{ cookiecutter | jsonify }}
and turn it into a command with all the option choices as these key=value
pairs (and record that command in a bash script)? What do you think @hxin ?
yes you can provide extra context in commandline options but I don't think it is possible to pass those dictionary parameter in commandlline, i.e you WON'T be able to do this: cookiecutter https://github.com/sidbdri/cookiecutter-de_analysis_skeleton gtf_files= { "mouse": "Mus_musculus.GRCm38.95.gtf", "human": "Homo_sapiens.GRCh38.95.gtf", "rat": "Rattus_norvegicus.Rnor_6.0.95.gtf" }
Oh, right, sorry - I understand now. Hmm.
However @hxin ...I can't remember a time when I've actually changed any of those dictionary parameters, I pretty much always use the defaults (which themselves depend on the Ensembl version). Could we get 90% of the way there by just creating a command which passes in the non-dictionary parameters?
yes
So perhaps let's not worry about the dict parameters for now? I think we can get nearly all the useful functionality from creating a bash command for the non-dict parameters.
we can use the python way to re-create the project tho, which can handle the dictionary parameter?
✔️
We want to be able to re-create the project using cookie-cutter with the init parameter.
This can be done using post-hook