Skip to content

Make scan to be a cython extension #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
if: github.repository == 'pymc-devs/pytensor'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: actions/setup-python@v3
with:
python-version: "3.9"
- name: Install dependencies
Expand Down
33 changes: 26 additions & 7 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,47 @@ concurrency:
cancel-in-progress: true

jobs:
# The job to build pypi wheels users can installed precompiled for them.
# At the moment only linux wheels are build, Windows and MacOS will compile on installation
# Before prebuilds all users had to compile code anyway.
build:
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: actions/setup-python@v3
with:
python-version: "3.8"
python-version: ${{ matrix.python-version }}
- name: Build the sdist and the wheel
run: |
pip install wheel
python setup.py sdist bdist_wheel
pip install build
python -m build
- name: Check the sdist installs and imports
run: |
mkdir -p test-sdist
cd test-sdist
python -m venv venv-sdist
venv-sdist/bin/python -m pip install ../dist/pytensor-*.tar.gz
# check import
venv-sdist/bin/python -c "import pytensor;print(pytensor.__version__)"
- uses: actions/upload-artifact@v2
# check import cython module
venv-sdist/bin/python -c 'from pytensor.scan import scan_perform; print(scan_perform.get_version())'
- name: Check the bdist installs and imports
run: |
mkdir -p test-bdist
cd test-bdist
python -m venv venv-bdist
venv-bdist/bin/python -m pip install ../dist/pytensor-*.whl
# check import
venv-bdist/bin/python -c "import pytensor;print(pytensor.__version__)"
# check import cython module
venv-bdist/bin/python -c 'from pytensor.scan import scan_perform; print(scan_perform.get_version())'
- uses: actions/upload-artifact@v3
with:
name: artifact
path: dist/*
Expand All @@ -49,7 +68,7 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
outputs:
changes: ${{ steps.changes.outputs.src }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: dorny/paths-filter@v2
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ needs.changes.outputs.changes == 'true' }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: '3.9'
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
install-numba: 1
part: "tests --ignore=tests/tensor/nnet --ignore=tests/tensor/signal"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -110,7 +110,7 @@ jobs:
echo $MATRIX_CONTEXT
export MATRIX_ID=`echo $MATRIX_CONTEXT | md5sum | cut -c 1-32`
echo $MATRIX_ID
echo "::set-output name=id::$MATRIX_ID"
echo "id=$MATRIX_ID" >> $GITHUB_OUTPUT

- name: Install dependencies
shell: bash -l {0}
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
FLOAT32: ${{ matrix.float32 }}

- name: Upload coverage file
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage/coverage-${{ steps.matrix-id.outputs.id }}.xml
Expand All @@ -164,7 +164,7 @@ jobs:
needs: [changes, all-checks]
if: ${{ needs.changes.outputs.changes == 'true' && needs.all-checks.result == 'success' }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ __pycache__
.coverage
*.linkinfo
*.o
*.c
*.orig
*.pyc
*.pyo
Expand Down
File renamed without changes.
208 changes: 208 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
[build-system]
requires = [
"setuptools>=48.0.0",
"cython",
"numpy>=1.17.0",
"versioneer[toml]==0.28",
]
build-backend = "setuptools.build_meta"

[project]
name = "pytensor"
dynamic = [
'version'
]
requires-python = ">=3.7"
authors = [
{name = "pymc-devs", email = "[email protected]"}
]
description = "Optimizing compiler for evaluating mathematical expressions on CPUs and GPUs."
readme = "DESCRIPTION.rst"
license = {file = "LICENCE.txt"}
classifiers = [
"Development Status :: 6 - Mature",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Topic :: Software Development :: Code Generators",
"Topic :: Software Development :: Compilers",
"Topic :: Scientific/Engineering :: Mathematics",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
]

keywords = [
"pytensor",
"math",
"numerical",
"symbolic",
"blas",
"numpy",
"autodiff",
"differentiation",
]
dependencies = [
"setuptools>=48.0.0",
"scipy>=0.14",
"numpy>=1.17.0",
"filelock",
"etuples",
"logical-unification",
"miniKanren",
"cons",
"typing_extensions",
]

[project.urls]
homepage = "https://github.com/pymc-devs/pytensor"
repository = "https://github.com/pymc-devs/pytensor"
documentation = "https://pytensor.readthedocs.io/en/latest/"


[project.scripts]
pytensor-cache = "bin.pytensor_cache:main"

[project.optional-dependencies]
complete = [
"pytensor[jax]",
"pytensor[numba]",
]
development = [
"pytensor[complete]",
"pytensor[tests]",
"pytensor[rtd]"
]
tests = [
"pytest",
"pre-commit",
"pytest-cov>=2.6.1",
"coverage>=5.1",
]
rtd = [
"sphinx>=1.3.0",
"sphinx_rtd_theme",
"pygments",
"pydot",
"pydot2",
"pydot-ng",
]
jax = [
"jax",
"jaxlib",
]
numba = [
"numba>=0.55",
"numba-scipy>=0.3.0"
]

[tool.setuptools.packages.find]
exclude = [
"tests",
"tests.*"
]

[tool.setuptools.package-data]
"*" = [
"*.txt",
"*.rst",
"*.cu",
"*.cuh",
"*.c",
"*.sh",
"*.pkl",
"*.h",
"*.cpp",
"ChangeLog",
"c_code/*",
]
pytensor = [
"py.typed"
]
"pytensor.misc" = [
"*.sh"
]
"pytensor.d3viz" = [
"html/*",
"css/*",
"js/*",
]

[tool.coverage.run]
omit = [
"pytensor/_version.py",
"tests/*",
"pytensor/assert_op.py",
"pytensor/graph/opt.py",
"pytensor/graph/opt_utils.py",
"pytensor/graph/optdb.py",
"pytensor/graph/kanren.py",
"pytensor/graph/unify.py",
"pytensor/link/jax/jax_linker.py",
"pytensor/link/jax/jax_dispatch.py",
"pytensor/graph/toolbox.py",
"pytensor/scalar/basic_scipy.py",
Comment on lines +143 to +152
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these get deleted in your other PR, right?

We should remember to update this after rebasing the other PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, one of these PRs goes first

]
branch = true
relative_files = true

[tool.coverage.report]
omit = [
"pytensor/_version.py",
"tests/",
]
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:",
]
show_missing = true

[tool.versioneer]
VCS = "git"
style = "pep440"
versionfile_source = "pytensor/_version.py"
versionfile_build = "pytensor/_version.py"
tag_prefix = "rel-"

[tool.pytest]
addopts = "--durations=50"
testpaths = "tests/"

[tool.pylint]
max-line-length = 88

[tool.pylint.messages_control]
disable = ["C0330", "C0326"]

[tool.isort]
profile = "black"
lines_after_imports = 2
lines_between_sections = 1
honor_noqa = true
skip_gitignore = true
skip = "pytensor/version.py"
skip_glob = "**/*.pyx"

[tool.mypy]
ignore_missing_imports = true
no_implicit_optional = true
check_untyped_defs = false
strict_equality = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unused_ignores = true
warn_return_any = true
warn_no_return = false
warn_unreachable = true
show_error_codes = true
allow_redefinition = false
files = ["pytensor", "tests"]
plugins = ["numpy.typing.mypy_plugin"]
6 changes: 2 additions & 4 deletions pytensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
from functools import singledispatch
from typing import Any, NoReturn, Optional

from pytensor.version import version as __version__


pytensor_logger = logging.getLogger("pytensor")
logging_default_handler = logging.StreamHandler()
Expand All @@ -49,10 +51,6 @@ def disable_log_handler(logger=pytensor_logger, handler=logging_default_handler)
logger.removeHandler(handler)


# Version information.
from pytensor.version import version as __version__


# Raise a meaningful warning/error if the pytensor directory is in the Python
# path.
rpath = os.path.realpath(__path__[0])
Expand Down
Loading