Skip to content

Commit

Permalink
Merge branch 'main' into codeflash/optimize-_make_forest_dict-2024-03…
Browse files Browse the repository at this point in the history
…-24T23.13.47
  • Loading branch information
misrasaurabh1 authored Mar 29, 2024
2 parents a54d52c + 3ceb740 commit 457861d
Show file tree
Hide file tree
Showing 191 changed files with 8,425 additions and 6,580 deletions.
78 changes: 41 additions & 37 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
trigger:
- master
- main
- "*.*.x"

variables:
python.version: '3.11'
PIP_CACHE_DIR: $(Pipeline.Workspace)/.pip
PYTEST_ADDOPTS: '-v --color=yes --durations=0 --nunit-xml=test-data/test-results.xml'
ANNDATA_DEV: no
RUN_COVERAGE: no
python.version: '3.12'
PYTEST_ADDOPTS: '-v --color=yes --nunit-xml=test-data/test-results.xml'
TEST_EXTRA: 'test-full'
PRERELEASE_DEPENDENCIES: no
DEPENDENCIES_VERSION: "latest" # |"pre-release" | "minimum-version"
TEST_TYPE: "standard" # | "coverage"

jobs:
- job: PyTest
Expand All @@ -19,84 +17,90 @@ jobs:
matrix:
Python3.9:
python.version: '3.9'
Python3.11: {}
minimal_tests:
Python3.12: {}
minimal_dependencies:
TEST_EXTRA: 'test-min'
anndata_dev:
ANNDATA_DEV: yes
RUN_COVERAGE: yes
PRERELEASE_DEPENDENCIES: yes
DEPENDENCIES_VERSION: "pre-release"
TEST_TYPE: "coverage"
minimum_versions:
python.version: '3.9'
DEPENDENCIES_VERSION: "minimum-version"
TEST_TYPE: "coverage"


steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'

- script: |
python -m pip install --upgrade uv
echo "##vso[task.setvariable variable=uv_cache_dir]`uv cache dir`"
displayName: 'Install tools'
- task: Cache@2
inputs:
key: '"python $(python.version)" | "$(Agent.OS)" | pyproject.toml'
restoreKeys: |
python | "$(Agent.OS)"
python
path: $(PIP_CACHE_DIR)
path: $(uv_cache_dir)
displayName: Cache pip packages

- script: |
export MPLBACKEND="agg"
echo $MPLBACKEND
displayName: 'Set env'
- script: |
python -m pip install --upgrade pip
pip install wheel coverage
pip install .[dev,$(TEST_EXTRA)]
- script: uv pip install --system --compile 'scanpy[dev,$(TEST_EXTRA)] @ .'
displayName: 'Install dependencies'
condition: eq(variables['PRERELEASE_DEPENDENCIES'], 'no')
condition: eq(variables['DEPENDENCIES_VERSION'], 'latest')

- script: |
python -m pip install --pre --upgrade pip
pip install --pre wheel coverage
pip install --pre .[dev,$(TEST_EXTRA)]
- script: >
uv pip install --system --compile --pre
"scanpy[dev,$(TEST_EXTRA)] @ ."
"anndata[dev,test] @ git+https://github.com/scverse/anndata"
displayName: 'Install dependencies release candidates'
condition: eq(variables['PRERELEASE_DEPENDENCIES'], 'yes')
condition: eq(variables['DEPENDENCIES_VERSION'], 'pre-release')
- script: |
pip install -v "anndata[dev,test] @ git+https://github.com/scverse/anndata"
displayName: 'Install development anndata'
condition: eq(variables['ANNDATA_DEV'], 'yes')
uv pip install --system --compile tomli packaging
deps=`python3 ci/scripts/min-deps.py pyproject.toml --extra dev test`
uv pip install --system --compile $deps "scanpy @ ."
displayName: 'Install dependencies minimum version'
condition: eq(variables['DEPENDENCIES_VERSION'], 'minimum-version')
- script: |
pip list
- script: uv pip list
displayName: 'Display installed versions'

- script: pytest
displayName: 'PyTest'
condition: eq(variables['RUN_COVERAGE'], 'no')
condition: eq(variables['TEST_TYPE'], 'standard')

