Skip to content

Commit

Permalink
feat: Add new module 'deepbiop' and 'add' function
Browse files Browse the repository at this point in the history
  • Loading branch information
cauliyang committed Aug 2, 2024
1 parent 66cbc6a commit 9561c60
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 24 deletions.
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
resolver = "2"
members = ["crates/*"]
members = ["crates/*", "py-deepbiop"]


[workspace.package]
version = "0.1.0"
Expand Down Expand Up @@ -61,6 +62,9 @@ flate2 = { version = "1.0.30", features = [
"zlib-ng",
], default-features = false }


deepbiop-fq = { version = "0.1.0", path = "crates/deepbiop-fq" }

[profile.opt-dev]
inherits = "dev"
opt-level = 1
Expand Down
23 changes: 0 additions & 23 deletions py-deepbiop/build.rs

This file was deleted.

1 change: 1 addition & 0 deletions py-deepbiop/deepbiop/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .deepbiop import * # noqa: F403
214 changes: 214 additions & 0 deletions py-deepbiop/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
[build-system]
requires = ["maturin>=1.0,<2.0"]
build-backend = "maturin"

[tool.maturin]
# "extension-module" tells pyo3 we want to build an extension module (skips linking against libpython.so)
features = ["pyo3/extension-module"]

[project]
name = "deepbiop"
description = "Deep Learning Preprocessing Library for Biological Data"
readme = "README.md"
requires-python = ">=3.9"
keywords = ["deep learning", "bioinformatics", "biological data"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apach License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Rust",
"Topic :: Scientific/Engineering",
]

[project.urls]
Homepage = ""


[tool.mypy]
files = ["polars", "tests"]
strict = true
enable_error_code = ["redundant-expr", "truthy-bool", "ignore-without-code"]
disable_error_code = ["empty-body"]

[[tool.mypy.overrides]]
module = [
"IPython.*",
"adbc_driver_manager.*",
"adbc_driver_sqlite.*",
"arrow_odbc",
"backports",
"connectorx",
"deltalake.*",
"fsspec.*",
"gevent",
"great_tables",
"hvplot.*",
"jax.*",
"kuzu",
"matplotlib.*",
"moto.server",
"nest_asyncio",
"openpyxl",
"polars.polars",
"pyarrow.*",
"pydantic",
"pyiceberg.*",
"sqlalchemy.*",
"torch.*",
"xlsx2csv",
"xlsxwriter.*",
"zoneinfo",
]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = ["IPython.*", "matplotlib.*"]
follow_imports = "skip"

[[tool.mypy.overrides]]
module = ["polars.*"]
# We exclude the polars module from warn_return_any, because the PyO3 api does not have Python
# type annotations. See https://github.com/PyO3/pyo3/issues/1112 for a discussion on adding
# this capability. We could add a stub file for polars.polars (the PyO3 api), but that
# amounts to duplicating almost all type annotations on our api, as the Python api itself is a
# thin wrapper around the PyO3 api to start with.
warn_return_any = false

[tool.ruff]
line-length = 88
fix = true

[tool.ruff.lint]
select = [
"E", # pycodestyle
"W", # pycodestyle
"F", # Pyflakes
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"D", # flake8-docstrings
"D213", # Augment NumPy docstring convention: Multi-line docstring summary should start at the second line
"D417", # Augment NumPy docstring convention: Missing argument descriptions
"I", # isort
"SIM", # flake8-simplify
"TCH", # flake8-type-checking
"TID", # flake8-tidy-imports
"UP", # pyupgrade
"PT", # flake8-pytest-style
"RUF", # Ruff-specific rules
"PTH", # flake8-use-pathlib
"FA", # flake8-future-annotations
"PIE", # flake8-pie
"TD", # flake8-todos
"TRY", # tryceratops
"EM", # flake8-errmsg
"FBT001", # flake8-boolean-trap
]

ignore = [
# Line length regulated by formatter
"E501",
# pydocstyle: http://www.pydocstyle.org/en/stable/error_codes.html
"D401", # Relax NumPy docstring convention: First line should be in imperative mood
# flake8-pytest-style:
"PT011", # pytest.raises({exception}) is too broad, set the match parameter or use a more specific exception
# flake8-simplify
"SIM102", # Use a single `if` statement instead of nested `if` statements
"SIM108", # Use ternary operator
# ruff
"RUF005", # unpack-instead-of-concatenating-to-collection-literal
# pycodestyle
# TODO: Remove errors below to further improve docstring linting
# Ordered from most common to least common errors.
"D105", # Missing docstring in magic method
"D100", # Missing docstring in public module
"D104", # Missing docstring in public package
# flake8-todos
"TD002", # Missing author in TODO
"TD003", # Missing issue link on the line following this TODO
# tryceratops
"TRY003", # Avoid specifying long messages outside the exception class
# Lints below are turned off because of conflicts with the ruff formatter
"D206",
"W191",
]

