semvec/pypi-packages huggingface dataset:
rhubarb 0.3.0
Avoid running multiple instances of the same celery task concurrently
License: MIT
Requires Python: >=3.8
Keywords: celery redis lock redlock mutex task lockable duplicate prevent

# Lock-based celery tasks using Redis

`rhubarb` provides a `LockableTask` which implements the [Redlock][1]
algorithm in order to guarantee that only one instance of a given task is
running at the same time, while preventing deadlocks from happening in case
of e.g. a worker getting killed, which is not uncommon in cloud environments.


## Why use rhubarb?

There are certainly other very similar libraries and tools that can help you
achieve the same results, but rhubarb aims to be a very opinionated approach
to the same problem these other libraries solve. You can use rhubarb without
changing any settings and be confident that the defaults will be enough to
not worry about it.

Rhubarb's long-term goal is to guarantee exclusive task execution with minimal,
almost inexistent downtime while taking resiliency towards unexpected worker
termination very seriously.


## Usage

```python
from rhubarb.tasks import LockableTask

@app.task(base=LockableTask)
def my_task():
    ...
```


## Settings

See the official celery [docs][2] on where/how to set the following settings:

* `rhubarb_backend_url`: URL to the Redis instance which will be used for
  creating the locks. If not present, will fallback to Celery's `broker_url`
  or `result_backend` settings, in that order of precedence.
* `rhubarb_backend_kwargs`: Dict of keyword arguments to pass to the Redis
  connection constructor, use for anything not present in the URL. Note that
  query parameters in the URL always take precedence over key-value pairs in
  this dict.
* `rhubarb_task_lock_ttl`: Global default expiry time for locks in seconds,
  if not present will default to 60 minutes.


## Testing

* Make sure you install both `requirements.txt` and `requirements-testing.txt`.
* Set up a local Redis instance, the `tests/` directory includes a `compose.yml`
  file which sets up a local Redis instance using `docker` and `docker-compose`.
* Run the `tox` command.


## Why is it called rhubarb?

It's a plugin for **celery** that implements the **Red**lock algorithm using
**Red**is... Have you ever seen a rhubarb? It's practically a red celery :-)


[1]: https://redis.io/docs/manual/patterns/distributed-locks/
[2]: https://docs.celeryq.dev/en/stable/userguide/configuration.html
forecast-verifier 0.1.2
Verify causal graph from data-driven models
License: MIT
Requires Python: >=3.9

# Forecast Verifier

Forecast verifier is Python package for verifying specified causal relationships between forecasts/predictions and covariates given trained models. The package goes one step beyond simple model explainability tools to extract learnt causal relationships, and verify them against existing domain knowledge.

Documentation can be found at: [Homepage](https://maichi-bui.github.io/forecast-verifier) 

## Installation
Install the forecast_verifier package using `pip` command:

```bash
pip install forecast-verifier
```

## Usage example
```python
import pandas as pd
from forecast_verifier.model import Forecaster, Regressor
from forecast_verifier.dataset import PerturbationDataset
from forecast_verifier.verifier import Verifier
from forecast_verifier.graph import PerturbationDirection, EffectDirection

# Create your model inheriting from Forecaster or Regressor that implements the forecast/predict method
class CustomForecaster(Forecaster):
    def __init__(self):
        super().__init__()
        # Initialize your model here    
    def forecast(self, dataset):
        # Implement your forecasting logic here
        pass

my_model = CustomForecaster()

# Load your dataset
original_data = pd.read_csv('your_dataset.csv')
pertubation_data = pd.read_csv('your_pertubation_dataset.csv')

# if pertubation_data are not available, create a PerturbationDataset based on original_data
perturbation_data = PerturbationDataset(original_dataset=original_data, 
                                        covariates=['covariate1'], 
                                        perturbation_direction=PerturbationDirection.increasing)
# increase covariate1 by 20% with bounds (-10, 40)
perturbation_data = perturbation_data.multipicative_perturb(0.2, bound=(-10, 40))
# increase covariate1 by 10 units with bounds (-10, 40)
perturbation_data = perturbation_data.additive_perturb(10, bound=(-10, 40))

# Define and verify causal relationships
## when covariate1 increases, the forecast should decrease, i.e., negative effect
## perturbation direction is increasing, meaning that we increase covariate1 from original_data to pertubation_data
verifier = Verifier(model=my_model, 
                    original_dataset=original_data, 
                    perturbed_dataset=pertubation_data, 
                    covariates=['covariate1'],                     
                    effect_direction=EffectDirection.negative,
                    perturbation_direction=PerturbationDirection.increasing)

print(verifier())
```
Check out other examples in examples/ folder