Skip to content

Commit

Permalink
Updated readme (#1541)
Browse files Browse the repository at this point in the history
  • Loading branch information
ternaus authored Feb 27, 2024
1 parent 4deb00e commit e5db7c1
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 23 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ jobs:
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install dependencies
run: pip install .[develop]
run: |
pip install .
pip install pytest
- name: Run checks
run: python tools/make_transforms_docs.py check README.md
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ repos:
- id: python-check-blanket-noqa
- id: python-use-type-annotations
- id: text-unicode-replacement-char
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies: ["tomli"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
Expand Down
18 changes: 11 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ For small changes (e.g., bug fixes), feel free to submit a PR.

For larger changes, consider
creating an [**issue**](https://github.com/albumentations-team/albumentations/issues) outlining your proposed change.
You can also join us on [**Discord**](https://discord.com/invite/astral-sh) to discuss your idea with the
You can also join us on [**Discord**](https://discord.gg/e6zHCXTvaN) to discuss your idea with the
community.

## Getting Started
Expand All @@ -18,13 +18,13 @@ community.
Start by forking the project repository to your GitHub account, then clone your fork to your local machine:

```bash
git clone https://github.com/your-username/albumentations.git
git clone https://github.com/albumentations/albumentations.git
cd albumentations
```

#### Create a virtual environment

We recommend using a virtual environment to isolate project dependencies:
We recommend using a virtual environment to isolate project dependencies. Ensure you have Python 3.8 or higher installed on your machine, as it is the minimum supported version for Albumentations. To create and activate a virtual environment, run the following commands:

```bash
python3 -m venv env
Expand Down Expand Up @@ -81,13 +81,13 @@ pip install -r requirements-dev.txt

To maintain code quality and consistency, we use pre-commit hooks. Follow these steps to set up pre-commit hooks in your local repository:

1. **Install pre-commit:** If you haven't already, you need to install pre-commit on your machine. You can do this using pip:
**Install pre-commit:** If you haven't already, you need to install pre-commit on your machine. You can do this using pip:

```bash
pip install pre-commit
```

2. **Initialize pre-commit:**
**Initialize pre-commit:**

Navigate to the root of your cloned repository and run:

Expand All @@ -97,7 +97,7 @@ pre-commit install

This command sets up the pre-commit hooks based on the configurations found in `.pre-commit-config.yaml` at the root of the repository.

3. **Running pre-commit hooks:**
**Running pre-commit hooks:**

Pre-commit will automatically run the configured hooks on each commit. You can also manually run the hooks on all files in the repository with:

Expand All @@ -116,7 +116,11 @@ Install test dependencies:
If you haven't installed the development dependencies, make sure to do so. These dependencies include `pytest`, which is required to run the tests.

```bash
pip install -e .[tests]
pip install -e .
```

```bash
pip install -r requirements-dev.txt
```

Run the tests:
Expand Down
2 changes: 1 addition & 1 deletion albumentations/augmentations/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2533,7 +2533,7 @@ class PixelDropout(DualTransform):
Args:
----
dropout_prob (float): pixel drop probability. Default: 0.01
per_channel (bool): if set to `True` drop mask will be sampled fo each channel,
per_channel (bool): if set to `True` drop mask will be sampled for each channel,
otherwise the same mask will be sampled for all channels. Default: False
drop_value (number or sequence of numbers or None): Value that will be set in dropped place.
If set to None value will be sampled randomly, default ranges will be used:
Expand Down
2 changes: 1 addition & 1 deletion albumentations/core/bbox_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def union_of_bboxes(height: int, width: int, bboxes: Sequence[BoxType], erosion_
height (float): Height of image or space.
width (float): Width of image or space.
bboxes (List[tuple]): List like bounding boxes. Format is `[(x_min, y_min, x_max, y_max)]`.
erosion_rate (float): How much each bounding box can be shrinked, useful for erosive cropping.
erosion_rate (float): How much each bounding box can be shrunk, useful for erosive cropping.
Set this in range [0, 1]. 0 will not be erosive at all, 1.0 can make any bbox to lose its volume.
Returns:
Expand Down
6 changes: 3 additions & 3 deletions albumentations/core/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@


def shorten_class_name(class_fullname: str) -> str:
splitted = class_fullname.split(".")
if len(splitted) == 1:
split = class_fullname.split(".")
if len(split) == 1:
return class_fullname
top_module, *_, class_name = splitted
top_module, *_, class_name = split
if top_module == "albumentations":
return class_name
return class_fullname
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ exclude = [
"site-packages",
"venv",
"tests",
"benchmark"
"benchmark",
"tools",
"setup.py"
]

# Same as Black.
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ black==24.2.0
deepdiff==6.7.1
mypy==1.8.0
pre_commit>=3.5.0
pytest==8.0.2
ruff==0.2.2
types-pkg-resources
types-PyYAML
Expand Down
5 changes: 0 additions & 5 deletions setup.cfg

This file was deleted.

1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def get_install_requirements(install_requires, choose_install_requires):
packages=find_packages(exclude=["tests"]),
python_requires=">=3.8",
install_requires=get_install_requirements(INSTALL_REQUIRES, CHOOSE_INSTALL_REQUIRES),
extras_require={"tests": ["pytest"], "develop": ["pytest"]},
classifiers=[
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
Expand Down
31 changes: 31 additions & 0 deletions tools/check_docstring_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import ast
import sys


def check_docstring_types(file_path):
with open(file_path) as source:
tree = ast.parse(source.read(), filename=file_path)

for node in ast.walk(tree):
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and node.returns:
docstring = ast.get_docstring(node)
if docstring:
# Example check: see if "Args:" is in docstring (for Google style)
if "Args:" not in docstring:
print(f"{file_path}: Function '{node.name}' is missing 'Args:' in its docstring")
return False
return True


def main():
success = True
for file_path in sys.argv[1:]:
if not check_docstring_types(file_path):
success = False

if not success:
sys.exit(1)


if __name__ == "__main__":
main()
6 changes: 3 additions & 3 deletions tools/make_transforms_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from enum import Enum

sys.path.append("..")
import albumentations # noqa: E402
import albumentations

IGNORED_CLASSES = {
"BasicTransform",
Expand All @@ -18,8 +18,8 @@ def make_augmentation_docs_link(cls):
module_parts = cls.__module__.split(".")
module_page = "/".join(module_parts[1:])
return (
"[{cls.__name__}](https://albumentations.ai/docs/api_reference/{module_page}/#{cls.__module__}.{cls.__name__})"
).format(module_page=module_page, cls=cls)
f"[{cls.__name__}](https://albumentations.ai/docs/api_reference/{module_page}/#{cls.__module__}.{cls.__name__})"
)


class Targets(Enum):
Expand Down

0 comments on commit e5db7c1

Please sign in to comment.