semvec/pypi-packages huggingface dataset:
fastapi-middleware 0.2.1
Middleware for FastAPI
Requires Python: >=3.8

# [FastAPI](https://fastapi.tiangolo.com/) middleware

## Overview

`fastapi-middleware` provides a collection of middleware for enhancing [FastAPI](https://fastapi.tiangolo.com/) applications.

## Installation

Install `fastapi-middleware` directly from PyPI:

```shell
pip install fastapi-middleware
```

## Getting Started

To start using the middleware, import the components you need and add them to your FastAPI app.

### Example usage
```python
import logging

from fastapi import FastAPI
from fastapi_middleware import SQLQueriesMiddleware

app = FastAPI()

# Set logging level for middleware
logging.getLogger('fastapi-middleware').setLevel(logging.DEBUG)

# Add the middleware components
app.add_middleware(SQLQueriesMiddleware)
```

## Middleware Components

### `GlobalContextMiddleware`

The GlobalContextMiddleware provides a global context object (`global_ctx`) that allows you to store data throughout the lifetime of a request. This can be useful for sharing request-specific information across different parts of your application without needing to pass it explicitly.

#### Example Use Case
Add data to the global_ctx in one part of your application, and access it in other middleware or endpoint functions:

```python
from fastapi import FastAPI
from fastapi_middleware import GlobalContextMiddleware, global_ctx

app = FastAPI()

# Add the middleware components
app.add_middleware(GlobalContextMiddleware)

...

global_ctx.user_id = 12345  # Set user-specific data
global_ctx.foo = 'bar'      # Or set request-specific data
# Retrieve in other parts of the app: global_ctx.user_id, global_ctx.foo
```

### `SQLQueriesMiddleware`
The `SQLQueriesMiddleware` logs a concise summary of SQL query performance in a single `INFO` message for each request, making it easy to monitor query performance. Additionally, detailed query insights, such as the actual SQL statements of the fastest and slowest queries, as well as individual query statements, are available at the `DEBUG` level if configured. 

Key metrics include:

- Total SQL Queries: Number of SQL queries executed.
- Total Query Time: Combined execution time for all queries.
- Average Query Time: Average time taken per query.
- Fastest and Slowest Query Times: Execution times of the fastest and slowest queries, along with statements at DEBUG level.

#### Configuration
You can customize `SQLQueriesMiddleware` with the following option:

- `print_each_query` (bool): If `True`, logs each individual SQL query's time and statement at the `DEBUG` level. This setting is useful for in-depth debugging. Default is `False`.

#### Example Usage
```python
# Add SQLQueriesMiddleware with configuration
app.add_middleware(SQLQueriesMiddleware, print_each_query=True)
```

#### Example Log Output
```text
INFO:     [SQLQueriesMiddleware] Total Queries: 4, Total Time: 24.04ms, Avg Time: 6.01ms, Fastest: 0.46ms, Slowest: 13.30ms
DEBUG:    [SQLQueriesMiddleware] Fastest Query: Fastest Query: SELECT * FROM users WHERE id = 1;
DEBUG:    [SQLQueriesMiddleware] Slowest Query: SELECT * FROM orders WHERE status = 'pending';
```
LQGames 0.1.0
Package for synthesis and simulation of linear quadratic differential games
Requires Python: >=3.6

# LQGames

Hereâ€™s a long description in English that you can use for the package:

---

## Description

`LQGames` is a Python package for simulating and solving Linear Quadratic (LQ) games, suitable for both finite and infinite horizon problems. This package provides tools for modeling dynamic systems with multiple players, each aiming to minimize their individual costs based on the systemâ€™s states and control inputs. It includes functions for continuous-time Algebraic Riccati Equations (CARE) solutions, state evolution simulations, and control input calculations, making it ideal for advanced applications in control theory and game theory.

## Key Features

- **Infinite Horizon LQ Games**: Supports infinite horizon games, allowing for stable, long-term system evolution simulations and optimizations.
- **Finite Horizon LQ Games**: Solves finite-time LQ games with detailed time-step simulation, making it ideal for time-constrained scenarios.
- **Simulations of State and Control Evolution**: Perform time-step simulations of both system state trajectories and optimal control inputs.

## Installation

After publishing to PyPI, the package can be installed via pip:

```bash
pip install LQGames
```

## Usage

```python
from LQGames.LQGames import LQGame_Infnity, LQGame_Finity

# Initialize system matrices and parameters
A = ...  # Autonomous movement matrix
B = [...]  # List of input matrices for each player
Q = [...]  # List of state weight matrices for each player
R = [...]  # List of input weight matrices for each player
x_0 = ...  # Initial state vector

# Set up an infinite horizon LQ game
lq_game = LQGame_Infnity(A=A, B=B, Q=Q, R=R, x_0=x_0)
lq_game.Simulation_x()  # Simulate state evolution

# Access simulation results
states = lq_game.Simulation_x
```

## Requirements

- **Python 3.6+**
- **NumPy**
- **SciPy**
- **warning**
- **copy**

## License

This package is licensed under the MIT License.
ndoptimize 0.0.0
Numba-accelerated minimization of objective functions.
Requires Python: >=3.10

# ndoptimize

[![Black](https://github.com/sun-data/ndoptimize/actions/workflows/black.yml/badge.svg)](https://github.com/sun-data/ndoptimize/actions/workflows/black.yml)
[![Ruff](https://github.com/sun-data/ndoptimize/actions/workflows/ruff.yml/badge.svg)](https://github.com/sun-data/ndoptimize/actions/workflows/ruff.yml)
[![Documentation Status](https://readthedocs.org/projects/ndoptimize/badge/?version=latest)](https://ndoptimize.readthedocs.io/en/latest/?badge=latest)

Numba-accelerated minimization of objective functions.
ggd-py-utils 1.0.0
A collection of utility functions for my projects.
Requires Python: >=3.6

**Package Purpose**

The `ggd-py-utils` package is a collection of reusable utilities for Python projects. The package is designed to provide a set of useful tools for various tasks, including tracing, machine learning, and formatting.

**Dependencies**

The package requires the following dependencies:

* `faiss-cpu==1.8.0`
* `unidecode==1.3.8`
* `colorama==0.4.6`
* `chime==0.7.0`
* `fasttext-wheel==0.9.2`
* `plotly==5.22.0`
* `nltk==3.8.1`
* `tf_keras==2.18.0`
* `numpy==1.26.4`
* `torch==2.2.2`
* `sentence-transformers==3.0.1`

**Installation**

To install the package, run the following command:
```bash
pip uninstall ggd-py-utils -y; pip install ggd-py-utils --upgrade
```
**Updating**

To update the package, run the following command:
```bash
pip install --upgrade ggd-py-utils
```
**Uninstallation**

To uninstall the package, run the following command:
```bash
pip uninstall ggd-py-utils -y
```
file-text-extractor 0.1
A package to extract text from various file formats including PDF and DOCX.
Requires Python: >=3.6

# File Text Extractor

This package allows you to extract text from `.pdf`, `.docx`, and `.txt` files, either from a local file path or from a Google Cloud Storage (GCS) URI. The package handles file extraction directly in memory for GCS files, without the need to download them to the local system.

## Installation

1. Clone the repository.
2. Install the dependencies:

   ```
   pip install -r requirements.txt
   ```

3. Install the package locally:

   ```
   pip install .
   ```

## Usage

### Extracting from a Local File

```python
from file_text_extractor import extract_text

# Extract text from a local PDF, DOCX, or TXT file
local_file_path = '/path/to/your/file.pdf'
text = extract_text(file_path=local_file_path)
print(text)

### Extracting from a GCS URI

```python
from file_text_extractor import extract_text

# Extract text from a file in GCS
gcs_uri = 'gs://your-bucket-name/path/to/your/file.pdf'
text = extract_text(gcs_uri=gcs_uri)
print(text)
truncatedgaussianmixtures 0.1.7
Fit gaussian mixture models using truncated gaussian kernels. This is a python wrapper around the julia package TruncatedGaussianMixtures.jl

# Truncated Guassian Mixtures
[![Documentation](https://img.shields.io/badge/docs-online-blue)](https://potatoasad.github.io/truncatedgaussianmixtures/index.html)
[![PyPI version](https://badge.fury.io/py/truncatedgaussianmixtures.svg)](https://badge.fury.io/py/truncatedgaussianmixtures)

Fit data to mixtures of *truncated* multivariate gaussians

```math
   p(x) = \sum_k w_k\  \phi_{[{\bf a}, {\bf b}]}({\bf x} | \boldsymbol{\mu}_k, \boldsymbol{\Sigma}_k)
```

where ${\bf a}$ and ${\bf b}$ are the bounding corners of the hypercube we would like to truncate the gaussian in.
This package supports

- Full, Diagonal and Block diagonal covariances for each component
- Inteface to allow one to perform the fit in some latent space given by a user-defined transformation, and carry along any target labels
- Sampling and pdf evaluation from the resultant fit


Quick Start
===============================================================
You can install this library using

```bash
pip install truncatedgaussianmixtures
```

You can then import truncatedgaussianmixtures. At the first import it may take a while, since this will create a local
julia installation. This will only happen once at the first ever import. 

The main function to use is `fit_gmm`. The following is a simple example use case. 

```python
   import pandas as pd
   from truncatedgaussianmixtures import fit_gmm

   # Generate some data
   df = pd.DataFrame(np.random.randn(80_000, 2), columns=["x", "y"])
   
   # Truncated it to the unit square
   cond = (df['x'] < 1) & (df['x'] > 0)  
   cond &= (df['y'] < 1) & (df['y'] > 0)
   df = df[cond]

   # Fit it a truncated gaussian mixture model to it
   gmm = fit_gmm(data = df,      # data to fit to
                 N    = 1,       # Number of components of the mixture model
                 a    = [0,0],   # lower corner of the truncation
                 b    = [1,1],   # upper corner of the truncation
                 cov  = "diag"   # covariance structure: any of ("diag", "full")
          )

   # Sample from the gmm
   df_fit = gmm.sample(len(df));

   # Evaluate it at different points
   gmm.pdf(np.array([0,0]))
```