[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = ["D100", "D102", "D103", "B018", "FBT001"]

[tool.ruff.lint.pycodestyle]
max-doc-length = 88

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.lint.flake8-type-checking]
strict = true

[tool.ruff.format]
docstring-code-format = true

[tool.pytest.ini_options]
addopts = [
"--tb=short",
"--strict-config",
"--strict-markers",
"--import-mode=importlib",
# Default to running fast tests only. To run ALL tests, run: pytest -m ""
"-m not slow and not write_disk and not release and not docs and not hypothesis and not benchmark and not ci_only",
]
markers = [
"ci_only: Tests that should only run on CI by default.",
"debug: Tests that should be run on a Polars debug build.",
"docs: Documentation code snippets",
"release: Tests that should be run on a Polars release build.",
"slow: Tests with a longer than average runtime.",
"write_disk: Tests that write to disk",
]
filterwarnings = [
# Fail on warnings
"error",
# Allow debugging in an IPython console
"ignore:.*unrecognized arguments.*PyDevIPCompleter:DeprecationWarning",
# Ignore warnings issued by dependency internals
"ignore:.*is_sparse is deprecated.*:FutureWarning",
"ignore:FigureCanvasAgg is non-interactive:UserWarning",
"ignore:datetime.datetime.utcfromtimestamp\\(\\) is deprecated.*:DeprecationWarning",
"ignore:datetime.datetime.utcnow\\(\\) is deprecated.*:DeprecationWarning",
# Introspection under PyCharm IDE can generate this in Python 3.12
"ignore:.*co_lnotab is deprecated, use co_lines.*:DeprecationWarning",
# TODO: Excel tests lead to unclosed file warnings
# https://github.com/pola-rs/polars/issues/14466
"ignore:unclosed file.*:ResourceWarning",
# Ignore invalid warnings when running earlier versions of SQLAlchemy (we
# know they are invalid because our standard tests run the latest version)
"ignore:Deprecated API features detected.*:DeprecationWarning",
]
xfail_strict = true

[tool.coverage.run]
source = ["polars"]
branch = true

[tool.coverage.report]
fail_under = 85
skip_covered = true
show_missing = true
exclude_lines = [
"pragma: no cover",
"@overload",
"except ImportError",
"if TYPE_CHECKING:",
"from typing_extensions import ",
]
12 changes: 12 additions & 0 deletions py-deepbiop/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use pyo3::prelude::*;

#[pyfunction]
fn add(a: usize, b: usize) -> usize {
a + b
}

#[pymodule]
fn deepbiop(_py: Python, m: &PyModule) -> PyResult<()> {

Check warning on line 9 in py-deepbiop/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

use of deprecated method `pyo3::deprecations::GilRefs::<T>::function_arg`: use `&Bound<'_, T>` instead for this function argument

warning: use of deprecated method `pyo3::deprecations::GilRefs::<T>::function_arg`: use `&Bound<'_, T>` instead for this function argument --> py-deepbiop/src/lib.rs:9:26 | 9 | fn deepbiop(_py: Python, m: &PyModule) -> PyResult<()> { | ^ | = note: `#[warn(deprecated)]` on by default

Check warning on line 9 in py-deepbiop/src/lib.rs

View workflow job for this annotation

GitHub Actions / Testing (macos)

use of deprecated method `pyo3::deprecations::GilRefs::<T>::function_arg`: use `&Bound<'_, T>` instead for this function argument

Check warning on line 9 in py-deepbiop/src/lib.rs

View workflow job for this annotation

GitHub Actions / Testing (stable)

use of deprecated method `pyo3::deprecations::GilRefs::<T>::function_arg`: use `&Bound<'_, T>` instead for this function argument

Check warning on line 9 in py-deepbiop/src/lib.rs

View workflow job for this annotation

GitHub Actions / Testing (beta)

use of deprecated method `pyo3::deprecations::GilRefs::<T>::function_arg`: use `&Bound<'_, T>` instead for this function argument
m.add_function(wrap_pyfunction!(add, m)?)?;
Ok(())
}

0 comments on commit 9561c60

Please sign in to comment.