semvec/pypi-packages huggingface dataset:
kagami 3.2.3
A framework to support functional programming for computational biology algorithm development

[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
[![Python 2.7](https://img.shields.io/badge/python-2.7-green.svg)](https://www.python.org/downloads/release/python-2715/)
[![Python 3.7](https://img.shields.io/badge/python-3.7-green.svg)](https://www.python.org/downloads/release/python-375/)
[![PyPI version](https://badge.fury.io/py/kagami.svg)](https://badge.fury.io/py/kagami)


# Kagami Library

The Kagami library is a Python package to accelerate the development of novel computational biology algorithms. 
It is currently under rapid growth. Although the APIs are aimed to remain consistent within a major version, compatible between releases are not guaranteed. 
Please note that there is no plan to include documents anytime soon. 

The Kagami library is distributed under the GNU Lesser General Public License v3.0.


## Installation

Using pip:
```bash
pip install kagami
```


### Testing

```bash
python -c "import kagami; kagami.test()"
```


## Citation

If you use Kagami, ACS or MOCHA in a publication, we would appreciate citations: (coming soon)

<img src="https://i.imgur.com/p3207Et.png" alt="Kagami is part of Albert's scientific toolbox." width="100"/>
pygating 1.0.6
A small package for creating and using configurations to control code flow
Requires Python: >=3.7

[![Python tests](https://github.com/atsaplin/pygating/actions/workflows/python-package.yml/badge.svg?branch=main)](https://github.com/atsaplin/pygating/actions/workflows/python-package.yml)

# PyGating

PyGating is a small but simple python library that enables you to quickly introduce a/b testing, control code flow, and introduce control switches to your codebase that can be controlled via both code and json-based configs.

PyGating supports entity-based checks, allowing you to define in the gating configuration exactly the properties, functions, and/or keys the gate will check based on a entity you will pass in at check time.

Check out the respository [here](https://github.com/atsaplin/pygating) for more information and documentation

## Features

- **Extensible Framework**: Create custom gates by extending base gate classes.
- **Entity-based gates**: Define gate configurations based on entity properties/functions to make gates dynamic
- **Consistant Hashing**: Entity-based gate checks will pass/fail consistently based on property hashing
- **JSON Configuration**: Supports gate configuration defined in json so that you can pull gates configs from databases
- **Predefined Gates**: Includes `DateGate`, `PercentageGate`, `RandomGate`, `InclusionGate`, and more.
- **Custom Gate Configurations**: Combine gates to create complex gating logic.

## Quick Usage Example
This example will only permit 10% of entities/code invocations to continue.

We can use either a RandomGate for pure 10% random chance or a PercentageGate for a consistant result based on the passed entity

- Initialize Pygating Library and imports
```python
from pygating import PyGating
from pygating.gating_configurations import GatingConfigurationAll
from pygating.gates import PercentageGate

PyGating.init() # only needs to be done once in the application
```
- Define a gate config (code or json):

Code-based config
```python
gate_config = GatingConfigurationAll(
    fail_closed=True, #if an exception is thrown, the gate check returns False
    gates=[
        PercentageGate(percentage=10, allow=True, entity_property="id") # 10% of entities passed into the gate check will pass based on their id field 
    ]
)
```
##### or
Json-based config
```json
gate_config = {
    "type": "GatingConfigurationAll",
    "fail_closed": true,
    "gates": [
        {
            "type": "PercentageGate",
            "percentage": 10.0,
            "allow": true,
            "entity_property": "id"
        }
    ]
}
```
- Use gate in your code:
```python
class Entity:
    def __init__(self, id: str):
        self.id = id

example_entity = Entity(id="dfa2oi1nrffvnoivwe")

if PyGating.check_gating(gate_config, entity=entity):
    print("Gate passed!") # Will pass for 10% of entity ids, and will be consistent for the same ids
else:
    print("Gate Failed")
```

## Installation
```bash
pip install pygating
```