diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 352d404..90c56db 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10"] + python-version: ["3.11"] timeout-minutes: 20 steps: @@ -29,7 +29,7 @@ jobs: ssh-key: ${{ secrets.READ_LNDOCS }} path: lndocs ref: main - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: "pip" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7603a53..0ba9366 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,70 +1,56 @@ +fail_fast: false +default_language_version: + python: python3 +default_stages: + - commit + - push +minimum_pre_commit_version: 2.16.0 repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.2.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - exclude: | - (?x)( - .github/workflows/latest-changes.jinja2 - ) - - id: check-yaml - - id: check-added-large-files - - repo: https://github.com/psf/black - rev: 22.6.0 - hooks: - - id: black-jupyter - - repo: https://github.com/pycqa/flake8 - rev: 4.0.1 + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v4.0.0-alpha.4 hooks: - - id: flake8 - additional_dependencies: - - flake8-black==0.3.3 - - flake8-typing-imports==1.10.0 - language_version: python3 - args: - - --max-line-length=88 - - --ignore=E203,E501,W503,BLK100 + - id: prettier exclude: | (?x)( - __init__.py + docs/changelog.md ) - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v2.6.2 - hooks: - - id: prettier - repo: https://github.com/kynan/nbstripout - rev: 0.3.9 + rev: 0.6.1 hooks: - id: nbstripout exclude: | (?x)( - docs/static/ + docs/static/| + docs/examples/| + docs/notes/ ) - - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.1.9 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.7 hooks: - - id: forbid-crlf - - id: remove-crlf - - repo: https://github.com/pycqa/isort - rev: 5.12.0 + - id: ruff + args: [--fix, --exit-non-zero-on-fix, --unsafe-fixes] + - id: ruff-format + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 hooks: - - id: isort - name: isort (python) - args: ["--profile", "black"] + - id: detect-private-key + - id: check-ast + - id: end-of-file-fixer + exclude: | + (?x)( + .github/workflows/latest-changes.jinja2 + ) + - id: mixed-line-ending + args: [--fix=lf] + - id: trailing-whitespace + - id: check-case-conflict - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.940 + rev: v1.7.1 hooks: - id: mypy - - repo: https://github.com/pycqa/pydocstyle - rev: 6.1.1 - hooks: - - id: pydocstyle - args: # google style + __init__, see http://www.pydocstyle.org/en/stable/error_codes.html - - --ignore=D100,D101,D102,D103,D106,D107,D203,D204,D213,D215,D400,D401,D403,D404,D406,D407,D408,D409,D412,D413 - - repo: https://github.com/asottile/pyupgrade - rev: v3.3.1 - hooks: - - id: pyupgrade - description: Automatically upgrade syntax for newer versions. - args: [--py38-plus] + args: [--no-strict-optional, --ignore-missing-imports] + additional_dependencies: ["types-requests", "types-attrs"] + exclude: | + (?x)( + test_notebooks.py + ) diff --git a/docs/vitessce.ipynb b/docs/vitessce.ipynb index 8e9a803..797c6dc 100644 --- a/docs/vitessce.ipynb +++ b/docs/vitessce.ipynb @@ -261,7 +261,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "lamindb", "language": "python", "name": "python3" }, @@ -275,7 +275,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.7" } }, "nbformat": 4, diff --git a/noxfile.py b/noxfile.py index 1bd1832..ae01ebd 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,6 +1,13 @@ import nox from laminci import upload_docs_artifact -from laminci.nox import build_docs, login_testuser1, run_pre_commit +from laminci.nox import ( + SYSTEM, + build_docs, + install_lamindb, + login_testuser1, + run, + run_pre_commit, +) nox.options.default_venv_backend = "none" @@ -12,22 +19,9 @@ def lint(session: nox.Session) -> None: @nox.session def build(session): - session.run( - "uv", - "pip", - "install", - "--system", - "lamindb[bionty] @ git+https://github.com/laminlabs/lamindb@main", - ) - session.run(*"uv pip install --system -r requirements.txt".split()) - session.run( - "uv", - "pip", - "install", - "--system", - "lamindb_setup @ git+https://github.com/laminlabs/lamindb-setup@main", - ) + install_lamindb(session, branch="release", extras="bionty,aws,gcp,jupyter") + run(session, f"uv pip install {SYSTEM} .[dev,use_case]") login_testuser1(session) - session.run(*"pytest -s tests".split()) + run(session, "pytest -s tests") build_docs(session, strict=True) upload_docs_artifact(aws=True) diff --git a/pyproject.toml b/pyproject.toml index 0db4a2a..c68fd10 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["flit_core >=3.2,<4"] build-backend = "flit_core.buildapi" [project] -name = "rxrx_lamin" +name = "lamin_spatial" authors = [{name = "Lamin Labs", email = "laminlabs@gmail.com"}] readme = "README.md" dynamic = ["version", "description"] @@ -20,11 +20,112 @@ dev = [ "pytest-cov", "nbproject_test", ] - -[tool.black] -preview = true +use_case = [ + "wetlab", + "findrefs", + "vitessce", + "starlette", + "duckdb", + "s3fs>=2024.10.0" # gets downgraded by vitessce/starlette but needs to be recent +] [tool.pytest.ini_options] testpaths = [ "tests", ] + +[tool.ruff] +src = ["src"] +line-length = 88 +select = [ + "F", # Errors detected by Pyflakes + "E", # Error detected by Pycodestyle + "W", # Warning detected by Pycodestyle + "I", # isort + "D", # pydocstyle + "B", # flake8-bugbear + "TID", # flake8-tidy-imports + "C4", # flake8-comprehensions + "BLE", # flake8-blind-except + "UP", # pyupgrade + "RUF100", # Report unused noqa directives + "TCH", # Typing imports + "NPY", # Numpy specific rules + "PTH" # Use pathlib +] +ignore = [ + # Do not catch blind exception: `Exception` + "BLE001", + # Errors from function calls in argument defaults. These are fine when the result is immutable. + "B008", + # line too long -> we accept long comment lines; black gets rid of long code lines + "E501", + # Do not assign a lambda expression, use a def -> lambda expression assignments are convenient + "E731", + # allow I, O, l as variable names -> I is the identity matrix + "E741", + # Missing docstring in public module + "D100", + # undocumented-public-class + "D101", + # Missing docstring in public method + "D102", + # Missing docstring in public function + "D103", + # Missing docstring in public package + "D104", + # __magic__ methods are are often self-explanatory, allow missing docstrings + "D105", + # Missing docstring in public nested class + "D106", + # Missing docstring in __init__ + "D107", + ## Disable one in each pair of mutually incompatible rules + # We don’t want a blank line before a class docstring + "D203", + # 1 blank line required after class docstring + "D204", + # first line should end with a period [Bug: doesn't work with single-line docstrings] + # We want docstrings to start immediately after the opening triple quote + "D213", + # Section underline is over-indented ("{name}") + "D215", + # First line should end with a period + "D400", + # First line should be in imperative mood; try rephrasing + "D401", + # First word of the first line should be capitalized: {} -> {} + "D403", + # First word of the docstring should not be "This" + "D404", + # Section name should end with a newline ("{name}") + "D406", + # Missing dashed underline after section ("{name}") + "D407", + # Section underline should be in the line following the section's name ("{name}") + "D408", + # Section underline should match the length of its name ("{name}") + "D409", + # No blank lines allowed between a section header and its content ("{name}") + "D412", + # Missing blank line after last section ("{name}") + "D413", + # Missing argument description + "D417", + # Imports unused + "F401", + # camcelcase imported as lowercase + "N813", + # module import not at top level of file + "E402", + # open()` should be replaced by `Path.open() + "PTH123", +] + +[tool.ruff.pydocstyle] +convention = "google" + +[tool.ruff.per-file-ignores] +"docs/*" = ["I"] +"tests/*" = ["D"] +"*/__init__.py" = ["F401"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index ec9310a..0000000 --- a/requirements.txt +++ /dev/null @@ -1,13 +0,0 @@ -wetlab@git+https://github.com/laminlabs/wetlab -findrefs@git+https://github.com/laminlabs/findrefs -nbproject -s3fs -gcsfs -pre-commit -nox -pytest>=6.0 -pytest-cov -nbproject_test -vitessce -starlette # for vitessce -duckdb