alexandrainst / alexandra-ml-template

Template for Python-based data science projects in the Alexandra Institute.
https://alexandra.dk/
MIT License
8 stars 1 forks source link

Docstring fix #10

Closed bourdeet closed 8 months ago

bourdeet commented 8 months ago

When deploying a new project and running make install , I encounter two errors.

Example setup command:

cookiecutter -f gh:alexandrainst/alexandra-ml-template

Example configuration from the prompt:

You've downloaded /home/bourdeet/.cookiecutters/alexandra-ml-template before. Is it okay to delete and re-download it? [yes]: yes
project_name [Project name, in snake_case]: test_project
project_description [Short description of the project]: Here is my description
author_name [Your full name]: Test
email [<name>@alexandra.dk]: test@alexandra.dk
open_source [Is this a public open source project? [y/N]]: N
python_version [Your Python version, written as 3.xx]: 3.11
dependency_manager [Which dependency manager do you use? [pip/POETRY]]: pip
license_checker [Do you want to check that your dependencies are only using open source licenses? [Y/n]]: n

First error upon running make install:

Installing the 'test_project' project...
Initialized empty Git repository in /home/bourdeet/projects/RK_iot_forretningsdesign/tes/test_project/.git/
Signed with GPG key [ID GPG_KEY].
pre-commit installed at .git/hooks/pre-commit
Updated dependencies in pyproject.toml.
No .pre-commit-config.yaml file was found
- To temporarily silence this, run `PRE_COMMIT_ALLOW_NO_CONFIG=1 git ...`
- To permanently silence this, install pre-commit with the --allow-missing-config option
- To uninstall pre-commit run `pre-commit uninstall`
make[1]: *** [makefile:111: add-repo-to-git] Error 1
make: *** [makefile:36: install] Error 2

The first error can be avoided by adding a dot to the name pre-commit-config.yaml. When running make install again, I get a second error related to docstring formatting of some of the template files:

Installing the 'test_project' project...
[...]
pre-commit installed at .git/hooks/pre-commit
Updated dependencies in pyproject.toml.
black....................................................................Passed
ruff.....................................................................Failed
- hook id: ruff
- exit code: 1
- files were modified by this hook

config/__init__.py:1:1: D104 Missing docstring in public package
src/scripts/freeze_dependencies.py:12:9: D102 Missing docstring in public method
src/scripts/freeze_dependencies.py:22:9: D102 Missing docstring in public method
tests/__init__.py:1:1: D104 Missing docstring in public package
tests/test_dummy.py:4:5: D103 Missing docstring in public function
Found 7 errors (2 fixed, 5 remaining).

nbstripout...........................................(no files to check)Skipped
mypy.....................................................................Passed
make[1]: *** [makefile:111: add-repo-to-git] Error 1
make: *** [makefile:36: install] Error 2

I have added the missing docstring in the problematic file.

bourdeet commented 8 months ago

I am trying to check that the new commits can run on install, but I realized that calling:

cookiecutter -f git@github.com:alexandrainst/alexandra-ml-template

This downloads the template from the main branch. @saattrupdan do you know if one can call a specific git branch from cookiecutter? I tried:

cookiecutter -f gh:alexandrainst/alexandra-ml-template@docstring_fix

cookiecutter -f git@github.com:alexandrainst/alexandra-ml-template@docstring_fix

cookiecutter -f gh:alexandrainst/alexandra-ml-template.git@docstring_fix

but it doesn't seem to work

saattrupdan commented 8 months ago

I am trying to check that the new commits can run on install, but I realized that calling:

cookiecutter -f git@github.com:alexandrainst/alexandra-ml-template

This downloads the template from the main branch. @saattrupdan do you know if one can call a specific git branch from cookiecutter?

@bourdeet It seems like you can specify the branch name with the --checkout argument, as described here:

$ cookiecutter -f git@github.com:alexandrainst/alexandra-ml-template --checkout docstring_fix
bourdeet commented 8 months ago

OK! the empty init.py files that caused the docstring issue were in the end not needed by the template, as they are created upon running make install

I have pushed the changes, and I can install a test project with both pip and poetry without any issue. Good to merge!