Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mscolnick committed Jan 10, 2025
0 parents commit 5c10a74
Show file tree
Hide file tree
Showing 10 changed files with 256 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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 .
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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/
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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"
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[tool.poetry]
authors = ["Your Name <[email protected]>"]
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
]
24 changes: 24 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
@@ -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()
8 changes: 8 additions & 0 deletions src/utils.py
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tests/test_sample.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5c10a74

Please sign in to comment.