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

feat: make modules use black formatter #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions {{ cookiecutter.__repo_name }}/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["ms-python.black-formatter", "BdSoftware.format-on-auto-save"]
BorjaEst marked this conversation as resolved.
Show resolved Hide resolved
}
14 changes: 14 additions & 0 deletions {{ cookiecutter.__repo_name }}/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// To allow formatting on autosave you need to install the
// "Format on Auto Save" extension
// https://github.com/microsoft/vscode/issues/45997#issuecomment-950405496
{
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
},
"files.autoSave": "afterDelay",
"editor.rulers": [
88
BorjaEst marked this conversation as resolved.
Show resolved Hide resolved
],

}
23 changes: 21 additions & 2 deletions {{ cookiecutter.__repo_name }}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

{{cookiecutter.description}}

## Usage

To launch it, first install the package then run [deepaas](https://github.com/ai4os/DEEPaaS):
```bash
git clone {{ cookiecutter.git_base_url }}/{{ cookiecutter.__repo_name }}
Expand All @@ -11,6 +13,23 @@ pip install -e .
deepaas-run --listen-ip 0.0.0.0
```

## Contributing
BorjaEst marked this conversation as resolved.
Show resolved Hide resolved

This module tries to enforce best practices by using [Black](https://github.com/psf/black)
to format the code.

For an optimal development experience, we recommend installing the VScode extensions
[Black](https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter)
and [Format on Auto Save](https://marketplace.visualstudio.com/items?itemName=BdSoftware.format-on-auto-save).
Copy link
Contributor

Choose a reason for hiding this comment

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

Check if BdSoftware is needed?
I run it in my local and it was all working without it.
If we do not add BdSoftware then I would remove this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my case, formatting did not happen without BSsoftware extension.
I'm using VScode 1.92.1 on Ubuntu 20.04. As far as I can tell, people still complain it not working.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have 1.92.2 and U 22.04, however, It should be the same.
I was not trying exactly the same but rather the config here (updated):

https://github.com/ai4os-hub/demo-advanced/blob/main/.vscode/settings.json

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested with your configuration and it still does not work in my local. So to be on the save side, I would just keep the BSsoftware extension.

Their configurations are automatically included in the [`.vscode`](./.vscode) folder.
This will format the code during the automatic saves, though you can force formatting with
`CTRL + Shift + I` (or `CTRL + S` to save).

To enable them only for this repository: after installing, click `Disable`,
then click `Enable (workspace)`.

In the Black _global_ settings, we also recommend setting `black-formatter.showNotification = off`.

## Project structure
```
Expand Down Expand Up @@ -40,13 +59,13 @@ deepaas-run --listen-ip 0.0.0.0
├── data/ <- Folder to store the data
├── models/ <- Folder to store models
├── tests/ <- Scripts to perfrom code testing
|
├── metadata.json <- Metadata information propagated to the AI4OS Hub
├── pyproject.toml <- a configuration file used by packaging tools, so {{cookiecutter.__app_name}}
│ can be imported or installed with `pip install -e .`
│ can be imported or installed with `pip install -e .`
├── requirements.txt <- The requirements file for reproducing the analysis environment, i.e.
│ contains a list of packages needed to make {{cookiecutter.__app_name}} work
Expand Down
5 changes: 3 additions & 2 deletions {{ cookiecutter.__repo_name }}/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ envdir = {toxworkdir}/shared
commands = pytest --numprocesses=auto {posargs}
allowlist_externals =
mkdir
passenv =
passenv =
RCLONERCLONE_CONFIG_RSHARE_VENDOR
RCLONE_CONFIG
RCLONE_CONFIG_RSHARE_PASS
Expand All @@ -23,8 +23,9 @@ deps = -r{toxinidir}/requirements-test.txt

# important for Jenkins publishing of results: store results in subdirectory
[testenv:qc.sty]
commands =
commands =
flake8 --statistics --tee --output-file={toxinidir}/flake8.log \
--max-line-length=80 --extend-select=B950 --extend-ignore=E203,E501,E701 \ # add this line to support Black formatter
BorjaEst marked this conversation as resolved.
Show resolved Hide resolved
--format=pylint {{ cookiecutter.__app_name }} tests

# important for Jenkins publishing of results: store results in subdirectory
Expand Down