semvec/pypi-packages huggingface dataset:
fastapi_route_middleware 0.1.0
A decorator-based middleware system for adding middleware to specific FastAPI routes
License: MIT
Requires Python: >=3.8
Keywords: async, decorator, fastapi, middleware, web

# FastAPI Route Middleware

A dependency free™ middleware system for adding middleware to specific FastAPI routes. I just like how node express works.

## Installation

```bash
pip install fastapi_route_middleware
```

but actually I know you're using `uv`, so:

```bash
uv add fastapi_route_middleware
```

## Usage

The `add_middleware` decorator allows you to apply middleware functions to specific FastAPI routes, giving you fine-grained control over which middleware runs on which endpoints. Middlewares can access FastAPI Request and Response even if the original route does not. If a middleware returns anything, it will trigger an early return and won't cause the original route handler to be called.

### Basic Example

```python
from fastapi import FastAPI
from fastapi_route_middleware import add_middleware

app = FastAPI()

# Define a simple middleware function
def log_request(request_id: str):
    print(f"Processing request {request_id}")

# Apply middleware to specific route
@app.get("/items/{item_id}")
@add_middleware(log_request)
async def get_item(item_id: int, request_id: str):
    return {"item_id": item_id}
```

### Async Middleware Example

```python
from fastapi import FastAPI
from fastapi_route_middleware import add_middleware
import asyncio

app = FastAPI()

# Define an async middleware function
async def async_auth_middleware(user_id: str):
    # Simulate async authentication check
    await asyncio.sleep(0.1)
    print(f"Authenticated user {user_id}")

@app.get("/protected")
@add_middleware(async_auth_middleware)
async def protected_route(user_id: str, data: str):
    return {"message": f"Hello {user_id}", "data": data}
```

### Multiple Middleware Example

```python
from fastapi import FastAPI
from fastapi_route_middleware import add_middleware

app = FastAPI()

def rate_limit_middleware(api_key: str):
    print(f"Rate limiting for API key: {api_key}")

def audit_middleware(user_id: str):
    print(f"Auditing action for user: {user_id}")

# Stack multiple middlewares
@app.post("/api/data")
@add_middleware(rate_limit_middleware)
@add_middleware(audit_middleware)
async def create_data(api_key: str, user_id: str, payload: dict):
    return {"status": "created", "data": payload}
```

## How It Works

The `add_middleware` decorator:

1. Executes the middleware before calling the original route handler
2. Supports both sync and async middleware functions
3. Preserves the original function's signature for FastAPI's dependency injection

## Requirements

- Python >= 3.8
- FastAPI >= 0.68.0

## License

MIT
tems 1.0.4
Translation Equivariant ModelS
License: MIT
Requires Python: >=3.11

[![tests](https://github.com/pattonw/tems/actions/workflows/tests.yaml/badge.svg)](https://github.com/pattonw/tems/actions/workflows/tests.yaml)
[![codecov](https://codecov.io/gh/pattonw/tems/branch/main/graph/badge.svg?token=YOUR_TOKEN)](https://codecov.io/gh/pattonw/tems)
[![ruff](https://github.com/pattonw/tems/actions/workflows/ruff.yaml/badge.svg)](https://github.com/pattonw/tems/actions/workflows/ruff.yaml)
[![mypy](https://github.com/pattonw/tems/actions/workflows/mypy.yaml/badge.svg)](https://github.com/pattonw/tems/actions/workflows/mypy.yaml)

[![pypi](https://img.shields.io/pypi/v/tems.svg)](https://pypi.python.org/pypi/tems)

# Translation Equivariant ModelS (TEMS)

See the docs [here](https://pattonw.github.io/tems)

## Available Models
- UNet

## Why use these Models
- It is surprisingly annoying to make a torch modules that are compatible with `torch.jit.script` for easy packaging and sharing. All models in this library are tested for serlializaiton/deserialization with `torch.jit.script`
- All models in this library have some helpful properties:
    - `min_input_shape` - the minimum amount of data that can be passed through a model
    - `min_output_shape` - the output shape when given data with shape: `min_input_shape`
    - `context` - (`input_shape` - `output_shape`)
    - `equivariant_step` - The minimum value by which you must increase the input shape to be able to process without error
- All models are translation equivariant **when in eval mode and with padding="valid"**
    - To maintain translation equivariance, we sometimes need to crop more aggressively. This is only done in `eval` mode since it is assumed you will not be processing data blockwise during training. Note that `min_input_shape`, `min_output_shape`, and `context` will thus all change when the model is switched between modes.
    - This behaviour is explicitly tested and shown to be true s.t. while training, blockwise processing is not the same as full in memmory operations, wheras while in eval mode, this identity holds.
    - Crops to maintain translation equivariance are minimal to maximize the efficiency of blockwise processing with these models.
- Nice simple pure torch implementation. No other dependencies.
travelpy 0.1.1
Python wrapper for TRAVEL particle tracking simulations
License: MIT
Requires Python: >=3.10

# travelpy

Python wrapper for TRAVEL particle tracking simulations.

## Overview

travelpy provides a modern Python interface to the TRAVEL particle tracking code, making it easier to:

- Run TRAVEL simulations from Python scripts or Jupyter notebooks
- Analyze beam and beamline files programmatically
- Process simulation outputs and visualize results
- Automate parameter sweeps and optimization studies

## Quick Start

```python
import travelpy as tp

# Configure TRAVEL path (one-time setup, if needed)
tp.set_travel_directory("C:/Program Files (x86)/Path Manager/Travel")

# Run a simulation
result = tp.run_travel("beam.dat", "beamline.in")

# Display output files
result.display_output_files()

# Access simulation data with simple properties
avgout = result.avgout
rmsout = result.rmsout

# Analyze key results
print(f"Final transmission: {avgout.transmission.iloc[-1]:.1f}%")
print(f"Final beam energy: {avgout.ekin_avg.iloc[-1]*1000:.1f} MeV")
print(f"Horizontal emittance: {rmsout.emitt_norm_rms_x_xp.iloc[-1]*1e6:.2f} mm·mrad")

# Clean up output files when done
result.clean_outputs()
```

## Installation

```bash
pip install travelpy
```

## Requirements

- Python 3.10+
- TRAVEL simulation code (Windows only)
- NumPy, matplotlib

## Examples and Tutorials

The `examples/` folder contains comprehensive tutorials designed for newcomers to travelpy. These hands-on examples cover everything from basic simulation workflows to advanced features like parameter sweeps and parallel processing. Each example is self-contained with sample data and step-by-step explanations to help you get started quickly.

## Documentation

Full documentation with examples and API reference coming soon.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for development guidelines.

## License

MIT License - see [LICENSE](LICENSE) file for details.