diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..35f4a3c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.12'] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: latest + virtualenvs-create: true + virtualenvs-in-project: true + + - name: Install dependencies + run: poetry install --no-interaction + + - name: Run tests + run: poetry run pytest tests src + + - name: Run linting + run: | + poetry run ruff check . + poetry run ruff format --check . diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a483e68 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +# Python-generated files +__pycache__/ +*.py[oc] +build/ +dist/ +wheels/ +*.egg-info + +# Virtual environments +.venv + +# IDE +!.vscode/ + +# Poetry +poetry.lock + +# Cache +.pytest_cache/ +.ruff_cache/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b5f968e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,8 @@ +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.1.13 + hooks: + - id: ruff + args: [--fix] + - id: ruff-format diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4c89e67 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "[python]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "charliermarsh.ruff", + "editor.codeActionsOnSave": { + "source.fixAll": "explicit", + "source.organizeImports": "explicit" + } + }, + "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python" +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..49658e9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 marimo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e430b9b --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ +# marimo + Poetry Starter Template + +A starter template for [marimo](https://marimo.io) notebooks using [Poetry](https://python-poetry.org) for dependency and project management. This template provides a modern Python development setup with best practices for notebook development. + +## Features + +- ๐Ÿš€ Python 3.12+ support +- ๐Ÿ“ฆ Dependency management with Poetry +- ๐Ÿงช Testing setup with pytest +- ๐ŸŽฏ Code quality with Ruff (linting + formatting) +- ๐Ÿ‘ท CI/CD with GitHub Actions +- ๐Ÿ““ Interactive notebook development with marimo + +## Prerequisites + +- Python 3.12 or higher +- [Poetry](https://python-poetry.org/docs/#installation) installed + +## Getting Started + +1. Clone this repository: + + ```bash + git clone https://github.com/yourusername/marimo-poetry-starter-template + cd marimo-poetry-starter-template + ``` + +2. Install dependencies: + + ```bash + poetry install + ``` + +3. Run the marimo editor: + + ```bash + poetry run marimo edit + ``` + +## Development + +### Running Tests + +```bash +# Run testing in your regular python files +poetry run pytest tests +# Running testing in your marimo notebooks +poetry run pytest src +``` + +### Linting and formatting + +```bash +poetry run ruff check . +poetry run ruff format . +``` + +### Pre-commit hooks + +```bash +poetry run pre-commit install +poetry run pre-commit run --all-files +``` + +## Project Structure + +```markdown +โ”œโ”€โ”€ .github/ # GitHub Actions workflows +โ”œโ”€โ”€ src/ # Source code +โ”‚ โ”œโ”€โ”€ app.py # Sample marimo notebook +โ”‚ โ””โ”€โ”€ utils.py # Utility functions +โ”œโ”€โ”€ tests/ # Test files +โ”œโ”€โ”€ pyproject.toml # Project configuration +โ””โ”€โ”€ poetry.lock # Dependency lock file +``` + +## License + +MIT diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..46922ee --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,36 @@ +[tool.poetry] +authors = ["Your Name "] +description = "A starter template for marimo notebooks with Poetry" +name = "marimo-template" +packages = [{include = "src"}] +readme = "README.md" +version = "0.1.0" + +[tool.poetry.dependencies] +marimo = "^0.10.12" +python = "^3.12" + +[tool.poetry.group.dev.dependencies] +pre-commit = "^4.0.1" +pytest = "^8.0.0" +ruff = "^0.1.13" + +[build-system] +build-backend = "poetry.core.masonry.api" +requires = ["poetry-core"] + +[tool.pytest.ini_options] +pythonpath = ["."] +testpaths = ["tests", "src"] + +[tool.ruff] +line-length = 100 +target-version = "py312" + +[tool.ruff.lint] +select = [ + "E", # pycodestyle + "F", # pyflakes + "I", # isort + "B", # flake8-bugbear +] diff --git a/src/app.py b/src/app.py new file mode 100644 index 0000000..81511e2 --- /dev/null +++ b/src/app.py @@ -0,0 +1,24 @@ +import marimo + +app = marimo.App(width="medium") + + +@app.cell +def _(): + import marimo as mo + + mo.md("# marimo + Poetry!") + return (mo,) + + +@app.cell +def test_cell(): + from utils import add + + assert add(1, 2) == 3 + assert 2 == 2 + return + + +if __name__ == "__main__": + app.run() diff --git a/src/utils.py b/src/utils.py new file mode 100644 index 0000000..20707a4 --- /dev/null +++ b/src/utils.py @@ -0,0 +1,8 @@ +def add(a: int, b: int) -> int: + """Add two numbers.""" + return a + b + + +def subtract(a: int, b: int) -> int: + """Subtract b from a.""" + return a - b diff --git a/tests/test_sample.py b/tests/test_sample.py new file mode 100644 index 0000000..b038ae9 --- /dev/null +++ b/tests/test_sample.py @@ -0,0 +1,9 @@ +from src.utils import add, subtract + + +def test_add(): + assert add(1, 2) == 3 + + +def test_subtract(): + assert subtract(1, 2) == -1