Skip to content

Commit

Permalink
Add .gitignore also in data
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianWilhelm committed Aug 18, 2019
1 parent 485e9dc commit c0dc782
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/pyscaffoldext/dsproject/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ def add_dsproject(struct, opts):
"""
gitignore_all = templates.gitignore_all(opts)

path = [opts["project"], "data", ".gitignore"]
struct = helpers.ensure(struct, path,
templates.gitignore_data(opts),
helpers.NO_OVERWRITE)
for folder in ('external', 'interim', 'preprocessed', 'raw'):
path = [opts["project"], "data", folder, ".gitignore"]
struct = helpers.ensure(struct, path,
Expand Down
18 changes: 18 additions & 0 deletions src/pyscaffoldext/dsproject/templates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def get_template(name):
def gitignore_all(opts):
"""gitignore file that ignores just everything
Ignore everything except of this gitignore file.
Args:
opts (dict): given options, see :obj:`create_project` for
an extensive list.
Expand All @@ -32,6 +34,22 @@ def gitignore_all(opts):
return template.safe_substitute(opts)


def gitignore_data(opts):
"""gitignore file that ignores almost everything
Ignore everything except of gitignore also in sub directories.
Args:
opts (dict): given options, see :obj:`create_project` for
an extensive list.
Returns:
str: file content as string
"""
template = get_template("gitignore_data")
return template.safe_substitute(opts)


def environment_yaml(opts):
"""Environment.yaml with some basic libraries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies:
- scikit-learn
- pytorch
- pip:
# add here only pip-packages that are not available in conda-forge! E.g.:
# add here only pip-packages that are not available in conda/conda-forge! E.g.:
- optuna
# for development only (could also be kept in a separate environment file)
- jupyterlab
Expand Down
8 changes: 8 additions & 0 deletions src/pyscaffoldext/dsproject/templates/gitignore_data.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Ignore everything in this directory
*
# Except this file and .gitignore in sub directories
!.gitignore
!raw
!external
!preprocessed
!interim
3 changes: 3 additions & 0 deletions src/pyscaffoldext/dsproject/templates/template_ipynb.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import sys\n",
"import math\n",
"import logging\n",
"from pathlib import Path\n",
"\n",
"import numpy as np\n",
"import scipy as sp\n",
Expand Down

0 comments on commit c0dc782

Please sign in to comment.