semvec/pypi-packages huggingface dataset:
pybalancer 1.0
an simple load balancer for Python

# pybalancer
**pybalancer** an simple load balancer for Python

## Features

English

* a simple load balancer
* consistent Hash Load Balance using **uhashring** ketama hash function
* periodly health checks, remove failed instance and add when it recovers
* manually call remove_instance when it fails.


## Installation
Using pip:

```
$ pip install pybalaner
```

## Basic usage

**pybalancer** is very simple and efficient to use:

```python
from pybalancer import LoadBalancer

# create a consistent hash ring of 3 nodes of weight 1
balancer = LoadBalancer(instances=['node1:port1', 'node2:port2', 'node3:port3'], interval=5)

# get the node name for the remote_addr key
target_instance = balancer.get_instance(remote_addr="host:port")

failed_times = 0
# call target_instance fails
if call(target_instance):
	failed_times += 1
	if failed_times > max_fails:
		balancer.remove_instance(target_instance)


alive_instances = balancer.get_alive_instances()
print(alive_instances)
```
levenshtein-dna 0.0.4
Levenshtein distance for DNA sequences.
Requires Python: >=3.6

## levenshtein_dna
Levenshtein distance for DNA sequences.


Levenshtein distance measures the minimum number of substitutions, deletions, and insertions required to make two 
strings equal. Typically, the criteria for substitution is the occurrence of two different characters at identical 
indices. However, this strict rule is insufficient if more than one character at a given location constitutes a match—as 
can be the case with functional DNA sequences. 

Here, [the IUPAC nucleotide codes](http://www.bioinformatics.org/sms/iupac.html) serve as the valid alphabet, therefore
allowing us to calculate distances between sequences with variable bases.

<sub>Levenshtein distance is calculated with **Algorithm X** from Fischer and Wagner's 
[The String-to-String Correction Problem](https://dl.acm.org/doi/10.1145/321796.321811).</sub>


## Installation
Install with pip:
```bash
pip install levenshtein-dna
```

## Usage
**Example 1:** Calculate the Levenshtein distance between the 5' splice site consensus and a candidate sequence.

```python

import levenshtein_dna

donor_consensus = 'MAGGTRAGT'  # M indicates A or C; R indicates A or G.
donor_candidate = 'AAGGTTAGT'

distance = levenshtein_dna.distance(donor_consensus, donor_candidate)
# 1
```
**Example 2:** Calculate the Levenshtein distance between the TATA box consensus and a candidate sequence.

```python

import levenshtein_dna

tata_consensus = 'TATAWAWA'  # W indicates A or T.
tata_candidate = 'TATAAATA'

distance = levenshtein_dna.distance(tata_consensus, tata_candidate)
# 0
```
## License
[MIT](LICENSE.txt)