- script: |
coverage run -m pytest
coverage xml
pytest --cov --cov-report=xml --cov-context=test
displayName: 'PyTest (coverage)'
condition: eq(variables['RUN_COVERAGE'], 'yes')
condition: eq(variables['TEST_TYPE'], 'coverage')
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: 'test-data/coverage.xml'
failIfCoverageEmpty: true
condition: eq(variables['RUN_COVERAGE'], 'yes')
condition: eq(variables['TEST_TYPE'], 'coverage')

- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: 'test-data/test-results.xml'
testResultsFormat: NUnit
testRunTitle: 'Publish test results for Python $(python.version)'
testRunTitle: 'Publish test results for $(Agent.JobName)'

- script: bash <(curl -s https://codecov.io/bash)
displayName: 'Upload to codecov.io'
condition: eq(variables['RUN_COVERAGE'], 'yes')
condition: eq(variables['TEST_TYPE'], 'coverage')

- job: CheckBuild
pool:
Expand All @@ -105,8 +109,8 @@ jobs:

- task: UsePythonVersion@0
inputs:
versionSpec: '3.11'
displayName: 'Use Python 3.11'
versionSpec: '3.12'
displayName: 'Use Python 3.12'

- script: |
python -m pip install --upgrade pip
Expand Down
1 change: 0 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ coverage:
default:
# Require 1% coverage, i.e., always succeed
target: 1
patch: false
changes: false

comment:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ body:
required: true
- label: I have confirmed this bug exists on the latest version of scanpy.
required: true
- label: (optional) I have confirmed this bug exists on the master branch of scanpy.
- label: (optional) I have confirmed this bug exists on the main branch of scanpy.
required: false
- type: markdown
attributes:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
blank_issues_enabled: false
blank_issues_enabled: true
contact_links:
- name: Scanpy Community Forum
url: https://discourse.scverse.org/
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
pull_request:
branches:
- main
- master
types:
# milestone changes
- milestoned
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "notebooks"]
path = notebooks
url = https://github.com/scverse/scanpy-tutorials/
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
rev: v0.3.4
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
Expand All @@ -26,7 +26,7 @@ repos:
- id: check-merge-conflict
- id: detect-private-key
- id: no-commit-to-branch
args: ["--branch=master", "--branch=main"]
args: ["--branch=main"]

ci:
autofix_prs: false
4 changes: 3 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
version: 2
submodules:
include: all
build:
os: ubuntu-20.04
tools:
python: '3.11'
python: '3.12'
sphinx:
fail_on_warning: true # do not change or you will be fired
configuration: docs/conf.py
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Contributing code
-----------------

