Metadata-Version: 2.4
Name: scitex-decorators
Version: 0.1.3
Summary: Decorator library: numpy_fn/torch_fn/pandas_fn/xarray_fn/signal_fn type converters, caching, batching, deprecation — standalone module from the SciTeX ecosystem
Author-email: Yusuke Watanabe <ywatanabe@scitex.ai>
License-Expression: AGPL-3.0-only
Project-URL: Homepage, https://github.com/ywatanabe1989/scitex-decorators
Project-URL: Repository, https://github.com/ywatanabe1989/scitex-decorators
Project-URL: Documentation, https://scitex-decorators.readthedocs.io
Keywords: scitex,decorators,caching,joblib,numpy,torch
Classifier: Development Status :: 3 - Alpha
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: tqdm
Provides-Extra: caching
Requires-Dist: joblib; extra == "caching"
Provides-Extra: pandas
Requires-Dist: pandas; extra == "pandas"
Provides-Extra: torch
Requires-Dist: torch; extra == "torch"
Provides-Extra: xarray
Requires-Dist: xarray; extra == "xarray"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: joblib; extra == "dev"
Requires-Dist: pandas; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx>=7.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=2.0; extra == "docs"
Requires-Dist: myst-parser>=2.0; extra == "docs"
Requires-Dist: sphinx-copybutton>=0.5; extra == "docs"
Requires-Dist: sphinx-autodoc-typehints>=1.25; extra == "docs"
Provides-Extra: all
Requires-Dist: scitex-decorators[caching]; extra == "all"
Requires-Dist: scitex-decorators[pandas]; extra == "all"
Requires-Dist: scitex-decorators[torch]; extra == "all"
Requires-Dist: scitex-decorators[xarray]; extra == "all"
Dynamic: license-file

# scitex-decorators

<!-- scitex-badges:start -->
[![PyPI](https://img.shields.io/pypi/v/scitex-decorators.svg)](https://pypi.org/project/scitex-decorators/)
[![Python](https://img.shields.io/pypi/pyversions/scitex-decorators.svg)](https://pypi.org/project/scitex-decorators/)
[![Tests](https://github.com/ywatanabe1989/scitex-decorators/actions/workflows/test.yml/badge.svg)](https://github.com/ywatanabe1989/scitex-decorators/actions/workflows/test.yml)
[![Install Test](https://github.com/ywatanabe1989/scitex-decorators/actions/workflows/install-test.yml/badge.svg)](https://github.com/ywatanabe1989/scitex-decorators/actions/workflows/install-test.yml)
[![Coverage](https://codecov.io/gh/ywatanabe1989/scitex-decorators/graph/badge.svg)](https://codecov.io/gh/ywatanabe1989/scitex-decorators)
[![Docs](https://readthedocs.org/projects/scitex-decorators/badge/?version=latest)](https://scitex-decorators.readthedocs.io/en/latest/)
[![License: AGPL v3](https://img.shields.io/badge/license-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
<!-- scitex-badges:end -->


Decorator library extracted from the [SciTeX](https://github.com/ywatanabe1989/scitex-python) ecosystem as a standalone package.

## Install

```bash
pip install scitex-decorators              # core (numpy only)
pip install "scitex-decorators[caching]"   # + joblib for cache_disk
pip install "scitex-decorators[torch]"     # + torch_fn / batch_torch_fn
pip install "scitex-decorators[all]"       # everything
```

## API

```python
import scitex_decorators as dec

# Type-conversion decorators (cast args before calling, restore after)
@dec.numpy_fn  ; @dec.torch_fn  ; @dec.pandas_fn  ; @dec.xarray_fn
@dec.signal_fn

# Caching (joblib for disk, dict for mem)
@dec.cache_disk        ; @dec.cache_disk_async    ; @dec.cache_mem

# Batching
@dec.batch_fn          ; @dec.batch_numpy_fn / batch_torch_fn / batch_pandas_fn

# Misc
@dec.deprecated(reason="…")
@dec.not_implemented
@dec.preserve_doc
@dec.timeout(seconds=10)
@dec.wrap

# Auto-ordering machinery (advanced)
dec.enable_auto_order() ; dec.disable_auto_order()

# Conversion helpers
dec.to_numpy(x) ; dec.to_torch(x)
dec.is_torch(x) ; dec.is_cuda(x) ; dec.is_nested_decorator(...)
```

## Cache directory resolution

`cache_disk` / `cache_disk_async` resolve the cache dir in this order:

1. `scitex.config.get_paths().function_cache` (only if scitex is installed)
2. `${SCITEX_CACHE_DIR}/function_cache`
3. `${XDG_CACHE_HOME}/scitex-decorators/function_cache`
4. `~/.cache/scitex-decorators/function_cache`

So the package works without the umbrella scitex installed.

## Status

Standalone fork of `scitex.decorators`. Zero scitex.* runtime deps. The
umbrella package's `scitex.decorators` import path is preserved via a
`sys.modules`-alias bridge.

## License

AGPL-3.0-only (see [LICENSE](./LICENSE)).
