semvec/pypi-packages huggingface dataset:
auto-schema 0.0.34
auto schema for a db
Requires Python: >=3.11

This takes a [sqlalchemy](https://www.sqlalchemy.org/) schema and applies [alembic](https://alembic.sqlalchemy.org/en/latest/) migrations.

It's used by the ent framework on top of  [alembic autogenerate](https://alembic.sqlalchemy.org/en/latest/autogenerate.html) to ensure that all supported schema types are automatically handled.

Will beef up this README eventually and add examples later.

Called as follows: `python3 auto_schema -s={pathToSchema} -e={engineURL}`.

Only supports Postgres DB at the moment.

## Concurrent indexes

auto_schema renders `CREATE INDEX CONCURRENTLY` when the SQLAlchemy index uses `postgresql_concurrently=True`. This is surfaced in ent via `indices: [{ ..., concurrently: true }]` or field-level `indexConcurrently: true` for `index: true`.

Notes:
- Concurrent index ops are wrapped in `autocommit_block()` in generated Alembic revisions.
- Drops are only concurrent if the generated op explicitly includes `postgresql_concurrently=True` (it cannot be inferred for removed indexes).

Design notes and tradeoffs:
- We do not default to concurrent drops. `DROP INDEX CONCURRENTLY` is Postgres-specific and must run outside a transaction; defaulting it everywhere would be surprising and would break non-Postgres use.
- We cannot infer whether an existing index was created concurrently once it is removed from schema. Postgres does not store that metadata, and Alembic's diff only yields a `DropIndexOp` without the flag.
- Alembic can render `postgresql_concurrently=True`, but it does not automatically wrap it in `autocommit_block()`. To guarantee correctness we use a renderer override; alternatives are custom ops that emit SQL or an autogenerate rewriter.

If we ever want concurrent drops, options include:
- Per-index `dropConcurrently` in schema.
- A global Postgres-only config flag to drop indexes concurrently (with warnings).
- A migration helper users can call explicitly when needed.

## Partial indexes

Partial indexes are supported via `postgresql_where=sa.text(...)` and `sqlite_where=sa.text(...)` in SQLAlchemy. In ent schema, use `indices: [{ ..., where: "place = 1" }]` or `indexWhere: "place = 1"` for `index: true`. The clause is a raw SQL string and should reference DB column names.
crml-lang 1.2.1
CRML language/spec models, schema validator, and YAML IO
Requires Python: >=3.9

# crml-lang

Language/spec package for CRML.

- Pydantic models for CRML documents
- Bundled JSON Schema + structured validator
- YAML load/dump helpers (`CRScenario`, `CRPortfolio`)

## Quickstart

Validate a scenario document:

```python
from crml_lang import validate

report = validate("examples/scenarios/data-breach-simple.yaml", source_kind="path")
print(report.ok)
```

Load and work with typed models:

```python
from crml_lang import CRScenario

scenario = CRScenario.load_from_yaml("examples/scenarios/data-breach-simple.yaml")
print(scenario.meta.name)
```

Bundle a portfolio (inline referenced scenarios/packs into a self-contained artifact):

```python
from crml_lang import bundle_portfolio

report = bundle_portfolio("examples/portfolios/portfolio.yaml", source_kind="path")
print(report.ok)

bundle = report.bundle
assert bundle is not None
```

Bundle from in-memory models (no filesystem access required):

```python
from crml_lang import CRPortfolio, CRScenario, bundle_portfolio

portfolio = CRPortfolio.load_from_yaml("examples/portfolios/portfolio.yaml")
scenario = CRScenario.load_from_yaml("examples/scenarios/data-breach-simple.yaml")

report = bundle_portfolio(
	portfolio,
	source_kind="model",
	scenarios={"s1": scenario},
)
print(report.ok)
```

Plan a portfolio (deterministic engine pipeline step):

```python
from crml_engine.pipeline import plan_portfolio

plan = plan_portfolio("examples/portfolios/portfolio.yaml", source_kind="path")
print(plan.ok)
```