Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docstring fix #10

Merged
merged 10 commits into from
Mar 12, 2024
Merged

Docstring fix #10

merged 10 commits into from
Mar 12, 2024

Conversation

bourdeet
Copy link
Contributor

@bourdeet bourdeet commented Mar 6, 2024

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]: [email protected]
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.

Copy link
Collaborator

@saattrupdan saattrupdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! I've got a few suggested changes, mostly related to the content of the docstrings.

bourdeet and others added 3 commits March 7, 2024 14:21
….dependency_manager != 'pip' else 'freeze_dependencies.py'}}

Co-authored-by: Dan Saattrup Nielsen <[email protected]>
@bourdeet
Copy link
Contributor Author

bourdeet commented Mar 7, 2024

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

cookiecutter -f [email protected]: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 [email protected]:alexandrainst/alexandra-ml-template@docstring_fix

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

but it doesn't seem to work

@saattrupdan
Copy link
Collaborator

saattrupdan commented Mar 7, 2024

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

cookiecutter -f [email protected]: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 [email protected]:alexandrainst/alexandra-ml-template --checkout docstring_fix

@bourdeet
Copy link
Contributor Author

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!

Copy link
Collaborator

@saattrupdan saattrupdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@saattrupdan saattrupdan merged commit fa8219e into main Mar 12, 2024
2 checks passed
@saattrupdan saattrupdan deleted the docstring_fix branch March 12, 2024 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants