mirror of
https://github.com/wassname/cookiecutter-data-science.git
synced 2026-06-27 20:21:10 +08:00
1fe968d24e
* WIP - New version with cleaner options * Fix find-replace error (#177) * Remove unnecessary .gitkeep * Remove unused tox.ini * Split reqs into dev/non-dev * Add basic packages support * Add tests for testing environment creation and requirements * Set up CI with Azure Pipelines (#194) * Change archived asciinema example (#163) * Change archived asciinema example * Update README.md Fix Asciinema powerline error * Update docs to show updated asciinema example * Added source and destination to Make data target (#169) * Fix broken Airflow link (#182) * Fixed: Typo in Makefile (#184) Fixed typo in Makefile, section "Set up python interpreter environment": intalled --> installed * Set up CI with Azure Pipelines [skip ci] * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * str paths for windows support * handle multiple data providers (#199) * Add missing env directory bin/activate path * Remove version from PYTHON_INTERPRETER command * Search for virtualenvwrapper.sh path if executable not found * Try chardet for character encoding detection * Specify python and virtualenv binaries for virtualenvwrapper * Add shebang to virtualenvwrapper.sh * Diagnostic * Try virtualenvwrapper-win * Set encoding if detected None * Fixes to Mac and Windows tests on Azure pipelines (#217) * Temporarily comment out py36 * Update azure-pipelines.yml * Fix tests on Windows and Mac (#1) * Temporarily remove py37 * Update virtualenv_harness.sh * put py37 back in * Set encoding to utf-8 * Comment out rmvirtualenv * Update test_creation.py * Update virtualenv_harness.sh * Add --show-capture * Update azure-pipelines.yml * Update azure-pipelines.yml * Update test_creation.py * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update Makefile * Update virtualenv_harness.sh * Update cookiecutter.json * Update cookiecutter.json * Update virtualenv_harness.sh * Update Makefile * Update Makefile * Update Makefile * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update Makefile * Update Makefile * Update Makefile * Update Makefile * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update Makefile * Update Makefile * Update virtualenv_harness.sh * Update Makefile * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update test_creation.py * Update azure-pipelines.yml * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update virtualenv_harness.sh * Update cookiecutter.json * Update conda_harness.sh * Update conda_harness.sh * Update conda_harness.sh Co-authored-by: Eric Jalbert <ericmjalbert@users.noreply.github.com> Co-authored-by: Jonathan Raviotta <jraviotta@users.noreply.github.com> Co-authored-by: Wes Roach <wesr000@gmail.com> Co-authored-by: Christopher Geis <16896724+geisch@users.noreply.github.com> Co-authored-by: Peter Bull <pjbull@gmail.com> Co-authored-by: Ian Preston <17241371+ianepreston@users.noreply.github.com> Co-authored-by: Jay Qi <jayqi@users.noreply.github.com> Co-authored-by: inchiosa <4316698+inchiosa@users.noreply.github.com> * More graceful deprecation * Make tests pass locally * test version match installed version * Remove unused imports * Unremove used import * Move to GH Actions * Fix typo * Test non-windows * Add netlify configs * Update suggestion to keep using deprecated cookiecutter template (#231) * Add mkdocs requirements file to docs directory * Try setting python version in runtime txt for netlify * Trigger build * Python 3.8 netlify * Python 3.6 netlify * Do not specify python runtime for netlify * Use 3.7 This reverts commit 898d7d3cf6008e47e89ed607167fad7aee1e065e. Co-authored-by: James Myatt <james@jamesmyatt.co.uk> Co-authored-by: drivendata <info@drivendata.org> Co-authored-by: Eric Jalbert <ericmjalbert@users.noreply.github.com> Co-authored-by: Jonathan Raviotta <jraviotta@users.noreply.github.com> Co-authored-by: Wes Roach <wesr000@gmail.com> Co-authored-by: Christopher Geis <16896724+geisch@users.noreply.github.com> Co-authored-by: Ian Preston <17241371+ianepreston@users.noreply.github.com> Co-authored-by: Jay Qi <jayqi@users.noreply.github.com> Co-authored-by: inchiosa <4316698+inchiosa@users.noreply.github.com> Co-authored-by: Robert Gibboni <robert@drivendata.org>
76 lines
2.2 KiB
Python
76 lines
2.2 KiB
Python
from contextlib import contextmanager
|
|
from itertools import product
|
|
import json
|
|
from pathlib import Path
|
|
import shutil
|
|
import sys
|
|
import tempfile
|
|
|
|
from ccds.__main__ import api_main
|
|
|
|
|
|
CCDS_ROOT = Path(__file__).parents[1].resolve()
|
|
|
|
|
|
default_args = {
|
|
'project_name': 'my_test_project',
|
|
'repo_name': 'my-test-repo',
|
|
'module_name': 'project_module',
|
|
'author_name': 'DrivenData',
|
|
'description': 'A test project',
|
|
'open_source_license' : 'MIT',
|
|
'dataset_storage': {"azure": {"container": "container-name"}},
|
|
}
|
|
|
|
def config_generator():
|
|
cookiecutter_json = json.load((CCDS_ROOT / 'ccds.json').open('r'))
|
|
|
|
# python versions for the created environment; match the root
|
|
# python version since Pipenv needs to be able to find an executable
|
|
running_py_version = f"{sys.version_info.major}.{sys.version_info.minor}"
|
|
py_version = [('python_version_number', v) for v in [running_py_version]]
|
|
|
|
configs = product(
|
|
py_version,
|
|
[('environment_manager', opt) for opt in cookiecutter_json['environment_manager']],
|
|
[('dependency_file', opt) for opt in cookiecutter_json['dependency_file']],
|
|
[('pydata_packages', opt) for opt in cookiecutter_json['pydata_packages']],
|
|
)
|
|
|
|
def _is_valid(config):
|
|
config = dict(config)
|
|
# Pipfile + pipenv only valid combo for either
|
|
if (config['environment_manager'] == 'pipenv') ^ (config['dependency_file'] == 'Pipfile'):
|
|
return False
|
|
# conda is the only valid env manager for environment.yml
|
|
if (config['dependency_file'] == 'environment.yml') and (config['environment_manager'] != 'conda'):
|
|
return False
|
|
return True
|
|
|
|
# remove invalid configs
|
|
configs = [
|
|
c for c in configs if _is_valid(c)
|
|
]
|
|
|
|
for c in configs:
|
|
config = dict(c)
|
|
config.update(default_args)
|
|
yield config
|
|
|
|
|
|
@contextmanager
|
|
def bake_project(config):
|
|
temp = Path(tempfile.mkdtemp(suffix='data-project')).resolve()
|
|
|
|
api_main.cookiecutter(
|
|
str(CCDS_ROOT),
|
|
no_input=True,
|
|
extra_context=config,
|
|
output_dir=temp,
|
|
overwrite_if_exists=True
|
|
)
|
|
|
|
yield temp / config['repo_name']
|
|
|
|
# cleanup after
|
|
shutil.rmtree(temp) |