diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8979f01 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/pyproject.toml b/pyproject.toml index e47af1d..fbbf92b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 ----------------------------------------------------------------------------------------------------- @@ -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" @@ -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. diff --git a/template/module1.py b/template/module1.py index fc3c13f..3835845 100644 --- a/template/module1.py +++ b/template/module1.py @@ -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() diff --git a/tests/test_module1.py b/tests/test_module1.py index 14302ef..6d8bd1d 100644 --- a/tests/test_module1.py +++ b/tests/test_module1.py @@ -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