Materials-Data-Science-and-Informatics / fair-python-cookiecutter

An opinionated cookiecutter template to kickstart a modern best-practice Python project with FAIR metadata.
MIT License
26 stars 4 forks source link

Cookiecutter fails w/ error #27

Closed cfgmr closed 2 months ago

cfgmr commented 2 months ago

Describe the bug Creating a new Project fails with

`TypeError: cookiecutter() got an unexpected keyword argument 'keep_project_on_failure'

To Reproduce Steps to reproduce the behavior: 1.pip install fair-python-cookiecutter

  1. pip install poetry
  2. fair-python-cookiecutter my-awesome-project
  3. answer questions
  4. See error

Expected behavior Expected a new project stub

Screenshots If applicable, add screenshots to help explain your problem.

Traces

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/cfaber/venvs/py3default/lib/python3.10/site-packages/fair_python_cookiecutter/cli.py:117   │
│ in main                                                                                          │
│                                                                                                  │
│   114 │   │   return                                                                             │
│   115 │                                                                                          │
│   116 │   # we're ready to create the repository                                                 │
│ ❱ 117 │   create_repository(ccconf, output_dir, keep_on_fail=keep_project_on_failure)            │
│   118                                                                                            │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │                  ccconf = CookiecutterConfig(                                                │ │
│ │                           │   default_context={},                                            │ │
│ │                           │   fair_python_cookiecutter=FPCConfig(                            │ │
│ │                           │   │   project_name='boknis-eck-client',                          │ │
│ │                           │   │   project_description='A python client library for the       │ │
│ │                           GEOMAR Boknis Eck Database',                                       │ │
│ │                           │   │   project_keywords='boknis BoknisEck ocean baltic monitoring │ │
│ │                           timeseries',                                                       │ │
│ │                           │   │   project_version='0.1.0',                                   │ │
│ │                           │   │   project_year=2024,                                         │ │
│ │                           │   │   project_license='MIT',                                     │ │
│ │                           │   │   last_name='Faber',                                         │ │
│ │                           │   │   first_name='Claas',                                        │ │
│ │                           │   │   email='cfaber@geomar.de',                                  │ │
│ │                           │   │   orcid='https://orcid.org/0000-0002-4861-3338',             │ │
│ │                           │   │   affiliation='GEOMAR Helmholtz Centre for Ocean Research    │ │
│ │                           Kiel',                                                             │ │
│ │                           │   │   copyright_holder='GEOMAR Helmholtz Centre for Ocean        │ │
│ │                           Research Kiel',                                                    │ │
│ │                           │   │                                                              │ │
│ │                           project_repo_url=Url('https://git.geomar.de/dm/libs/boknis-eck-cl… │ │
│ │                           │   │   project_hoster=Url('https://git.geomar.de/'),              │ │
│ │                           │   │   project_org='dm/libs',                                     │ │
│ │                           │   │   project_slug='boknis-eck-client',                          │ │
│ │                           │   │   project_pages_domain='pages.git.geomar.de',                │ │
│ │                           │   │                                                              │ │
│ │                           project_pages_url=Url('https://boknis-eck-client.pages.git.geomar… │ │
│ │                           │   │   init_cli=True,                                             │ │
│ │                           │   │   init_api=False                                             │ │
│ │                           │   ),                                                             │ │
│ │                           │   cookiecutters_dir='/home/cfaber/.cookiecutters/',              │ │
│ │                           │   replay_dir='/home/cfaber/.cookiecutter_replay/',               │ │
│ │                           │   abbreviations={                                                │ │
│ │                           │   │   'gh': 'https://github.com/{0}.git',                        │ │
│ │                           │   │   'gl': 'https://gitlab.com/{0}.git',                        │ │
│ │                           │   │   'bb': 'https://bitbucket.org/{0}'                          │ │
│ │                           │   }                                                              │ │
│ │                           )                                                                  │ │
│ │             config_file = None                                                               │ │
│ │                 dry_run = False                                                              │ │
│ │ keep_project_on_failure = False                                                              │ │
│ │                no_input = False                                                              │ │
│ │              output_dir = PosixPath('/home/cfaber/misc')                                     │ │
│ │                repo_url = ''                                                                 │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /home/cfaber/venvs/py3default/lib/python3.10/site-packages/fair_python_cookiecutter/main.py:118  │
│ in create_repository                                                                             │
│                                                                                                  │
│   115 │   check_prerequisites()                                                                  │
│   116 │   with TempDir(keep=keep_on_fail) as tmp_root:                                           │
│   117 │   │   copy_template(tmp_root, cookiecutter_json=cc_json)                                 │
│ ❱ 118 │   │   cookiecutter(                                                                      │
│   119 │   │   │   template=str(tmp_root),  # copy of template                                    │
│   120 │   │   │   no_input=True,  # if cookiecutter still needs to ask, we did a mistake         │
│   121 │   │   │   output_dir=str(output_dir),                                                    │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │      cc_args = {}                                                                            │ │
│ │      cc_json = CookiecutterJson(                                                             │ │
│ │                │   copy_without_render=['docs/overrides', '.github'],                        │ │
│ │                │   fpc_version='0.3.1',                                                      │ │
│ │                │   project_name='boknis-eck-client',                                         │ │
│ │                │   project_slug='boknis-eck-client',                                         │ │
│ │                │   project_package='boknis_eck_client',                                      │ │
│ │                │   project_version='0.1.0',                                                  │ │
│ │                │   project_description='A python client library for the GEOMAR Boknis Eck    │ │
│ │                Database',                                                                    │ │
│ │                │   project_keywords='boknis BoknisEck ocean baltic monitoring timeseries',   │ │
│ │                │   project_git_hoster='https://git.geomar.de/',                              │ │
│ │                │   project_git_org='dm/libs',                                                │ │
│ │                │   project_git_path='dm/libs/boknis-eck-client',                             │ │
│ │                │   project_repo_url='https://git.geomar.de/dm/libs/boknis-eck-client',       │ │
│ │                │   project_clone_url='git@git.geomar.de/dm/libs/boknis-eck-client.git',      │ │
│ │                │   project_pages_domain='pages.git.geomar.de',                               │ │
│ │                │   project_pages_url='https://boknis-eck-client.pages.git.geomar.de/',       │ │
│ │                │   project_license='MIT',                                                    │ │
│ │                │   copyright_holder='GEOMAR Helmholtz Centre for Ocean Research Kiel',       │ │
│ │                │   copyright_year='2024',                                                    │ │
│ │                │   copyright_text='Copyright © 2024 GEOMAR Helmholtz Centre for Ocean        │ │
│ │                Research Kiel',                                                               │ │
│ │                │   copyright_line='SPDX-FileCopyrightText: Copyright © 2024 GEOMAR Helmholtz │ │
│ │                Centre for Ocean Resea'+8,                                                    │ │
│ │                │   author_affiliation='GEOMAR Helmholtz Centre for Ocean Research Kiel',     │ │
│ │                │   author_last_name='Faber',                                                 │ │
│ │                │   author_first_name='Claas',                                                │ │
│ │                │   author_email='cfaber@geomar.de',                                          │ │
│ │                │   author_orcid_url='https://orcid.org/0000-0002-4861-3338',                 │ │
│ │                │   author_name_email='Claas Faber <cfaber@geomar.de>',                       │ │
│ │                │   init_cli=True,                                                            │ │
│ │                │   init_api=False,                                                           │ │
│ │                │   is_github=False                                                           │ │
│ │                )                                                                             │ │
│ │         conf = CookiecutterConfig(                                                           │ │
│ │                │   default_context={},                                                       │ │
│ │                │   fair_python_cookiecutter=FPCConfig(                                       │ │
│ │                │   │   project_name='boknis-eck-client',                                     │ │
│ │                │   │   project_description='A python client library for the GEOMAR Boknis    │ │
│ │                Eck Database',                                                                │ │
│ │                │   │   project_keywords='boknis BoknisEck ocean baltic monitoring            │ │
│ │                timeseries',                                                                  │ │
│ │                │   │   project_version='0.1.0',                                              │ │
│ │                │   │   project_year=2024,                                                    │ │
│ │                │   │   project_license='MIT',                                                │ │
│ │                │   │   last_name='Faber',                                                    │ │
│ │                │   │   first_name='Claas',                                                   │ │
│ │                │   │   email='cfaber@geomar.de',                                             │ │
│ │                │   │   orcid='https://orcid.org/0000-0002-4861-3338',                        │ │
│ │                │   │   affiliation='GEOMAR Helmholtz Centre for Ocean Research Kiel',        │ │
│ │                │   │   copyright_holder='GEOMAR Helmholtz Centre for Ocean Research Kiel',   │ │
│ │                │   │                                                                         │ │
│ │                project_repo_url=Url('https://git.geomar.de/dm/libs/boknis-eck-client'),      │ │
│ │                │   │   project_hoster=Url('https://git.geomar.de/'),                         │ │
│ │                │   │   project_org='dm/libs',                                                │ │
│ │                │   │   project_slug='boknis-eck-client',                                     │ │
│ │                │   │   project_pages_domain='pages.git.geomar.de',                           │ │
│ │                │   │                                                                         │ │
│ │                project_pages_url=Url('https://boknis-eck-client.pages.git.geomar.de/'),      │ │
│ │                │   │   init_cli=True,                                                        │ │
│ │                │   │   init_api=False                                                        │ │
│ │                │   ),                                                                        │ │
│ │                │   cookiecutters_dir='/home/cfaber/.cookiecutters/',                         │ │
│ │                │   replay_dir='/home/cfaber/.cookiecutter_replay/',                          │ │
│ │                │   abbreviations={                                                           │ │
│ │                │   │   'gh': 'https://github.com/{0}.git',                                   │ │
│ │                │   │   'gl': 'https://gitlab.com/{0}.git',                                   │ │
│ │                │   │   'bb': 'https://bitbucket.org/{0}'                                     │ │
│ │                │   }                                                                         │ │
│ │                )                                                                             │ │
│ │ keep_on_fail = False                                                                         │ │
│ │   output_dir = PosixPath('/home/cfaber/misc')                                                │ │
│ │     tmp_root = PosixPath('/run/user/1000/template_2c1847a0-4e80-11ef-98fc-bd8b0ce89866')     │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

Environment Provide information about versions of relevant software packages.

(py3default) cfaber@xyz~/misc$ python --version
Python 3.10.12
(py3default) cfaber@xyz:~/misc$ poetry --version
Poetry (version 1.8.3)
cookiecutter==2.1.1

Additional context

Fresh install of poetry and fair-python-cookiecutter in a virtual env

mustafasoylu commented 2 months ago

@cfgmr I am trying to recreate this error, but I couldn't. Could you let me know of your OS and way of creating the virtual environment?

cfgmr commented 2 months ago

Could you let me know of your OS and way of creating the virtual environment?

My apologies, I was not using a new venv, but one which already had an older version of cookiecutter (v2.1.1) installed. The problem does not occur in a fresh venv with up-to-date cookiecutter. I updated the environment info in the issue description above accordingly.

I tested it, and fair-python-cookiecutter fails with cookiecutter 2.1.1 but works with cookiecutter 2.2.3.

A change in the pyproject.toml from cookiecutter = "^2.1.1" to cookiecutter = "^2.2" could probably fix this issue.

Dockerfile for an environment to reproduce the error:

FROM python:3.10.12-slim AS base

RUN apt update && apt install -y git

RUN pip install poetry
RUN pip install fair-python-cookiecutter
RUN pip install cookiecutter==2.1.1
mustafasoylu commented 2 months ago

Thank you for the information, I will release a fix ASAP.