We love code contributions!
If you're interested in contributing code, please take a look over the [contributing guide](https://scanpy.readthedocs.io/en/latest/dev/index.html) in the main documentation.
If you're interested in contributing code, please take a look over the [contribution guide](https://scanpy.readthedocs.io/en/latest/dev/index.html) in the main documentation.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@
[![Downloads](https://static.pepy.tech/badge/scanpy)](https://pepy.tech/project/scanpy)
[![Conda](https://img.shields.io/conda/dn/conda-forge/scanpy?logo=Anaconda)](https://anaconda.org/conda-forge/scanpy)
[![Docs](https://readthedocs.com/projects/icb-scanpy/badge/?version=latest)](https://scanpy.readthedocs.io)
[![Build Status](https://dev.azure.com/scverse/scanpy/_apis/build/status/theislab.scanpy?branchName=master)](https://dev.azure.com/scverse/scanpy/_build)
[![Build Status](https://dev.azure.com/scverse/scanpy/_apis/build/status/theislab.scanpy?branchName=main)](https://dev.azure.com/scverse/scanpy/_build)
[![Discourse topics](https://img.shields.io/discourse/posts?color=yellow&logo=discourse&server=https%3A%2F%2Fdiscourse.scverse.org)](https://discourse.scverse.org/)
[![Chat](https://img.shields.io/badge/zulip-join_chat-%2367b08f.svg)](https://scverse.zulipchat.com)
[![Powered by NumFOCUS](https://img.shields.io/badge/powered%20by-NumFOCUS-orange.svg?style=flat&colorA=E1523D&colorB=007D8A)](https://numfocus.org/)

# Scanpy – Single-Cell Analysis in Python

Scanpy is a scalable toolkit for analyzing single-cell gene expression data
built jointly with [anndata](https://anndata.readthedocs.io). It includes
built jointly with [anndata][]. It includes
preprocessing, visualization, clustering, trajectory inference and differential
expression testing. The Python-based implementation efficiently deals with
datasets of more than one million cells.

Discuss usage on the scverse [Discourse]. Read the [documentation].
If you'd like to contribute by opening an issue or creating a pull request, please take a look at our [contributing guide].
Discuss usage on the scverse [Discourse][]. Read the [documentation][].
If you'd like to contribute by opening an issue or creating a pull request, please take a look at our [contribution guide][].

[anndata]: https://anndata.readthedocs.io
[discourse]: https://discourse.scverse.org/
[documentation]: https://scanpy.readthedocs.io

[//]: # (numfocus-fiscal-sponsor-attribution)

Expand Down Expand Up @@ -52,6 +56,5 @@ You can cite the scverse publication as follows:
>
> _Nat Biotechnol._ 2023 Apr 10. doi: [10.1038/s41587-023-01733-8](https://doi.org/10.1038/s41587-023-01733-8).
[contributing guide]: CONTRIBUTING.md
[discourse]: https://discourse.scverse.org/
[documentation]: https://scanpy.readthedocs.io

[contribution guide]: CONTRIBUTING.md
99 changes: 99 additions & 0 deletions ci/scripts/min-deps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!python3
from __future__ import annotations

import argparse
import sys
from collections import deque
from pathlib import Path
from typing import TYPE_CHECKING

if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib

from packaging.requirements import Requirement
from packaging.version import Version

if TYPE_CHECKING:
from collections.abc import Generator, Iterable


def min_dep(req: Requirement) -> Requirement:
"""
Given a requirement, return the minimum version specifier.
Example
-------
>>> min_dep(Requirement("numpy>=1.0"))
"numpy==1.0"
"""
req_name = req.name
if req.extras:
req_name = f"{req_name}[{','.join(req.extras)}]"

if not req.specifier:
return Requirement(req_name)

min_version = Version("0.0.0.a1")
for spec in req.specifier:
if spec.operator in [">", ">=", "~="]:
min_version = max(min_version, Version(spec.version))
elif spec.operator == "==":
min_version = Version(spec.version)

return Requirement(f"{req_name}=={min_version}.*")


def extract_min_deps(
dependencies: Iterable[Requirement], *, pyproject
) -> Generator[Requirement, None, None]:
dependencies = deque(dependencies) # We'll be mutating this
project_name = pyproject["project"]["name"]

while len(dependencies) > 0:
req = dependencies.pop()

# If we are referring to other optional dependency lists, resolve them
if req.name == project_name:
assert req.extras, f"Project included itself as dependency, without specifying extras: {req}"
for extra in req.extras:
extra_deps = pyproject["project"]["optional-dependencies"][extra]
dependencies += map(Requirement, extra_deps)
else:
yield min_dep(req)


def main():
parser = argparse.ArgumentParser(
prog="min-deps",
description="""Parse a pyproject.toml file and output a list of minimum dependencies.
Output is directly passable to `pip install`.""",
usage="pip install `python min-deps.py pyproject.toml`",
)
parser.add_argument(
"path", type=Path, help="pyproject.toml to parse minimum dependencies from"
)
parser.add_argument(
"--extras", type=str, nargs="*", default=(), help="extras to install"
)

args = parser.parse_args()

pyproject = tomllib.loads(args.path.read_text())

project_name = pyproject["project"]["name"]
deps = [
*map(Requirement, pyproject["project"]["dependencies"]),
*(Requirement(f"{project_name}[{extra}]") for extra in args.extras),
]

min_deps = extract_min_deps(deps, pyproject=pyproject)

print(" ".join(map(str, min_deps)))


if __name__ == "__main__":
main()
Loading

0 comments on commit 457861d

Please sign in to comment.