Skip to content

Commit

Permalink
Update pyproject.toml (#36)
Browse files Browse the repository at this point in the history
Co-authored-by: UltralyticsAssistant <[email protected]>
  • Loading branch information
glenn-jocher and UltralyticsAssistant authored Oct 29, 2024
1 parent 8b98254 commit 3c20674
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 34 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Ultralytics Template 🚀, AGPL-3.0 license
# Continuous Integration (CI) GitHub Actions tests

name: Template CI

on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '0 0 * * *' # Runs at 00:00 UTC every day

jobs:
Test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.12", "3.13"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run Python tests
run: |
python -m pytest tests/test_module1.py -v
- name: Run CLI tests
run: |
example-cli-command
16 changes: 9 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# For comprehensive documentation and usage instructions, visit: https://docs.ultralytics.com

[build-system]
requires = ["setuptools>=43.0.0", "wheel"]
requires = ["setuptools>=70.0.0", "wheel"]
build-backend = "setuptools.build_meta"

# Project settings -----------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -57,14 +57,16 @@ classifiers = [# Optional, for a list of valid classifiers, see https://pypi.org
]

# Required dependencies ------------------------------------------------------------------------------------------------
dependencies = [# Optional
"ultralytics",
dependencies = [
"numpy",
]

# Optional dependencies ------------------------------------------------------------------------------------------------
[project.optional-dependencies] # Optional
tests = ["pytest"]
[project.optional-dependencies]
dev = [
"pytest",
"mkdocs",
]

[project.urls] # Optional
"Homepage" = "https://ultralytics.com"
Expand All @@ -73,8 +75,8 @@ tests = ["pytest"]
"Bug Reports" = "https://github.com/ultralytics/template/issues"
"Changelog" = "https://github.com/ultralytics/template/releases"

# [project.scripts] # Optional
# sample = "sample:main" # executes the function `main` from this package when "sample" is called.
[project.scripts] # Optional
example-cli-command = "template.module1:main" # executes `template.module1.main` when "example-cli-command" is run from CLI

# Tools settings -------------------------------------------------------------------------------------------------------
[tool.setuptools] # configuration specific to the `setuptools` build backend.
Expand Down
44 changes: 29 additions & 15 deletions template/module1.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,40 @@

def add_numbers(a, b):
"""
Adds two numbers and returns the sum.
Adds two numbers together using element-wise addition.
Args:
a (float | int): The first number in the addition.
b (float | int): The second number in the addition.
a (int | float | torch.Tensor): First number or tensor to add.
b (int | float | torch.Tensor): Second number or tensor to add.
Returns:
(float | int): The sum of `a` and `b`.
Notes:
This function supports both integer and floating-point numbers. The returned value will match the type of the input
values unless they're mixed, in which case a float is returned.
(int | float | torch.Tensor): Sum of the input numbers or tensors. If inputs are tensors, returns a tensor of
the same shape.
Examples:
```python
result = add_numbers(3, 5)
assert result == 8
result = add_numbers(3.5, 2)
assert result == 5.5
```
>>> result = add_numbers(1, 2) # returns 3
>>> x = torch.tensor([1, 2])
>>> y = torch.tensor([3, 4])
>>> result = add_numbers(x, y) # returns tensor([4, 6])
"""
return a + b


def main():
"""
Main entry point for the Ultralytics YOLO application.
Executes a simple addition operation by calling the add_numbers function with predefined values. This function
serves as a basic demonstration of program flow and function calling within the Ultralytics framework.
Examples:
>>> main() # Runs the main function which adds 1 + 2
"""
a = 1
b = 2
y = add_numbers(a, b)
print(f"Added {a} + {b} = {y}")


if __name__ == "__main__":
main()
21 changes: 9 additions & 12 deletions tests/test_module1.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
# Ultralytics YOLO 🚀, AGPL-3.0 License https://ultralytics.com/license

from module1 import add_numbers
from template.module1 import add_numbers


def test_add_numbers():
"""
Test the add_numbers function from module1 by verifying the correctness of summation operation between pairs of
integers.
Tests the add_numbers function with positive and negative integer inputs.
Tests:
- Ensures that the sum of 2 and 3 equals 5.
- Validates that the sum of -1 and 1 equals 0.
Returns:
(None): This function performs assertions to validate the behavior of add_numbers. It does not return a value.
Raises:
AssertionError: If any of the assertions fail, this error is raised indicating a test case failure.
The function performs assertion tests to verify that the add_numbers function correctly handles both positive and negative
integer addition operations. Tests include basic positive integer addition and operations involving negative integers.
Examples:
>>> test_add_numbers() # Runs assertion tests
>>> assert add_numbers(2, 3) == 5 # Test positive integers
>>> assert add_numbers(-1, 1) == 0 # Test with negative integer
"""
assert add_numbers(2, 3) == 5
assert add_numbers(-1, 1) == 0
Expand Down

0 comments on commit 3c20674

Please sign in to comment.